I give up... help?

Started by
11 comments, last by Frazzuld 24 years ago
I am trying desperately to figure out HOW to use DirectX. All I want to do is plot a pixel.. a single pixel... then a line... then a circle... I guess what I need are some SIMPLE demostrations of how this is suppoed to work... the ones provided with DX7 SDK dont help me. They explain something in the tutorial, then I go to the example and htere are 50 lines of crap I have never seen. Anyway, a truely basic tutorial would be nice, or a list of what functions will do what for me... Thanks!!
If it ain't broke, I haven't fixed it yet!!
Advertisement
You need to get a book, I got the book Sams Teach Yourself DirectX 7, and I fully recommend you get it. Although it doesnt cover displaying a single pixel (why would you want to know that anyways?) it does show you how to display an image file (which you can make a single pixel in size if you really wanted, hehe) and it shows you lot more and explains the stuff extremely well.

So well infact, that 1 month ago, I was asking that same question you are, how to display some king of an image or pixel or line on the screen and I couldnt find jack on the internet, so I got the book and now 1 month later, I have read almost half of the book and have already developed a hexagon tile engine similar to AOW and Civ2, with units and sound effects and everything!

There are a few other good books out there too I have heard, but getting books is by far the best way to go, the free stuff on the internet is just shit compared to them usually.

Possibility
Thanks Possibility!! I am gonna get that book tomorrow.. I figure they did well with their C++ in 21 days book, so I can take a chance on the DirectX book. I guess I am a little impatient because DOS games (mode 13h mainly) were fairly straight forward. I wouldn''t have switched except I wanted 16bit color.. anyway, thanks for the holler... Anyone else wanna reccomend a book? I got a good job today and I wdont mind building a library (no pun intended).
If it ain't broke, I haven't fixed it yet!!
Well I think possibly the best book for begginers on directX is "tricks of the windows game programming gurus" by Andre LaMothe.
"I have realised that maths can explain everything. How it can is unimportant, I want to know why." -Me
I''ll second that recommendation. I''m a graduating electronic game design student, and I have read a lot of books on the subject. LaMothe has been very good for me, and his "Tricks of the Windows Game Programming Gurus" is a huge tome of excellent DirectX 7 information as well as basic theory and a whole bunch of other stuff that is game oriented. Very good book. DirectX 7 in 24 hours is good as well... but still, there is no book that i have read that thoroughly explains all aspects of directX, there are simply too many. So, after reading the books, and programming a bit, once you come upon an obstacle, the next best place to go is the DirectX help file. It may look like greek to you right now, but once you understand what you are doing, that help file will bring you through most scenarios. Oh yeah, and this message board is my last hope if all other methods fail...

SPLiCE
A cheaper solution: http://www.gamedev.net/reference/programming/directx/article589.asp - Andre LaMothe''s Direct X-tasy article.

But of course, buying a book is most often a really good idea.

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Hey thanks guys... Looks Like I will get both books, and I am off to check that article right now!!
If it ain't broke, I haven't fixed it yet!!
I have been programming alot using directx and i learned everything i needed to know from Inside Directx (Microsoft Programming) and the sdk examples. I thought it was a great book and explained directx well except for direct 3D which it doesn''t cover and is a seperate book which just came out(hopefully i will be picking this one up soon when i get some time). Anyway once you get going you''ll probably want to create a primary surface and a back surface then Lock the back surface get a pointer to it and then you can set individual pixels by dereferncing the memory. DirectX does take a bit of set up to get going but once you get the ground work laid you should be good to go. You should take a look at both books anway (refering to the sams one) and see which is more your style. Good Luck in your quest.

--Fuel

I dream in Black and White.
Founder Caffeinated Gameswww.caffeinatedgames.com
Hey Frazzuld, I noticed nobody actually responded to your question without referring you to a book.

So, here''s some actual code... first, set up a surface. I assume you know how to do that (if you don''t, just email me). Then you have to lock the surface before you write. Then you write pixels, just as though you were pointing to a memory buffer, then you unlock.

Like so (assume we want to plot a pixel at 10,10 on an 8-bit surface (This is in C, not C++):


DDSURFACEDESC ddsd;
HRESULT hRes;
char *memptr;

ddsd.dwSize=sizeof(ddsd);
surface->lpVtbl->GetSurfaceDesc(surface,&ddsd);
hRes=IDirectDrawSurface_Lock(surface,NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR,0);

memptr=ddsd.lpSurface;

(ddsd.lpSurface is now a pointer to the memory the surface takes. You can memset it, or plot a single pixel, or do whatever you would normally do to draw to the screen).

When you''re finished drawing, you have to call:

IDirectDrawSurface_Unlock(surface,ddsd.lpSurface);

Make sure that ddsd.lpSurface doesn''t change during your draw routines. Also, try to minimize your locks and unlocks, since on some computers (one of mine) they can take up to 5000 cycles.






-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.
-- Goodlife-----------------------------Those whom the gods would destroy, they first drive mad.--DirectX design team official motto
Goodlife: Although it doesn''t matter, that code is in C++.

/. Muzzafarath
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall

This topic is closed to new replies.

Advertisement