DirectX Code Rot?
Ok, so I've dug some old code that I wrote about 6 months ago and started playing with it. Problem is, when I try to run the executable it produces, it fails. I've traced the problem into this piece of code:
DDSURFACEDESC2 ddsd; // DD surface description (Primary surface)
DDSCAPS2 ddscaps; // DD surface capabilites struct
// 0-fill ddsd (just to be safe)
ZeroMemory(&ddsd, sizeof(ddsd));
// Fill in the surface description
ddsd.dwSize = sizeof(ddsd); // Set the size
ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT; // Set valid flags
ddsd.dwBackBufferCount = DISPLAY_BACKBUFFERCOUNT; // Back buffer count
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE / // Request a primary surface
DDSCAPS_COMPLEX / // " a complex surface
DDSCAPS_FLIP; // " a flippable surface
// Create the primary surface
if (FAILED(rVal = m_lpDD->CreateSurface(&ddsd, &m_lpDDSPrimary, NULL)))
return rVal;
The call to CreateSurface always fails with "Invalid Params". I don't understand why when this worked six months ago. Everything that I do prior to this call; SetDisplayMode, Initialize, etc. works fine and returns DD_OK. It's only this call that fails (in any display mode I try).
If somebody has had a similar problem, please let me know.
Thanks,
David
Edited by - Stark on 7/6/00 12:21:24 PM
Okay, with that out of the way the only thing that stood out is that you are dividing the flags for the dwFlags and ddsCaps.dwCaps members instead of ORing.
Anonymous, the board turns binary OR operators into divides. /// (that *should* be three binary OR signs, but they show up as divides).
- Muzzafarath
Mad House Software
The Field Marshals
- Muzzafarath
Mad House Software
The Field Marshals
Crap, stupid copy and past. hehe. The flags aren''t actually being divided in the code. It must''ve gotten twisted during the copy and past.
Ya, I guess it does convert them. How odd. I thought I musta screwed up something as basic as copy and paste until I tried to edit my original post.
I have had a similar problem. I think the problem lies in the fact that your driver doesn''t support one of the Caps
DDSCAPS_COMPLEX or DDSCAPS_FLIP. Do a DevCaps to findout if these are supported on your machine.
DDSCAPS_COMPLEX or DDSCAPS_FLIP. Do a DevCaps to findout if these are supported on your machine.
quote:Original post by DeltaVee
I have had a similar problem. I think the problem lies in the fact that your driver doesn''t support one of the Caps
DDSCAPS_COMPLEX or DDSCAPS_FLIP. Do a DevCaps to findout if these are supported on your machine.
It''s possible. The only thing that has changed is my machine. Originally developped my code using a P-166 and Matrox Mystique. Recently, I upgraded to an Athlon 550 with a TNT2.
Weird thing is, I''ve tried to write the struct initialise like so, also:
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
It still return "Invalid Params".
I''ve tried this same code on a GeForce, and a 3D Rage Pro. All with the same result.
I get a similar weird ass problem when trying to attach a backbuffer, but only in DirectX 7.
I have 650 athlon and Rage 128.
I have 650 athlon and Rage 128.
What have you got DISPLAY_BACKBUFFERCOUNT defined as?
If its 0, the call will fail. That''s the only thing that you haven''t written in that could cause the creation to fail. Try just changing to:
ddsd.dwBackBufferCount = 1;
I haven''t noticed anything else wrong with that code...
HTH
n!
If its 0, the call will fail. That''s the only thing that you haven''t written in that could cause the creation to fail. Try just changing to:
ddsd.dwBackBufferCount = 1;
I haven''t noticed anything else wrong with that code...
HTH
n!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement