#### Archived

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

# (I think) range error when setting the perspective (windowed mode)

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

## Recommended Posts

	D3DVIEWPORT9 ViewPort;

ZeroMemory(&ViewPort, sizeof(D3DVIEWPORT9));

ViewPort.X	= 0;
ViewPort.Y	= 0;
ViewPort.Width	= 800;
ViewPort.Height	= 600;
ViewPort.MinZ	= 0.0f;
ViewPort.MaxZ	= 1.0f;

if (FAILED(g_lpDevice->SetViewport(&ViewPort)))
return E_FAIL;  
This is my code for setting the viewport. It doesn't give any errors when compiling, but on execution I get to see this: "First-chance exception in app.exe: 0xC0000005: Access Violation." This error occurs in the last line (when setting the viewport) I think the error has something to do with the range I set for the viewport, so I tried getting .X, .Y, .Width and .Height using the getclientrect function etc. etc. but it doesn't help... What could be the error? Thanks in advance for any given help [edited by - Subotron on January 20, 2003 7:16:32 AM]

##### Share on other sites
That code looks fine. If the parameters in your structure are wrong then D3D won''t crash, it''ll return an error code such as D3DERR_INVALIDCALL

I assume this has stopped in the debugger. If so highlight just the "g_lpDevice" (as if you were about to do a cut & paste) and leave the mouse pointer hovering over the highlighted text - what is the value for g_lpDevice, my guess (99% certain) is it''s 0 (0x00000000), i.e. a null pointer. The next guess is an uninitialised pointer (0xCDCDCDCD) or some trashed memory.

If it is a null pointer it hints at the device creation failing, so run your code with the DEBUG D3D runtime and look at the output window to see why.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
you where right the device is 0 tnx a lot... I can fix this I guess