Iluvatar's picture

Triangles and Quads...

Hi I have a little Problem with a render-Call.
I try to render Quads (one Quad, to be precise)!

Using this Code:

            ///Bind the Vertex-Array
            GL.BindVertexArray(m_vertexArrayObject);
 
            ///Draw the Geometry
            GL.DrawArrays(BeginMode.Quads, 0, 4);
 
            ///Check for Errors
            if (GL.GetError() != ErrorCode.NoError)
            {
                Logger.SendToLog("An Error occured while rendering the GroundPlane", LogType.Errors);
            }
 
            ///Unbind the Vertex-Array again
            GL.BindVertexArray(0);

I get the Message posted! But with a slightly modified Version of the Code here:

            ///Bind the Vertex-Array
            GL.BindVertexArray(m_vertexArrayObject);
 
            ///Draw the Geometry
            GL.DrawArrays(BeginMode.Triangles, 0, 3);
 
            ///Check for Errors
            if (GL.GetError() != ErrorCode.NoError)
            {
                Logger.SendToLog("An Error occured while rendering the GroundPlane", LogType.Errors);
            }
 
            ///Unbind the Vertex-Array again
            GL.BindVertexArray(0);

Everything works fine! (Except that I only see one Triangle instead of the Quad....)

Does anybody know what the reason could be?
I can't figure it out :(
My Vertex-Array (and VertexBuffers) should work....

Best regards
Ilu


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Iluvatar's picture

I tried different modes now, this works well:

            ///Draw the Geometry
            GL.DrawArrays(BeginMode.TriangleFan, 0, 4);

Or did I mis-interpret the Quads-Mode?

Best regards
Ilu

the Fiddler's picture

Try printing the return value of GL.GetError(), it will give a hint at what might be wrong.

Iluvatar's picture

I tried it, and I get an "Invalid Enum"...
The Error is caused by the GL.DrawArrays call, because I put a GetError() before the Call and everything is fine there....

Thanks for your reply :)

the Fiddler's picture

Are you using a forward-compatible 3.0+ context? BeginMode.Quads is not supported there.

Iluvatar's picture

Ouch, yes, that's true ;)
Must have missed that it's not allowed :(....

Thank's for the Info!