preRender() and postRender(), how?
I need to add my own code before each frame is rendered (so that the lighting in my 'toon shader works properly), and i thought that over-riding the preRender method in canvas3D would be perfect for this. However, i'm miffed as to how to do this.
I've tried a quick test:
public class MyCanvas3D extends Canvas3D
{
preRender()
{
System.out.println("Pre-render");
}
}
which i would of thought would print a line before rendering each frame, but the compiler produces odd errors of "cannot resolve symbol" and something about canvas3d's constructors. Do i need to specify my own constructors? I don't need anything extra apart from custom pre(and possibly post)Render methods. Could anyone provide a breif bit of code that lets me define my own preRender method?
Thanks in advance.
Canvas3D has no default constructors, only constructors with parameters. So you have to add at least a constructors to your class, which calls one of the available constructors.Then you forgot to call the parent method Canvas3D.preRender( ) in the overriden preRender( ) method.
So if i wanted a constructor identical to the constructors in Canvas3D, could i use:
public MyCanvas3D(GraphicsConfiguration g)
{
Canvas3D.Canvas3D(g);
}
That doesn't seem right :( How do i call one of the existing constructors?
Although i don't think i need to call the parent method preRender(), the docs seem to suggest that this is an empty method designed to be overwritted like this.
Humour me here, and a quick code sample would be welcome...
> public MyCanvas3D(GraphicsConfiguration g)
> {
super( g );
> }
> Although i don't think i need to call the parent
> method preRender(), the docs seem to suggest that this
> is an empty method designed to be overwritted like
> this.
In general it is a good thing to call the parent method (it might do something necessary for the function of the parent class). If you have the info that it is an empty method you can of course skip it. But implementations might change ... . The compiler should recognize the empty method anyway and optimize this, so you don't loose anything.