Hi,
I'm trying to render a robot which has 7 joints. Each joint is an object called "Joint". I load the vertices correctly but I don't know why I can just see the first joint. I new in openGL so I don't understand very well if my calls are correct or not and the reason why...
Here you can check my code:
vertexArray is the array where I put my vertexs points previously.
GLuint vertexs[color="#000000"];
glGenBuffers[color="#000000"]([color="#000080"]1[color="#000000"],&vertexs[color="#000000"]);
glBindBuffer[color="#000000"](GL_ARRAY_BUFFER[color="#000000"],vertexs[color="#000000"]);
glBufferData[color="#000000"](GL_ARRAY_BUFFER[color="#000000"],sizeVertex[color="#000000"]*[color="#808000"]sizeof[color="#000000"](GLfloat[color="#000000"]),vertexArray[color="#000000"],GL_DYNAMIC_DRAW[color="#000000"]);
glEnableVertexAttribArray[color="#000000"]([color="#000080"]0[color="#000000"]);
glVertexAttribPointer[color="#000000"]([color="#000080"]0[color="#000000"], [color="#000080"]3[color="#000000"], GL_FLOAT[color="#000000"], GL_FALSE[color="#000000"], [color="#000080"]0[color="#000000"], [color="#000080"]0[color="#000000"]);
the render function:
[color="#808000"]void Joint[color="#000000"]::render[color="#000000"]()[color="#000000"]{ glDrawArrays[color="#000000"](GL_TRIANGLES[color="#000000"],[color="#000080"]0[color="#000000"],sizeVertex[color="#000000"]);}
Can you see a problem? Thanks
Troubles with glEnableVertexAttribArray
Hi,
I'm trying to render a robot which has 7 joints. Each joint is an object called "Joint". I load the vertices correctly but I don't know why I can just see the first joint. I new in openGL so I don't understand very well if my calls are correct or not and the reason why...
Here you can check my code:
vertexArray is the array where I put my vertexs points previously.
GLuint vertexs[color="#000000"];
glGenBuffers[color="#000000"]([color="#000080"]1[color="#000000"],&vertexs[color="#000000"]);
glBindBuffer[color="#000000"](GL_ARRAY_BUFFER[color="#000000"],vertexs[color="#000000"]);
glBufferData[color="#000000"](GL_ARRAY_BUFFER[color="#000000"],sizeVertex[color="#000000"]*[color="#808000"]sizeof[color="#000000"](GLfloat[color="#000000"]),vertexArray[color="#000000"],GL_DYNAMIC_DRAW[color="#000000"]);
glEnableVertexAttribArray[color="#000000"]([color="#000080"]0[color="#000000"]);
glVertexAttribPointer[color="#000000"]([color="#000080"]0[color="#000000"], [color="#000080"]3[color="#000000"], GL_FLOAT[color="#000000"], GL_FALSE[color="#000000"], [color="#000080"]0[color="#000000"], [color="#000080"]0[color="#000000"]);
the render function:
[color="#808000"]void Joint[color="#000000"]::render[color="#000000"]()[color="#000000"]{ glDrawArrays[color="#000000"](GL_TRIANGLES[color="#000000"],[color="#000080"]0[color="#000000"],sizeVertex[color="#000000"]);}
Can you see a problem? Thanks
I can see one problem with your code:
On the call to glDrawArrays, the last parameter is the number of indices you want to render (in this case, the number of triangles), not the total size of the vertex array.
Assuming that on vertexArray, you store your vertices in the form x, y, z, x, y, z, etc,...
and sizeVertex is the size of this array you should pass ( sizeVertex / 3 ) to glDrawArrays.
Other than that, it's hard to tell why is not working, can you post more code?
ps: someone correct me if i'm wrong, im still kinda new to opengl and etc
Did you rebind the buffer before you drew? It also seems like you didn't call the program with the shader before you drew..
Also are you planning on moving the robot? If so where did you learn how to move it? I am trying to figure out how to move stuff with vbo's
Also are you planning on moving the robot? If so where did you learn how to move it? I am trying to figure out how to move stuff with vbo's
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement