• Advertisement

Archived

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

DirectX is driving me crazy

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

Hey all I''m trying to make a simple game. Very simple, all I want to do at this point is display a background image and another image on top of that and animate it. Sound fun? Maybe I''ll add more after this, but I''m having problems now...I don''t get any syntax errors when I compile. Here''s the basic algorithm of my code: // Allocate DirectDraw stuff above o Load in the background bitmap o Set the Palette created above with the bitmap''s palette o Create a DirectDraw surface the size of the bitmap o Lock the newly created surface o Copy the bitmap''s buffer to the surface.lpSurface buffer o Unlock the surface o Finally, Blit the surface to the primary surface The code compiles fine but when I execute nothing but blackness comes up. If anyone can help me out or point me to some working code...that would be great Thanks

Share this post


Link to post
Share on other sites
Advertisement
a whole bunch of things may be wrong. Check the return calls of your DD calls with:
if(FAILED(lpdd->CreateSurface(..)))
MessageBox(NULL, "Error Init", "Error create surface", MB_OK);

to at least give the post a little bit more info as to where things are going wrong.
just one thing, you are in 256 color mode before setting palette right?

another thing... how can you load the background bitmap when the surface hasn''t been created yet?

"what does allocate dd stuff above" do? You should create all your surfaces and load them up with a bitmap there.

Share this post


Link to post
Share on other sites
>Check the return calls of your DD calls with:
>if(FAILED(lpdd->CreateSurface(..)))
>MessageBox(NULL, "Error Init", "Error create surface", >MB_OK);

Good idea, I''ll try that

>just one thing, you are in 256 color mode before setting >palette right?

Yup

>another thing... how can you load the background bitmap >when the surface hasn''t been created yet?

I created a structure for bitmaps...among other things it has a pointer to a buffer, this is where I put the image, then after I create the surface I move the buffer to the surface. There''s probably a better, more efficient way of doing this, which is why I''m posting this ...also because my way''s not working.

>"what does allocate dd stuff above" do? You should create >all your surfaces and load them up with a bitmap there.

I just put that there to say that I''ve initialized DirectDraw...meaning I have a pointer to dd and I have a primary surface and a palette (since I''m in 256 color mode).





Share this post


Link to post
Share on other sites
Attach clippers to both your backbuffer and primary surface. If for some reason your bitmap is out of bounds even 1 pixel, without a clipper it won''t be drawn at all. I''ve had the same problem, and it was just because no clippers were attached.



*Tony Chamblee*

Nucleus Software

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You have a surface, and it has a pointer to surface data? Note, that pointer given is valid ONLY when the buffer is locked, so you have to lock it

surface->Lock (pamams);
// load data to the surface
surface->Unlock();

And be sure to understand what is the meaning of lPitch param...

...doh, all this is clearly (?) explained in DD documentation, why no one ever bothers to read it...?
(now, if I understood you wrong and that is what you did, sorry, my apologies

Share this post


Link to post
Share on other sites
my advice would be to scrap the pallets, theyre more trouble than they are worth.

it''s not as if you need to be in <= 8bit color depth, right?

use 16bit (or more) colors any that may solve your poblems...

oh, and dont give any 1993 crap about 16bit being slow or 16bit bitmaps being larger than 8bit...computers seldom use floppies (if at all...) for games and MOST modern (even semi modern) video cards can churn out loadsa fps in 16bit (providing you dont go mad with screen resolution...)

hell, most games in development these days use 32bit...

of corse, if there is some good reason youre using 256 colors, just ignore me

why not give cdx a look (http://www.cdx.sk), makes things a LOT easier...

Share this post


Link to post
Share on other sites

  • Advertisement