Archived

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

VI2

how to convert generic vertex to API depended type

Recommended Posts

Hi guys, I have my own data structures for my application, and it uses both directx and opengl. i''m wondering what the best way is to convert my data structures to directx and opengl are. Like I have my own vertex data types... I want to abstract my program from the api... which is why I''m running into these issues. I''ve looked into sdl and such but I''m looking to do some of this on my own. What are some of the techniques used to convert data types on the fly?

Share this post


Link to post
Share on other sites
You need to be a lot more specific. OpenGL and D3D don''t have vertex types.


John Bolton
Page 44 Studios
Current project: NHL Faceoff 2005 PS2

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well forexample I have a grid class which is suppost to let you put a grid anywhere in any orientation... i want to be able to render the same thing in dx and opengl...

so i have my grid class and a render function that calls a generic function drawline. Draw line takes 2 points and can call one of 3 functions depending on gdi directx or opengl..

i''m just wondering what the best way to setup the datastructure for something like this since I might be rendering to different devices.

Share this post


Link to post
Share on other sites
IMO you should just dump you vertices in a raw float array and render them inline, by lines (v1-v2, v3-v4), or by triangles (v1, v2 v3, v4 v5 v6), no matter how your struct is, the vertice usually turns out to be in the xyz order so a quick move of memory into the array from your struct should work.





--- At The Edge Of Time

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I don''t quite understand what you mean. Could you explain what you mean by a quick move of memory into an array.

Share this post


Link to post
Share on other sites