Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Cybertron

OpenGL 'Vertex Buffer' in OpenGL?

This topic is 5955 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 am new to OpenGL and was wondering what it uses as an equivilent to ''vertex buffers'' like in D3D? Are there any other major differences that I should be aware of?

Share this post


Link to post
Share on other sites
Advertisement
Vertex Arrays. The differences aren''t huge, but the syntax might be strange. The functions you''ll want to look at are
-glEnableClientState(), glDisableClientState()
-gl*Pointer(...) where * is EdgeFlag, Index, Normal, TexCoord, Vertex, or Color. You don''t have to specify an array for each; just enable the ones you need and send a pointer for each of them
-glDrawArrays, glDrawElements, glDrawRangeElements, glArrayElement

This tutorial covers vertex arrays and their relation to multitexturing.
Little more info here...
Probably most useful:A simple spinning cube using vertex arrays. Beware the code, though. It''s not the most efficient.

G''luck.
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

Share this post


Link to post
Share on other sites
Thanks alot! It looks like I can even use the same type that DX uses for the verticies, normals and colors

One more question: I know OpenGL uses a matrix stack, while D3D uses 3 separate matricies. Is there any way I can emulate the 3 separate matrices in OpenGL? I am guessing I just need the ''view'' and ''world'' matrices to make a modelview matrix

Share this post


Link to post
Share on other sites
quote:
Original post by Cybertron
One more question: I know OpenGL uses a matrix stack, while D3D uses 3 separate matrices. Is there any way I can emulate the 3 separate matrices in OpenGL? I am guessing I just need the 'view' and 'world' matrices to make a modelview matrix

I'm not familiar with what Direct3D/DirectGraphics labels its matricies, but they should all have a counterpart in OpenGL (It's been a while, I could be wrong). Each of OpenGL's three matrices has a matrix stack. The three matrices are the projection matrix (the 'viewport' matrix), the modelview matrix (the 'camera' matrix), and the texture matrix (exactly what it's named ). Edit: typo.



[edited by - Null and Void on July 26, 2002 9:37:57 PM]

Share this post


Link to post
Share on other sites
OpenGL does not work quite the same as D3D. In Direct3D you set up your the view matrix and then the objects matrix before rendering by calling the SetTransform function twice. In OpenGL you use glRotate and glTranslate calls to set up the matrix. Basically when you make these calls you are changing the camera matrix just like you are when you call SetTransform(D3DTS_VIEW, &viewmatrix). In D3D you would call it again to set the object''s matrix, in OpenGL you use glRotate and glTranslate once again to multiply the current matrix by the objects matrix. So in the end its the same as having one matrix for the camera, one for the obect and multiplying them together for one final matrix which is used to transform everything. Direct3D does this also but does it through the two calls, one for the D3DTS_VIEW matrix (camera matrix) and D3DTS_WORLD matrix (object matrix).
D3D Way
...//create camera matrix
d3d_device->SetTransform(D3DTS_VIEW,&cameramatrix); //set camera
...//create object rotation and translation matrix
d3d_device->SetTransform(D3DTS_OBJECTMATRIX); //set object

OpenGl way
//change ''camera''
glRotatef(x,y,z,ang);
glTranslate(xpos,ypos,zpos);
//now move object
glTranslatef(objx,objy,objz);
glRotatef(ang,x,y,z);

Share this post


Link to post
Share on other sites

  • 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!