Empty Begin/End drawing things!!!

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Empty Begin/End drawing things!!!

NickJPGeorge
EDIT: I realize how difficult it is to make any sense of the following problem, and I know no one wants to sift through the gory details of my program, so let me simply state:  I have something that's being drawn occasionally (maybe 1 in 20 times) in my program, when I have an empty glBegin(GL2.GL_QUADS);gl.glEnd();, that is not being drawn if I comment that out.  Why would that happen?


Longer version:

Ok, this is simply the most perplexing bug I've ever had with JoGL.  It took me many many hours just to characterize the bug this far.  The simplest way I can describe it is the following:

Something seems to be getting stuck in some kind of buffer.  My program draws a lot of a specific object (a box made with quads).  Originally I used a gl list for this, but for the sake of debugging, I made it make explicit calls every time.  I also have a sprite effect.  Sometimes when I draw the sprite effect, it gets covered up with a box that shouldn't be there.  I found that if I replaced the ENTIRE sprite drawing with

                gl.glBegin(GL2.GL_QUADS);
                gl.glEnd();

the box would somehow still be drawn.  If I comment out these last two lines, the box is not drawn.  Therefore, somehow, just having a begin/end with no code in between is causing an earlier displayed series of quad calls (the box) to be recalled.  What on earth could be causing this?!

Thanks for any help,
Nick
Reply | Threaded
Open this post in threaded view
|

Re: Empty Begin/End drawing things!!!

Demoscene Passivist
Administrator
Given the statement u provided u are right an empty glBegin(GL2.GL_QUADS);gl.glEnd(); is a legal combination according to the OpenGL spec. But often such "extreme cases" trap into some nasty driver bugs (e.g. see some recent Mesa3D bug regarding a similar issue: http://www.mail-archive.com/mesa3d-dev@lists.sourceforge.net/msg08483.html).

So keeping ur drivers up2date is always a good idea. Other than that is ur program working correctly when using display-lists ? If so maybe u do not correcty begin/end ur glBegin/glEnd calls leaving the driver in some undefined state ?!

Also don't hesitate to post/attach code snippets or even ur full code. Moste people here are crazy enough to read it

Reply | Threaded
Open this post in threaded view
|

Re: Empty Begin/End drawing things!!!

NickJPGeorge
I checked all my begin/end blocks, and I think they match up.  Here's some more description:

If I comment out the code that makes boxes be drawn, the 'phantom' box never appears.  If I comment out ALL of the code used to draw the sprite, the phantom box never appears.  If I leave in code for drawing normal boxes, and leave only "begin/end" for the sprite drawing, I occasionally get the phantom box.
Reply | Threaded
Open this post in threaded view
|

Re: Empty Begin/End drawing things!!!

Michael Bien
are you checking for GL errors, e.g by using the Debug Pipeline?
http://michael-bien.com/mbien/entry/jogl_2_composeable_pipline
regards,
michael


On 10/09/2010 02:17 AM, NickJPGeorge [via jogamp] wrote:
I checked all my begin/end blocks, and I think they match up.  Here's some more description:

If I comment out the code that makes boxes be drawn, the 'phantom' box never appears.  If I comment out ALL of the code used to draw the sprite, the phantom box never appears.  If I leave in code for drawing normal boxes, and leave only "begin/end" for the sprite drawing, I occasionally get the phantom box.


View message @ http://jogamp.762907.n3.nabble.com/Empty-Begin-End-drawing-things-tp1667610p1668419.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.



-- 
- - - -
http://michael-bien.com
Reply | Threaded
Open this post in threaded view
|

Re: Empty Begin/End drawing things!!!

NickJPGeorge
Hmm, does it matter that I'm using GL2 instead of GL3?  (I'm still kind of fuzzy about the difference)?

I used

drawable.setGL(new DebugGL2(drawable.getGL().getGL2())); instead.  

It doesn't give me any errors.

I've learned a little more about the problem:  The thing being drawn is a real thing, that should be drawn.   It's just being drawn at the wrong time.  So, for instance

gl.glPushMatrix();
//transforms  #1
//Draw Box
gl.glPopMatrix();

gl.glPushMatrix();
//transforms #2
gl.glBegin(GL2.GL_QUADS);
gl.glEnd();
gl.glPopMatrix();

The box is being drawn under transforms #2 instead of transforms #1, even though the begin/end block after transforms #2 is empty.
Reply | Threaded
Open this post in threaded view
|

Re: Empty Begin/End drawing things!!!

NickJPGeorge
The only solution I've found to this problem is to litter my code with blocks like

                gl.glPushMatrix();
                gl.glScalef( .001f , .001f, .001f);
                gl.glBegin( GL2.GL_QUADS );
                gl.glEnd();
                gl.glPopMatrix();

anytime I draw anything, making it draw these phantom objects really small somewhere I can't see them.  Obviously this is a very unsatisfactory solution.