Archived

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

Gwahir the Windlord

Overawed by Direct3D

Recommended Posts

I am an amature game programmer, and have been trying to learn for the past 3 or so years how to code games. My expirence began with Interplay''s Learn to Program Basic, then I graduated to QuickBasic, then to DarkBasic. I have finally made the leap to join the ranks of real programmers, learning C/C++, and am doing pretty well. I have made a few simple but awesome(considering they are made totally by me) 2D games using raw DirectDraw. It wasn''t so bad, with a few helper functions I learned to load and display sprites in just a line or two of code, and could abstract all the junk away from my game code. Now, I am ready to move into the realm of 3D. I took one look at the direct3D code and just about wet my pants. That stuff looks nasty. That I could learn it eventually I don''t doubt, and I plan to, but from what I saw, it seems that you need to fill out multiple massive structs just to display a cube on the screen. Now, there is no way anyone could write a game like that. So they must abstract the hairy, confused code away, and have a nice clean set of functions to use within thier actual game. So, I need to make a wrapper, I think it is called. So far, so good. But now I come to a hard thing. The Documentation isn''t that great, and the only way I can learn to code is by doing. This has held true for every language or API I have learned. But I cannot do it all at once. Or I could, but it would take forever, and result in massive frustration, with most of the code simply copied from tutorials, and me not really understanding it. This leads us to my question. Is there a good open source wrapper for Direct3D that comes with basic functions such as load object, place object, rotate object, ect. Similar to the commands in DarkBasic? To tell you the truth I liked darkbasic''s 3D commands a lot, but after using C++ I cannot endure using BASIC code any more. So I think a wrapper that provided some simple functions like that, but that was open source, allowing me to tweak and experiment with it, and add my own directX commands would simply be great. It would allow me to ease into Direct3D relativly painlessly, while still having fun coding. Thanks. P.S. If you know of such a wrapper, even if it isn''t open source, could you tell me as well? I really want to make 3D games, but learning Direct3D from scratch would take months, and yet be really boring, so I would want somthing to program with, even if it isn''t as professional as Direct3D.

Share this post


Link to post
Share on other sites
JimboC    152
It''s acually not as bad as it first looks. Get a cheap 3d program that will let you export your models to a .3DS format and use the converter that comes with the SDK. If you look at some of the basic samples that come with the SDK, you''ll see that putting basic 3D shapes on the screen isn''t too bad (animating them is a bit more difficult though to be honest). You can build from there, adding effects and optimizations as you go.

Share this post


Link to post
Share on other sites
iNsAn1tY    476
Or, you could do what I did, and use OpenGL, which doesn''t have such a horrific initialization routine.

I too looked at the code for D3D, just a while after starting to learn OpenGL, to compare the two. I downloaded some sample code, and after looking through the four pages of it required just to set up the window, I decided to stay with OpenGL.

Don''t get me wrong. D3D is probably just as good as OpenGL, and perhaps has a little more flexibility, as you can delve a little deeper into it, but I personally don''t like D3D that much. With OpenGL, you can still use DirectInput for keyboard stuff, DirectSound, DirectSound3D and DirectMIDI for sound and music, and DirectPlay for networking...

iNsAn1tY - the place where imagination and the real world merge...
Try http://uk.geocities.com/mentalmantle

Share this post


Link to post
Share on other sites
DanG    122
Insanity is right in that to begin with, OGL is easier. Using GLUT for a window and basic feedback you can have a interactive cube on the screen in 2 pages of code. However as you move along to Windows for interaction and advanced 3D, they completely level out. Niether is superior. Ask that question on these forums and i will find you and mercilessly pester you.

I can''t really suggest you put a wrapper on D3D before you learn it. I really suggest you stick with it for a week and learn the opening calls and get a cube on the screen. Keep using it until you start to understand what calls are doing what, then write your own wrapper. That will really make you an expert at beggining D3D. D3D is very popular and finding info is really simple. If you haven''t yet, go to nexe.gamedev.net. Also try Monopolsoft website and google. Just keep learning! A wrapper will just make you learn someone''s wrapper and not the REAL D3D!

He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Share this post


