# 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
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 on other sites

(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 on other sites
Hi!

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

Quad and triangle are rendered in wire mode.

EDIT: screen shot fixed

##### 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 on other sites
I get the same result as enmaniac.
Nothing filled.

GeForce 7800 GS / ForceWare 162.18

##### 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]

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627661
• Total Posts
2978496
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 12
• 22
• 13
• 33