flyx / OpenGLAda

Thick Ada binding for OpenGL and GLFW
flyx.github.io/OpenGLAda/
MIT License
95 stars 13 forks source link

Problem Drawing Quads #75

Closed rogermc2 closed 7 years ago

rogermc2 commented 7 years ago

I am trying to draw quads, but the following code fails: Draw_Elements (GL.Types.Quads, GL.Types.Size (Vertex_Data.Num_Elements), UInt_Type); with "raised GL.ERRORS.INTERNAL_ERROR : gl-raise_exception_on_opengl_error.adb:30"

It runs without error when Quads is replaced with Points, Lines, Line_Loop, Line_Strip, Triangles, Triangle_Strip, Triangle_Fan, Lines_Adjacency, Line_Strip_Adjacency, Triangles_Adjacency or Triangle_Strip_Adjacency.

It also fails with Quad_Strip, Polygon and Patches.

rogermc2 commented 7 years ago

I'm now wondering if the problem occurs because Quads apparently are deprecated? Further investigation reveals that in the latest Mac OpenGL framework file gl3.h the following definitions occur: / BeginMode /

define GL_POINTS 0x0000

define GL_LINES 0x0001

define GL_LINE_LOOP 0x0002

define GL_LINE_STRIP 0x0003

define GL_TRIANGLES 0x0004

define GL_TRIANGLE_STRIP 0x0005

define GL_TRIANGLE_FAN 0x0006

then later, under

ifndef GL_ARB_tessellation_shader

define GL_PATCHES 0x000E

..... / reuse GL_TRIANGLES /

define GL_QUADS 0x0007

Also, under

ifndef GL_VERSION_3_2

...

define GL_LINES_ADJACENCY 0x000A

define GL_LINE_STRIP_ADJACENCY 0x000B

define GL_TRIANGLES_ADJACENCY 0x000C

define GL_TRIANGLE_STRIP_ADJACENCY 0x000D

Polygon doesn't seem to be defined. Perhaps this is the reason that gldrawelements rejects modes quads, Quad_Strip, Polygon and Patches?

I now plan to replace quads with pairs of triangles in this and future examples which, in any case, seems to be recommended.

rogermc2 commented 7 years ago

OK now. Quads and others are deprecated, so I'll use triangles.