Skip to main content
GameDev.net gamedev.net
🔒 Locked

Create a DX surface while specifying BPP

Started by WymsicalWyvern Sep 17, 2000 at 10:45 PM 11 replies 550+ views
Original Post
WymsicalWyvern
WymsicalWyvern
Can someone tells me why this fails?:

ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = usWidth; ddsd.dwHeight = usHeight; ZeroMemory( &ddsd.ddpfPixelFormat, sizeof( DDPIXELFORMAT ) ); ddsd.ddpfPixelFormat.dwSize = sizeof( DDPIXELFORMAT ); ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; ddsd.ddpfPixelFormat.dwRGBBitCount = usBitDepth; hr = m_pDD4->CreateSurface( &ddsd, &m_pDDS, NULL ); thanks in advance
Bigshot
Bigshot
Did you remember to clear ddsd first? Like this:
ZeroMemory(&ddsd, sizeof(ddsd)); 

That could be one problem.
morfe
morfe
That shouldn''t be a problem. I never remember to do that but it always works for me.

Try declaring
ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT;


I.e. leave out the DDSD_HEIGHT & DDSD_WIDTH tags.

Otherwise it may be your dwCaps type ...



"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
Bigshot
Bigshot
I''d recommend you try my idea. I just commented out the ZeroMemory line in my engine and now surface creation fails, so I know I need that line of code. Could be something else too, though.

Good luck,
Alex
MuteAngel
MuteAngel
I agree with Bigshot. I spent a lot of time trying to figure why my DirectX application would crash until I found that I didn''t clear the ddsd structure. Once cleared everything ran fine.
WymsicalWyvern
WymsicalWyvern
k, i tried those, they didn''t work, so i put it back and checked the error message, says its an invalid pixel format, am i not specifying enough data or not the right data? This specifying pixel formats stuff is quite vague in the DX help files

The wymsical wyvern
SikCiv
SikCiv
I thought u couldnt use a different BBP than the Front buffer?..maybe thats the problem.

Surfaces in the Video cards'' memory have to be the same BBP unless they can convert the Surface automatically (guessing logically), dont know about surfaces in SysMem though.
  Downloads:  ZeroOne Realm
WymsicalWyvern
WymsicalWyvern
well right now, the surface i''m creating just happens to be the same bit depth as the primary surface, btw, what are the pros and cons for system memory surfaces?

The wymsical wyvern
Bigshot
Bigshot
It''s possible to use a different pixel format, but I''ve heard there are limitations. Why would you want to use a different pixel format than your primary surface anyway? To create a normal offscreen surface all you would need to do is remove that second chunk of code you have listed with all the ddsd.ddpfPixelFormat stuff and take out the DDSD_PIXELFORMAT from your ddsd.dwFlags and add ZeroMemory(&ddsd, sizeof(ddsd)); above everything!! Then it should work just fine and dandy!

Alex
WymsicalWyvern
WymsicalWyvern
lets just say, given my engine''s architecture, i MUST specify the BPP


the wymsical wyvern
Syzygy
Syzygy
First, you should definately be able to create surfaces with format other than the primary format (you just can''t expect a Blt() call to convert betwen them). You may not be able to create a non-primary format in VIDEO memory, but you should definately be able to create it in SYSTEM memory. You''re not specifying either in your surface description, so DDraw should try video memory first and fall through to system memory if that fails, so that''s not your problem.
I can''t be sure, but I''d guess that you can''t fill in the bpp count of the DDSURFACEDESC structure without also specifying the Red, Green, Blue, and Alpha bitmasks. After all, just saying 16 bits doesn''t give the video card enough information. For example, it could be 555, 565, 1555, or 4444?

...Syzygy
Hway
Hway
Clearing ddsd will not do any harm.

You''ll have to specify bit masks too.

RTFM.

And why people keep asking questions that are
clearly answered in SDK docs?!?

(...sorry, it''s been a bad day...)
~~~ "'impossible' is a word in the dictonary of fools" --Napoleon

Topic Locked

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

Sign in to reply to this topic.