DirectX8 SDK and the Clear function

Started by
7 comments, last by Random-Axess 21 years, 9 months ago
Hey all! I''m running a Windows 98 (not SE) machine with no graphics accelarator and DirectX 8.0 SDK. I''m using the Visual C++ 6.0 Compiler. I haven''t, however, updated it with service packs. My main thing is this: when i created a DirectDraw Device (named m_pD3DDevice, i wanted to clear the screen and fill it blue. So i use the Clear function, like so: m_pD3DDevice ->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLORXRGB(0,0,255), 1.0f, 0); it compiles properly, but i get an error when i try to run it. When i open the Debug for it, it points to the last 0 that is passed to the Clear function. What''s wrong? I can''t seem to figure it out! Is it just a windows problem or what?
Advertisement
What exactly does the error message say? The last 0 is for the stencil value - it doesn''t seem to make a difference if you are not specifying a stencil fill.

the name of the window is D3d window
the error:
This program has performed an illegal operation and will be shut down.

I click debug, and i get this error, pointing to the last 0 in Clear:
Unhandled Exception in D3d Window.exe: 0xC0000005: Acess Violation.

at this point itried skipping over that but then
i get the same error on the next line, which is
m_pD3DDevice ->BeginScreen();
My dollar says that your D3d object pointer isn''t pointing at anything. Either check if it is using variable watch in debug or somthing.

i''m sorry, i''m pretty new to DirectX programming and such...where/how do i access variable watch??
also: to fix this, how would i do it?
I''m currently following a book and i''ve checked with the code it shows in the book, and mine''s the exact same (minus the comment variations). Also, when i tried to use the Source Code off the book''s CD, i got the same error.

I''m beginning to think its a windows problem--both that it''s running Windows98 (non SE) and that i''m running it on (temporarily) on a laptop which has a crappy Chip Technologies video chipset.

However, if there is a way to solve this, and it isn''t the fault of the computer OR the compiler (rather a Code error) then someone please let me know!
*bump*
What AP is saying is that the m_pD3DDevice is not pointing to a device. Most likely you need to go back and make sure that there was not an error when it was created. it would be a line somthing like this...

D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,Window,D3DCREATE_HARDWARE_VERTEXPROCESSING,&pp,&m_pD3DDevice);

the code you are using sounds like it's trying to create a device that your video card can't make...

try changing to something like this..

D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,Window,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&m_pD3DDevice);

and check the return value..it should be D3D_OK if the device is created ok, otherewise it will point to garbage.


[edited by - dabx11 on July 2, 2002 2:44:16 AM]
Watch out for

  if( m_pD3DDevice = NULL ){    //Error checking}  

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement