#### Archived

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

# Problem with D3DX...

This topic is 6567 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anyone know why I would be getting a DDERR_CANNOTATTACHSURFACE error when I attempt to create a D3DX context? My program registers/creates the window, then it calls D3DXInitialize(), checks the caps, and calls D3DXCreateContextEx(). I have tried both CreateContextEx and CreateContext, even with all defaults and I get the same thing each time. I have tried removing the caps check. I''ve tried making D3DXInitialize the very first call in WinMain. I''ve changed up some of the window reg/creation params. I always get the exact same error. The SDK explains the error as
quote:
A surface cannot be attached to another requested surface.
If anyone knows how to fix this, please enlighten me. Thanks in advance for the help. Oh... The SDK examples work fine. Imagine that!

##### Share on other sites
What type of card do you have, and what parameters are you giving D3DXCreateContext()?

Maybe you can get some help from my tutorial: Introduction to Direct3D which uses D3DX

- WitchLord

##### Share on other sites
I''m using a Voodoo3 2000. I''ve tried many different combinations of parameters with both D3DXCreateContext() and D3DXCreateContextEx(). I''ve even tried supplying all D3DX_DEFAULT parameters where they are accepted. Does this tell you anything?

I''m taking a look at the tutorials now.
Thanks for the help.

##### Share on other sites
The Voodoo3 doesn''t have stencil buffers.

I believe one of the defaults for stencil buffer actually tries to make a stencil buffer. Make sure the parameter for stencil buffer is 0, and then make the rest default...

If that doesn''t work, try hard-coding WIDTH/HEIGHT to 640/480...

If that doesn''t work, specify a bit-depth of 16.
(if you specify defeault for bit depth, the context will default to the bit depth of your desktop, and if you run your desktop in 24 bit it will try to make a 24 bit bit depth)

If that doesn''t help try running your desktop in 16 bits.

If that doesn''t work, hmmm...

##### Share on other sites
Thanks for the help JoeyBlow2. Unfortunately, I had previously tried setting the stencil bits to zero. Doh! I also run my desktop in 16bit. And I want to create my D3DX object in 1024x768 preferably, but I have tried 640, 800, and 1024. This is bugging me. If it would help to take a look at some of my source, I would be more than willing to oblige. Once again, thanks for taking the time to try and help me out. I appreciate it.

##### Share on other sites
Well i have a voodoo 3 2000, try this:

  D3DXCreateContext(D3DX_DEFAULT, D3DX_CONTEXT_FULLSCREEN, hWnd, 1024, 768, &g_pd3dx);or...D3DXCreateContextEx(D3DX_DEFAULT,D3DX_CONTEXT_FULLSCREEN, hWnd,NULL,16,D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT, D3DX_DEFAULT,1024,768,D3DX_DEFAULT,&g_pd3dx);

With D3DXCreateContextEx i run into a weird situation, if numAlphaBits,numDepthbits, or numStencilBits are set to NULL or 0 instead of D3DX_DEFAULT, i lose quite a few fps and there are graphical glitches in parts of my game.

BTW, g_pd3dx is my pointer to the ID3DXContext interface.

+AA_970+

Edited by - +AA_970+ on July 12, 2000 5:06:40 PM

##### Share on other sites
Thanks for the help +AA_970+, but I am still getting the same error. I''m not going to give up without figuring this out, but it''s really making me bitter. I''ve looked at all of the SDK examples and all of the tutorials that I''ve found, and I haven''t found any major differences in them and my code. It doesn''t matter exactly where I call D3DXInitialize() as long as it''s the first D3DX function that I call, right? The DirectX help and the SDK examples are somewhat unclear about this. I made it the very first call in WinMain, but that didn''t help. Currently, it''s the first call in my InitD3DX function which is called immediately after the window is created. Thanks for all the help. I''m gonna keep looking.

BTW, In case it makes any difference, I have the same code implemented in DDraw/D3D and it works great. I just figured that changing to D3DX would simplify things a little more.

##### Share on other sites
You said your had the code implemented in DDraw/D3D. Now that you switched to D3DX are you still starting up direct draw?
The D3DX context creates D3D and DDraw, so you wouldn't have to init. DDraw. You also don't have to do QueryInterface, SetCooperativeLevel, SetDisplayMode, create the primary surface, and create the back buffer.

+AA_970+

Edited by - +AA_970+ on July 13, 2000 12:24:45 PM

##### Share on other sites
Nope. I trashed the DDraw and D3D code when I changed to D3DX.

##### Share on other sites
Here''s something new. It works fine in windowed mode. I only get the error when I try to run fullscreen. *frowns*
Does this shed any light on the problem?

1. 1
2. 2
Rutin
22
3. 3
JoeJ
20
4. 4
5. 5

• 27
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631735
• Total Posts
3001942
×