Sign in to follow this  

Very Simple Directdraw problem

This topic is 4838 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

I am making a simple two dimensional game with directdraw. It is based on Andre LaMothe's GPDUMB Engine from windows game programming for dummies, perhaps some of you have seen it before. Anyway, when I execute the game I get a runtime error that says: Unhandled exception at 0x004139eb in Test.exe: 0xC0000005: Access violation reading location 0x00000000. I would imagine that this is a complaint that my program is attempting to read memory reserved for windows. Has anyone ever encountered this problem? If anyone knows hwo to fix this I would greatly appreciate it. By the way, the primary and secondary surface, the LPDIRECTDRAWCLIPPER structure, and the primary and secondary buffer are all set to 0x00000000 for some reason. Also, the debugger in Visual Studio .NET referred to each of these as a <bad pointer>. Thanks.

Share this post


Link to post
Share on other sites
Quote:

By the way, the primary and secondary surface, the LPDIRECTDRAWCLIPPER structure, and the primary and secondary buffer are all set to 0x00000000 for some reason.


That will be the problem then :-) Are you calling your init() function (or whatever function creates the directdraw interface and surfaces), before you try to do something with them? And are you checking all your HRESULTS from calling directx functions (making sure they all return S_OK)?

Alan

Share this post


Link to post
Share on other sites
HA! OK, thank you. I added some error handling to it, and my intialization function for directdraw exits with an error. It fails on the SetCooperativeLevel() function. Not to show how green I am but here's what I wrote there. Any ideas?

<code>
lpdd->SetCooperativeLevel(MainWindowHandle, DDSCL_FULLSCREEN
|DDSCL_EXCLUSIVE
|DDSCL_ALLOWREBOOT)
</code>

--Thanx

Share this post


Link to post
Share on other sites
That looks about right, as long as MainWindowHandle is actually the value of your window?

SetCooperativeLevel(..) returns an HRESULT that tells you exactly what went wrong (ie, why it failed). Try catching that and looking up the error code, they are usually pretty informative.

Alan

Share this post


Link to post
Share on other sites
Hey, thanks for your help, all of you! In my window, I forgot to save the window handle after saving the window class data; therefore, my MainWindowHandle was NULL! LOL! D'oh. It's always a silly mistake isn't it? Thanx a lot.

-Ajax

Share this post


Link to post
Share on other sites

This topic is 4838 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this