PDA

View Full Version : Getting glDrawElements



Cribs
03-24-2007, 03:03 PM
Im having a problem getting Vertex Arrays working. When i compile the program, it compiles fine. When i run it i get a runtime error that says im trying to access memory from 0x00000000. When i try debugging it breaks at glDrawElements.

Right now I have the program just trying to draw a simple triangle to the screen. Im using SDL to do handle my window and opengl. Iv read an entire chapter from OpenGL Superbible about vertex arrays and I have looked at several samples that have all run without a problem. Here is my entire program. I have an extention header and a vec3d header but im sure the problem isnt in those, so this should suffice.

Here is the code for my test program:
http://cpp.sourceforge.net/?show=33399

Thanks in advance!
Cribs

Zengar
03-24-2007, 03:29 PM
You will have to load the function pointer manually, read the details in the wiki, somewhere under extensions.

Cribs
03-24-2007, 03:38 PM
Which function? glDrawEmelents? SDL loads glDrawElements for you.

WINGDIAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);

Zengar
03-24-2007, 05:45 PM
Ah, sorry, I somehow thought you were talking about glDrawRangeElements, which is in GL 1.2 and has to be loaded separately.

In this case my only bet is that you pass wrong pointers for indices and/or attribute arrays. Is it possible that you enable an array without binding an array pointer?

Cribs
03-24-2007, 08:46 PM
Ok, i fixed it, it was because i was calling:

glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );

when i initialized everything