Search code examples
openglglslpolygonfragment-shadervertex-buffer

OpenGL GL_POLYGON Not Functioning Properly


I have an OpenGL-related issue. Whenever I attempt to draw a simple polygon using four vertices from a vertex buffer... nothing happens. However, it will draw the shape in GL_TRIANGLES or GL_TRIANGLE_STRIP mode, albeit distorted. Am I doing something wrong?

Relevent code:

Vertex array: https://i.sstatic.net/4ybC6.png

GL_POLYGON: https://i.sstatic.net/cUEJR.png

GL_TRIANGLES: https://i.sstatic.net/3imiW.png

GL_TRIANGLE_STRIP: https://i.sstatic.net/N9Qfu.png


Solution

  • I'm using a forward-compatible 3.2 core profile

    First of all, never use a "forward-compatible core profile". You should just use a core profile; stop using the forward compatibility bit. It's pointless.

    More importantly, GL_POLYGON is not part of a core OpenGL profile. It was removed in 3.1. So your code is likely giving you a GL_INVALID_ENUM error that you're ignoring.

    Lastly, always post your OpenGL version and profile in your question.