opengl vertex buffer and index
Hy.
I' have some experience in directx 10 , now i must create an opengl application , in directx 10 i use vertex buffers and index buffers for drawing objects , there is a corrispondence in opengl?
What do you advice to me for learning opengl from directx?
thanks.
Vertex Buffer Objects
VBOs can store indicies/verticies, or whatever you want. If you want to draw these things, you just bind your buffer and use any of the drawing commands. For example, to draw using indicies, you could use glDrawElements.
As for advice, I haven't used DirectX in ages, so I personally have none. Maybe someone else has some for you!
VBOs can store indicies/verticies, or whatever you want. If you want to draw these things, you just bind your buffer and use any of the drawing commands. For example, to draw using indicies, you could use glDrawElements.
As for advice, I haven't used DirectX in ages, so I personally have none. Maybe someone else has some for you!
GLint matrixMode; glGetIntegerv(GL_MATRIX_MODE, &matrixMode); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(this->getPosX(), this->getPosY(), m_zorder); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 0, &m_vertices[0]); glTexCoordPointer(2, GL_FLOAT, 0, &m_texCoords[0]); glColorPointer(4, GL_FLOAT, 0, &m_simple_color[0]); glDrawArrays(GL_QUADS, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glPopMatrix(); glMatrixMode(matrixMode);
Here, that is how I draw a Quad. That are no VBO, like aryx, said, but Arrays. But I think they are stored the same way by my Videocard, because in MY application, I do not see any difference in performance. Anyway how is this done?
You can either put all Vertices, TextureCoords and Color in one struct and use the stride to tell OpenGL how they are arranged. I use 3 different Arrays for one Object. Color, TextureCoordinate and Vertices. Simple Structs. Then I fill them with data and pass them to OpenGL.
Hope you understand my explanation.
regards
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement