Jump to content
  • Advertisement


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


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

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

If you intended to correct an error in the post then please contact us.

Recommended Posts


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 this post

Link to post
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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!