Jump to content
  • Advertisement

Archived

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

Mythomania

OpenGL Mapping DirectX to OpenGL

This topic is 6067 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

Hello everybody, I''m developing a 3D engine using DirectX which I plan to port to other OS/APIs. Since I don''t know much about OpenGL I have problems designing my interface classes. e.g. I have a vertex buffer class which behaves much like the DX8 vertex buffers do. I read a bit about OpenGL, and specifying vertices seems to be different there. That confuses me because I''m pretty sure that the DX vertex buffers are laid out in the same way as in hardware. And because I want a fast engine (of course) I need to know how to treat the vertices in OpenGL. I hope you understand what the problem is, my description sounds a bit strange... And BTW: I need someone else to help with the engine since it''s quite a bit of work. If somebody''s interested, just send me an email and I''ll tell you more.

Share this post


Link to post
Share on other sites
Advertisement
DirectX uses vertex buffers and custom vertices, like you already know. You can specify OpenGL vertices in two different ways. YOu can either do vertex by vertex, like shown here:

glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
glEnd();

or use vertex arrays. I''m not too familiar with vertex arrays, so I might give you the wrong info if I post some code. But, the basic concept is that you have an array of floats containing all of your vertex information or one containing the tex coords, one containing the locations, one containing the normals, etc. You specify the arrays through the function gl*Pointer, * representing Vertex, Normal, etc. Then you use either glDrawElements, glDrawRangeElements, or some other function.

Share this post


Link to post
Share on other sites
thanx maonium.
new to me is, that i can put all vertex data in one array. this is the way opengl (and i think hardware) does it. but i couldn''t find anything about that in the opengl 1.2 specification.
can anybody point me to some links where these kind of vertex arrays is specified (or maybe other links which explain how to do opengl things just like in dx/hardware)?

Share this post


Link to post
Share on other sites
have a look at Vertex Arrays here

http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/@ebt-link;cs=fullhtml;pt=38709?target=%25N%14_4472_START_RESTART_N%25#X

That will give you the basix background to what you are trying to achieve, but note that this method has been superceded using OpenGL extensions ... nvidia for example use NV_VERTEX ARRAY_RANGE.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Humm....
Interesting link...

http://nehe.gamedev.net

Sure that after their 32 tutorials(the best I''ve seen),
you''ll be able to finish your project without
any prob''...

Go check it out !!!

Share this post


Link to post
Share on other sites
ok, another question:

how are more complex vertex formats achieved in ogl? as far as i can see only simple vertex types are supported...
what if i want to use an additional color(specular), several (3d)textures or indexed vertex blending?
ogl doesnt seem to support these things...

Share this post


Link to post
Share on other sites
EXT_secondary_color
EXT_separate_specular_color
3dtextures doesnt really make sense, do u mean 3d texture coordinates?
EXT_vertex_weighting

Share this post


Link to post
Share on other sites
Hava a look at this for volumetric textures:

EXT_texture3D - http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture3D.txt


Edited by - meZmo on November 12, 2001 2:57:31 PM

Share this post


Link to post
Share on other sites
thanx a lot everybody.
i''m slowly starting to understand how opengl works...
i just don''t like this extension stuff...do all the developers have different extensions each?

and im still not sure whether i have understood how vertex arrays work. let me summarize:

one can either store the different parts of one vertex in separate arrays OR store everything in one array. i can imagine how the first possibility would be coded, but from the docs i cant figure out the second one.
could somebody post a little example please?
and i would also like to know if its possible to add the extended vertex parts like vertex weighting into one array with the others or if i have to use separate arrays in that case?

Share this post


Link to post
Share on other sites
basically opengl unlike d3d is a state machine thus anything turned on will remain on until u turn it off,
typically all the vertex arrays stuff is off when u start.

*beware* the syntax below is most likely wrong
glEnableClientState( GL_VERTEX_ARRAY ); vertices ON
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); texture coords on
glEnableClientState( GL_VERTEX_WEIGHTING_ARRAY ) vertex weighting ON

// where is all the info stored that u want to draw

VertexWeightPointer( ... , ptr_weightweightsdata );
TexCoordPointer( ... , ptr_texcoordsdata );
VertexArrayPointer( ... , ptr_verticesdata );

// draw it

glDrawArrays(.. ) or drawelements(..)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!