![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jun 2007
Posts: 218
![]() |
I think it would be convenient if there was some sort of distinction between when a renderable that performs it's openGL setup and when it does its actual drawing.
I have the following picture in my head that would add a little consistency to parts of the codebase. Code:
public interface Renderable {
/**
* Causes this <code>Renderable</code> to render itself using the <code>DrawContext</code> provided. The
* <code>DrawContext</code> provides the elevation model, openGl instance, globe and other information required for
* drawing. It is recommended that the <code>DrawContext</code> is non-null as most implementations do not support
* null <code>DrawContext</code>s.
*
* The expectation is that the Renderable will perform any necessary
* openGL setup, and then use its draw method to perform the actual drawing,
* though this is not required (ie for Renderables that use batched rendering)
*
* @param dc the <code>DrawContext</code> to be used
* @see DrawContext
*/
public void render(DrawContext dc);
/**
* Causes this Renderable to render itself using the DrawContext provided
* using the current OpenGL state.
*/
public void draw(DrawContext dc);
}
// This could be an abstract class with an abstract draw method
// but I implemented it this way to ease with migrating the current codebase
public class BasicRenderable implements Renderable {
/**
* Set up the OpenGL state for this Renderable to be rendered.
* This method is intended to be overriden by subclasses
*/
public void beginRendering() {}
/**
* Restore the OpenGL state to its previous value (ie using glPopAttrib()).
* This method is intended to be overriden by subclasses
*/
public void endRendering() {}
public void render() {
try {
beginRendering();
draw();
}
finally {
endRendering();
}
}
public void draw() {
throw new UnsupportedOperationException();
}
}
Last edited by remleduff; 01-29-2008 at 02:56 PM. |
|
|
|
|
|
#2 |
|
Developer
Join Date: Dec 2007
Posts: 55
![]() |
I believe that is the correct intent. However, you shouldn't modify the Renderable interface IMO.
I created my own rendering framework that sits on top of WWJ. I have a hierarchy of entities, all of which are derived from a common interface. Furthermore, I generally extend from a standard implementation that has doPreRender(), doRender(), and doPostRender() methods (Entity->BasicEntity->*Entity). Much like WWJ, I use a prefix of do* in order to further control the rendering process (e.g. frustum culling, where the do* methods aren't called if the entity is not visible in the frustum). |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jun 2007
Posts: 218
![]() |
Well, I was mostly suggesting a change for the WW code that I thought would be useful, I can of course do whatever I want in my own code.
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two suggestion for the online xml files | Guest_Jim_* | Suggestion Box | 2 | 04-26-2007 11:36 PM |
| Next-generation user interface ideas | Jessi | Suggestion Box | 65 | 03-29-2006 03:14 AM |
| GIS interface | DC | Suggestion Box | 8 | 02-05-2006 02:12 AM |
| Suggestion: show the most detailed imagery on zoom | Superrobster | Suggestion Box | 1 | 07-02-2005 08:31 PM |
| Multilingual interface | 5of0 | Developers' Corner | 2 | 02-14-2005 08:00 PM |