PDA

View Full Version : GL_POLYGON and QT: working after update.. why!??



giello
09-20-2013, 09:05 AM
Hi guys,

I'm using opengl with Qt and I'm working on shapefiles.

Basically, I was taking the shapefile and building the map with OpengGl drawing points, lines and polygons depending on the data retrieved from the shapefile.

The problem was with the GL_POLYGON: it added lines that they shouldn't be there to close the polygon (I think).

In another computer, now I have just updated all the packages and it seems that this problem isn't present anymore.

Have you idea of what happened? chich package is the responsible of this behaviour?

Thank you in advance!

Ps I'm on OpenSuse 12.2!

GClements
09-20-2013, 04:13 PM
Basically, I was taking the shapefile and building the map with OpengGl drawing points, lines and polygons depending on the data retrieved from the shapefile.

The problem was with the GL_POLYGON: it added lines that they shouldn't be there to close the polygon (I think).

You are aware that GL_POLYGON is limited to convex polygons, right? If you need to draw non-convex polygons, you need to either tessellate them into a set of convex polygons (e.g. using the GLU tessellation routines) or use stencilling.

If you try to draw a non-convex polygon with a single GL_POLYGON call, the results are undefined, and likely to vary according to the hardware and driver.

giello
09-23-2013, 01:18 AM
You are aware that GL_POLYGON is limited to convex polygons, right? If you need to draw non-convex polygons, you need to either tessellate them into a set of convex polygons (e.g. using the GLU tessellation routines) or use stencilling.

If you try to draw a non-convex polygon with a single GL_POLYGON call, the results are undefined, and likely to vary according to the hardware and driver.



Ok, I understand. Thank you for your suggestions.

The fact is that in the other computer it works great.. very strange...


Which solution do you suggest to use? is there anything already ready in OpenGL?

giello
09-23-2013, 01:31 AM
wouldn't it possible that OpenGl internal implementation changed in a way to draw concave polygons?

thokra
09-23-2013, 06:05 AM
What hardware configs are you testing on?

giello
09-23-2013, 07:23 AM
the one in which tessellation is ok uses an amd FirePro while the other it's a GeForce, I have to check for the model number

thokra
09-23-2013, 07:50 AM
Well, maybe the AMD implementation does tesselation internally. In general, GClements is right and if it works on AMD, they're probably doing it wrong.

On another note, why exactly do you think you need to use POLYGON?

giello
09-23-2013, 08:57 AM
I understand.

I'm using GL_POLYGON along with GL_LINE_LOOP, GL_LINE_STRIP and others functions.. it depends on the shapefile's data.

Actually, I think the problems are due to GL_LINE_LOOP..

GClements
09-23-2013, 09:30 AM
Which solution do you suggest to use? is there anything already ready in OpenGL?
Assuming that the data is static, use the GLU tessellation functions and store the tessellated data.

giello
09-23-2013, 09:52 AM
Ok, thank you. I think I'll tessellate each polygon on the fly