Sign in to follow this  
Andrew Kabakwu

OpenGL Strange opengl behaviour

Recommended Posts

Hi, I've never seen this problem before. Am developing a win32 opengl program and have set the polygon rendering mode as follows
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);

When I render OpenGL primitives in the following order
     glBegin(GL_POINTS)

     glEnd()



    //rectangle B
    glBegin(GL_QUADS);
       glColor3f(0.0f,1.0f,0.0f);
       glVertex3f(b[0][0],b[0][1],b[0][2]);
       glVertex3f(b[1][0],b[1][1],b[1][2]);
       glVertex3f(b[2][0],b[2][1],b[2][2]);
       glVertex3f(b[3][0],b[3][1],b[3][2]);
    glEnd();


    //triangle A				
   glBegin(GL_TRIANGLES);
     glColor3f(1.0f,0.0f,0.0f);
     glVertex3f(a[0][0],a[0][1],a[0][2]);
     glVertex3f(a[1][0],a[1][1],a[1][2]);
     glVertex3f(a[2][0],a[2][1],a[2][2]);
   glEnd();



   //Swept shape c
   glColor3f(0.0f,0.0f,1.0f);

   glBegin(GL_POINTS);
	for (int i=0; i<(num_a * num_b); i++)
	{
	   if(c[i][0] != 0.0 || c[i][1] != 0.0 || c[i][2] != 0.0)
	   {
		glVertex3f(c[i][0], c[i][1], c[i][2]);
	   }
	}
   glEnd();


The first set of GL_POINTS renders properly. Then the Rectangle using GL_QUADS also renders as a wire frame as expected and the last set of points also renders as expected. Now comes the problem. The triangle using GL_TRIANGLES renders as a SOLID FILLED triangle and not as a wire frame. I've moved the triangle up before the rectangle and in that case it is the Rectangle that renders as a SOLID polygon. I've determined that doing in a single frame a render order of GL_POINTS,GL_TRIANGLES,GL_QUADS and then back to GL_POINTS causes the GL_QUADS to be filled. (This also happens when its GL_POINTS,GL_QUADS,GL_TRIANGLES and back to GL_POINTS the GL_TRIANGLE becomes filled) Am not changing the polygon fill mode at all. Could anyone explain how this can be happening? PS: If I group the GL_POINTS render in a single batch at the top or bottom (i.e eliminating the 2nd call to GL_POINTS in a single frame) this problem does NOT OCCUR! [Edited by - Andrew Kabakwu on August 13, 2007 12:45:33 PM]

Share this post


Link to post
Share on other sites
I've included a link to where you can download the program source am referring to.

(Note: this program is suppose to perform the Minkowski Sum (difference) which is what the calculate_points_c function does and is not relevant to the OpenGL problem)

It is just as I explained in the first post, when you run it you will see a wire frame rectangle and a white center point for the (0,0) origin.

The triangle is rendered as a solid instead of a wire frame, which is wrong according to the settings I've used.

If you follow the comments in the RenderScene() function above the 2 glBegin(GL_POINTS) blocks, then you'll see the behaviour change.

Win32 Source to Strange OpenGL behaviour

Share this post


Link to post
Share on other sites
Hi!

As for me it looks that everyting is ok. Here is the screenshot I got after running the app

screenshot

Quad and triangle are rendered in wire mode.

EDIT: screen shot fixed

Share this post


Link to post
Share on other sites
I have tried your code, and I do get the strange behaviour aswell. I have an ATI card with not so recent drivers, and I could try it at home with an NVIDIA card aswell.

I have tried several combinations or drawing order and numbers of primitives to draw, and it's always the last batch before a GL_POINT batch that is incorrectly filled. A following GL_LINES batch is OK, but not GL_POINTS.

For example, if you have a sequence of point - triangle - point batches, the triangle batch is filled. Point - triangle A - triangle B - point, then A is lined and B filled (if a triangle batch contains multiple triangles, they are alled rendered the same; lined or filled). Point - triangle A - triangle B - point - triangle C - triangle D - point, then A and C are correct, and B and D are incorrect. However, if a flush is forced (glFlush) just after a triangle batch, it is always rendered correct.

Definitely looks like a driver bug to me. Seems like they render points using triangle primitives, and in order to get a filled point the fill mode must be temporarily restored to fill mode. However, it looks like they insert the fill mode command a batch too early into the command buffer.

Share this post


Link to post
Share on other sites
My video card is an ATI Radeon (according to windows its an x1300PRO)

so I went and got the latest drivers for ATI X1300 series, installed it and the problem went away.

(Also windows now identifies my video card as an ATI x1550 series. )

Thanks for all the responses

[Edited by - Andrew Kabakwu on August 14, 2007 12:53:04 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this