Saving DrawingState in WorldWind with OpenGL4

104 views Asked by At

I am currently trying to display a PointCloud on the WorldWind map. All the examples on the WorldWind website are done using OpenGL2. But i tried to use OpenGL4 instead, because I used it a little bit before.

Now I ran into a problem while managing drawing state:

"Any state that we change from the WorldWind default must be restored after rendering the cube, or it will cause other objects to render incorrectly"

Managing drawing state. In OpenGL2 it is fairly simple. Before anything is drawn beginDrawing() is called.

protected void beginDrawing(DrawContext dc){

GL2 gl = dc.getGL().getGL2();

int attrMask = GL2.GL_CURRENT_BIT | GL.GL_COLOR_BUFFER_BIT;
gl.glPushAttrib(attrMask);

if (!dc.isPickingMode())
    dc.beginStandardLighting(); }

The glPushAttrib method is used to save the state and is later poped in the endDrawing().

protected void endDrawing(DrawContext dc){
GL2 gl = dc.getGL().getGL2();

if (!dc.isPickingMode())
    dc.endStandardLighting();

gl.glPopAttrib();   }

Can I achieve the same thing with OpenGL4? If yes how?

Everything I found until now is for OpenGL2. I found out that DrawContext has Methods called restoreDefaultCurrentColor(), restoreDefaultDepthTesting() and restoreDefaultBlending() but they didn't help.

Edit: So i found out that if i call gl.glBindProgram(0) to unbind the currently used program i actually can see something. I see the standard layers of WorldWind. That means the stars, city names etc. But the Globe is still dark. It looks like something breaks during the rendering.

0

There are 0 answers