Jump to content
  • Advertisement
Sign in to follow this  

glArrayElement, glDrawElements C#

This topic is 4653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get glArrayElements and glDrawElements to work in C# and am having problems. I do not have lighting. Example 1 works like it should, well Example 2 shows a blank screen and Example 3 crashs. float[,] vertices = {{ -1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, { -1.0f, 1.0f, 1.0f}}; private float[,] colors = {{1.0f, 0.0f, 1.0f }, {1.0f, 0.0f, 1.0f }, {1.0f, 0.0f, 1.0f }, {1.0f, 0.0f, 1.0f}}; byte[,] frontIndices = {{0, 1, 2, 3}}; GL.glEnableClientState(GL.GL_COLOR_ARRAY); GL.glEnableClientState(GL.GL_VERTEX_ARRAY); GL.glColorPointer(3, GL.GL_FLOAT, 0, colors); GL.glVertexPointer(3, GL.GL_FLOAT, 0, vertices); Example 1 GL.glColor3f(1.0f,0.0f,1.0f); GL.glBegin(GL.GL_QUADS); GL.glVertex3f(vertices[0,0], vertices[0,1], vertices[0,2]); GL.glVertex3f(vertices[1,0], vertices[1,1], vertices[1,2]); GL.glVertex3f(vertices[2,0], vertices[2,1], vertices[2,2]); GL.glVertex3f(vertices[3,0], vertices[3,1], vertices[3,2]); GL.glEnd(); Example 2 GL.glArrayElement(0); GL.glArrayElement(1); GL.glArrayElement(2); GL.glArrayElement(3); Example 3 GL.glDrawElements(GL.GL_QUADS, 4, GL.GL_BYTE, frontIndices);

Share this post

Link to post
Share on other sites
I don't know anything about C# but:

Example 2
With glArrayElements, you still need glBegin and glEnd

Example 3
You're only draw ONE primitive, not 4 (even though there 4 vertices)
GL.glDrawElements(GL.GL_QUADS, 1, GL.GL_BYTE, frontIndices);
8-bit indices aren't usually used. That shouldn't be a problem though

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!