Link to post
Share on other sites
Bill6    122
I keep thinking I should go back and learn OpenGL (since I haven''t used it since release 1, oh what a piece of shit it was back then...damn slow 486s), but I''m sticking with DX for a little while longer. Unless, of course, I keep having problems with other people''s machines that I can''t test on. I never even thought about using DX in conjunction with OpenGL. That''s a great idea as far as using DX''s input, sound, and network capabilities. Thanks for the great idea.

B6

Share this post


Link to post
Share on other sites
a person    118
if you do plan on d3d, make sure you learn dx8 since its much cleaner then the other versions. also you may not realize it, but the docs and samples with sdk are great and well done. just requires you to think a little. the structs are not huge, and there are few you need to fill out. sometimes the struct descriptions can be slightly confusing, but for the most part the sdk samples clear everything up.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
D3D isn''t bad at all once you learn it. I''m talking about D3D7, and from what I hear, d3d8 is even simpler. The hard part is figuring it out for the first time. Once you do that things are much simpler. One thing you should do is make a class to hold things like "Init" so you can set everything up with a single call. Then you should make an Uninit which handles making sure everything is shut down correctly. After that you don''t really "need" any more helper functions, though I''m sure you''ll find a time or two where one could be convienant.

OpenGL may be simpler than D3D but it''s also a little lower on the compatability and performace totem pole for Windows. Just another example of D3D run well, look at X-BOX. D3D may nto be the easiest to learn, but once you do you can do some amazing things and do them very effeciently.

Share this post


Link to post
Share on other sites
Ok, thanks everyone. I think I will go with learning raw Direct3D. It''ll be hard, but since you advise it, I''ll give it a try, if you are honest when you say it is easier then it looks at first glance.

One thing about not needing helper functions though, how is that possible? I mean, even in directdraw to load a bitmap you need to fill out a BITMAP struct, create a HBITMAP, load it into the DirectDraw Surface, delete the HBITMAP, ect. Like at least thirty lines of code, if I recall correctly. Way to much to have right in the middle of my game. So I made a function that loaded a bitmap into a DirectDraw surface. Much easier to use. But if I don''t even have to do that with Direct3D, it will be much easier.

Share this post


Link to post
Share on other sites
JHL    150
Start with a really simple dx app that just clears the screen, then make it render like two triangle with vertex colors with out transformation, then make those triangle textured. Do this with out righting any wrappers. Now Look at what you have done and say "this really isn't that hard". Now start writing you wrapper. This is exactly what I did when I went to convert my 2d rts engine to 3d.
As for opengl the my setup code isn't really any longer then that for an opengl project I did recently. And getting a fullscreen window in opengl seems to be a well kept secret.

Edited by - JHL on January 13, 2002 8:02:41 PM

Share this post


Link to post
Share on other sites
Infinisearch    2964
Use DirectX 8.1 it is pretty simple to get started in, it even includes an App wizard for VC++. Thats the place to start for learning D3D the API, but if u don''t know the theory it will be rough going. So if u don''t know any 3d theory I would suggest learning the theory, making a really simple 3d game or demo with your own 3d code using directdraw since u said you need to ''do'' in order to learn. Once u learn enough to do that start browsing the D3D SDK and code generated by the app wizard. You should be comfortable with D3D by then. Oh and alot of tutorials on the Net can help u out.

Share this post


Link to post
Share on other sites
a person    118
you do realize that loading various formats ARE ussually done as functions or classes. anyhoo, d3d8 has texture loading capabilities (functions that create a texture surface froma file) which include bmp, jpg (pretty sure), tga (with alpha channel), png (again unsure). the main reason i am unsure about the exact capabilities of the loading functions is simply because i use my own image loader system which stays away from using HBITMAP DIB loading hack style crap. there is also ability to load .x format 3d models. i think there is even a converter with the sdk that converts from 3ds to .x format.

Share this post


Link to post
Share on other sites
Oluseyi    2103
OT:
quote:
Original post by DanG
He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Actually, he who said "money is the root of all evil" misquoted a proverb. Ironically, everyone assumes the misquote is the original.

Look it up some time. The actual statement has a subtle but profound difference.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
Promit    13246
When i was using D3D8, i found two "gotchas". One was the matrices things. That was just standard 3D theory though. The BIG gotcha was the vertex structures. After you understand what the hell those are, then things start making sense.

PS when starting, dont worry about rhw. Just set it to one.

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Share this post


Link to post
Share on other sites