problems creating a cube

Started by
12 comments, last by jmoyers 16 years, 11 months ago
Quote:Original post by corntown
now Im getting a big black square in the middle of the screen(why is it black ?)
It's been a while since I used FF, but try SetRenderState( D3DRS_LIGHTING, FALSE ) in your initialization code. Might be passing your geometry through the lighting engine, not finding any normals (or lights!) and thus outputting 0/black.

You could verify this with SetRenderState( D3DRS_AMBIENT, D3DCOLOR_XRGB( 255, 0, 0 ) ) - if your cube turns red as a result then its the lighting engine thats getting in your way.

btw, you are aware you're creating a reference rasterizer device?! I'm pretty sure ALL hardware from the last 5 years will be capable of executing your code in hardware [smile]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Advertisement
Quote:Original post by jollyjeffers
Quote:Original post by corntown
now Im getting a big black square in the middle of the screen(why is it black ?)
It's been a while since I used FF, but try SetRenderState( D3DRS_LIGHTING, FALSE ) in your initialization code. Might be passing your geometry through the lighting engine, not finding any normals (or lights!) and thus outputting 0/black.

You could verify this with SetRenderState( D3DRS_AMBIENT, D3DCOLOR_XRGB( 255, 0, 0 ) ) - if your cube turns red as a result then its the lighting engine thats getting in your way.

btw, you are aware you're creating a reference rasterizer device?! I'm pretty sure ALL hardware from the last 5 years will be capable of executing your code in hardware [smile]

hth
Jack


it doesn't recgonize SetRenderState

Quote:Original post by corntown
it doesn't recgonize SetRenderState
Had you looked up SetRenderState() in the DX documentation, you'd see that it's a member of IDirect3DDevice9.

Jack is probably correct about disabling lighting - you don't have a material set, and the default material is all black, which could explain what you're seeing. You're also not clearing your backbuffer at all (Look into IDirect3DDevice9::Clear()). You'll want to clear your backbuffer to a non-black colour for debugging, and you'll definitely want to clear your Z-buffer (Which is also going to cause this problem) each frame.
Render states are set through the D3D Device pointer. Looking at your code, its something like:

pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );


Where D3DRS = D3D Render State.. Lighting referring to the built in lighting engine... which doesn't do you any good unless you have fixed function lights set. So thats why you set it to false.

It sounds like whatever PDF book you are using is not explaining things very well (or you're skipping ahead). I'd recommend some of these step by step tutorials you find all over the web for FFP (Fixed Function Pipeline).

Another good resource for Dx functions and how to use them, is MSDN... so for instance, if you couldn't figure out SetRenderState, you might go to: MSDN Dx9.0c C++ Docs

You might have seen: IDirect3DDevice9::SetRenderState Method - and thought, "Oh, maybe its set through a member function of the device object."

This topic is closed to new replies.

Advertisement