简体   繁体   中英

glDrawElements not working in the other machine

I'm using OpenGL with g++. This simple code works fine in my system. It draws a rectangle as expected.

GLfloat vertices[] = 
{
    0,0,0,  //0
    0,6,0,  //1
    6,6,0,  //2
    6,0,0,  //3
};
GLint indices[] = {0,1,2,3};
glColor3f(1,0,0);
glVertexPointer (3, GL_FLOAT, 0, vertices);
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, indices);

But in my friend's system, it gives segmentation fault.

I changed GL_UNSIGNED_INT to GL_INT . Then at least it does not give segmentation fault but its not rendering anything.

What can be the reason for this?

Read your documentation carefully

Don't forget to glEnableClientState(GL_VERTEX_ARRAY);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM