Skip to main content
gamedev.net
🔒 Locked

DirectX questions...

Started by illuzion Nov 25, 2001 at 11:40 PM 2 replies 300+ views
Original Post
illuzion
illuzion
Hi I''ve been programming using OpenGL for a while now, but I want to get started with Direct3D. Ideally, my new engine will use a plugin system, so you can choose to render with either OpenGL or D3D, and to the main program, they''re both the same. So I have a couple of questions about D3D from a OGL programmer''s perspective: - can you use arrays of data, like compiled vertex arrays, or arrays of vertices, normals, etc? These can really speed things up with OpenGL, and I''d like to use the same data structures with both rendering engines. - how does D3D handle textures? As far as storing them, generating them, loading them from a file, etc, I mean. - I''m not really sure what other things I''m going to have to ask. Can anyone give me a good idea of the main differences - from a programming point of view - I''m not trying to make a DirectX vs OpenGL debate, I just want to know what problems I''m likely to run into when trying to have one program, one data set, etc, that uses both of them. Thanks, David.
sysmark
sysmark
I use both OpenGL and Direct3D, and I think Direct3D is better for the stuff you mention.

1) Direct3D uses vertex & indexbuffers. You define a vertex format (transformed / untransformed, color, normal, texture coordinates), then you create the buffer either static or dynamic. The hard part is to make efficient use of these buffers, because one mistake can send your framerate to a snailpace. But once you get it right you'll see that d3d is as fast, but I think even faster, than OpenGL because this can be highly optimized.


2) Direct3D texturing works basicly the same as OpenGL. You can load them using the Direct3DX library and it will even generate the mipmaps for you. A lot of formats are supported, but the most important ones are JPG and BMP. If you want to render primitives using a texture you just have to set it and that's that. Of course you can set certain flags to change the texture filtering and stuff.

Edited by - sysmark on November 26, 2001 3:45:39 AM

Edited by - sysmark on November 26, 2001 3:47:45 AM
illuzion
illuzion
Thanks.

So, if I had an array of vertices and an array of indices (into the the vertex array) as I might if I was using OpenGL, can I use exactly the same thing using Direct3D?

What other ways of doing this are there?

Thanks,
David.
siaspete
siaspete
You can do something similar, but you don''t keep your data in a regular C array, as you want them to be kept in video memory.

Basically you store your indices in a D3D Index Buffer, and your vertices in a D3D Vertex Buffer.

The best way to find out the differences is to download the newest SDK and have a look through the tutorials.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.