Archived

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

griffenjam

Major problem trying to call CreateSurface

Recommended Posts

I need help, I am using VC++ 6 and receently my graphics engine stopped working. It DID work before but no longer does. It fails in the call to CreateSurface with DDERR_NOTCOMPLEX or something like that, basicly it meens that I am trying to do something that needs a complex surface, but I don''t have one. But I am creating a Complex surface. O.k., now it gets wierd. I had a little somthing I wrote a long time ago that I based my current engine on, it still works. I used all the ddraw interface from that and created a new project with it, it doesn''t work in the new project. Its the same code to create the window, the same code to start up direct draw but on fails with that error, the older one doesn''t. I can only guess that it is VC++''s fault, because my code works, DirectX works, and my video card drivers work. What is wrong??????? Jason Mickela ICQ : 873518 E-Mail: jmickela@pacbell.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------

Share this post


Link to post
Share on other sites
If everything you say is true, I''d guess that its a linking conumdrum.

Did you install the Dx8 SDK or even the Dx7 SDK recently? I had many odd problems when I was using the dx8 headers & linking the dx7 libs (or maybe it was vice-versa).

Check Tools->Options->Directories
and add
C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\VC98\DX8\INCLUDE (or where ever they are on your ''puter)
to the TOP of the list in *both* the lib & header sections.

Then, blow away the debug & release sub directories & do full rebuilds (this alone could solve the problem).

Magmai Kai Holmlor
- The disgruntled & disillusioned

Share this post


Link to post
Share on other sites
Well, I don''t think it has anything to do with DX, or with strange info in Debug and Release directories because
A. It worked before and I have not modified my DX Wrapper
B I have not Re-Installed DX
C An older project based on an older version of my wrapper still works (that wrapper still uses DX7)
D A new project that uses the SAME WRAPPER as the project that works, does not work. Same code different result.

I have even changed the workspace settings file to look like the one in the project that works, that did nothing.

I have no idea what to do.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@pacbell.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------

Share this post


Link to post
Share on other sites
Well, I don''t think it has anything to do with DX, or with strange info in Debug and Release directories because
A. It worked before and I have not modified my DX Wrapper
B I have not Re-Installed DX
C An older project based on an older version of my wrapper still works (that wrapper still uses DX7)
D A new project that uses the SAME WRAPPER as the project that works, does not work. Same code different result.

I have even changed the workspace settings file to look like the one in the project that works, that did nothing.

I have no idea what to do.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@pacbell.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------

Share this post


Link to post
Share on other sites
Sounds like the parameters you are passing to your wrapper. Is your window handle valid? What flags are you passing? etc.

You''re the only one that has access to the code, so I can''t be more specific.

Share this post


Link to post
Share on other sites
Here is my code, its pretty standard though.
The wiondow handle is good and is tested before this function
is called.

int MyDDraw::DDrawInit(HWND hwnd, HINSTANCE hInst, DisplayMode Mode)
{
HRESULT hr;
DDSCAPS2 DDSCaps;
hWnd = hwnd;
hInstance = hInst;



hr = DirectDrawCreate(NULL, &lpDDOld, NULL);
if(hr != DD_OK)
{
MessageBox(hWnd, "Direct Draw Create Error", "Error",MB_OK);
return 1;
}

hr=lpDDOld->QueryInterface((GUID)IID_IDirectDraw4,(LPVOID*)&lpDD);
lpDDOld->Release();

if(hr != DD_OK)
return 1;
if(lpDD == NULL)
return 1;

hr = lpDD->SetCooperativeLevel(hWnd, DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN);

if(hr != DD_OK)
return 1;

hr=lpDD->SetDisplayMode(Mode.Width,Mode.Height,Mode.Depth, 0, 0);

if(hr != DD_OK)
return 1;

ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_VIDEOMEMORY;
ddsd.dwBackBufferCount = BUFFERS;
hr = lpDD->CreateSurface(&ddsd, &lpSurface, NULL);
//Create Surface is failing
if(hr == DDERR_OUTOFVIDEOMEMORY)
{
MessageBox(hWnd, "DDERR_OUTOFVIDEOMEMORY", "Error", MB_OK);
return 1;
}
else if(hr == DDERR_PRIMARYSURFACEALREADYEXISTS )
{
MessageBox(hWnd, "DDERR_PRIMARYSURFACEALREADYEXISTS", "Error", MB_OK);
return 1;
}
else if(hr == DDERR_NOEXCLUSIVEMODE )
{
MessageBox(hWnd, "DDERR_NOEXCLUSIVEMODE ", "Error", MB_OK);
return 1;
}


The above error is the one that comes up, I tried to clean up the code as best I could to make it readable in this window.
This USED to work, I have changed NOTHING. Nothing new was implemted. MAtter of fact, I quit working on my game for a while, that last I was working on it it was fine. Finally I re-opened it
tried to compile it to get an idea of where I left off, then this started. I didn''t even change any code from the last time it worked.

Share this post


Link to post
Share on other sites