Skip to main content
gamedev.net
🔒 Locked

Creating an empty surface

Started by SikCiv 6 replies 950+ views
Original Post
SikCiv
SikCiv
When I create a DD7 Surface using the below code, and blit to/from it, my app crashes, therefore im unable to diagnose the problem by the error return code. // ----------- MY CODE: ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; if(bSysMem) ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; else ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN |DDSCAPS_VIDEOMEMORY; ddsd.dwWidth = bm.bmWidth; ddsd.dwHeight = bm.bmHeight; if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK) return NULL; //------------------------- My objective is to create a surface, then blit from another larger surface to fill the bitmap. What am i doing wrong? Do i have to pre-fill the surface with something, or fill it with black??? or do i HAVE TO load a bitmap to it?
  Downloads:  ZeroOne Realm
Ironblayde
Ironblayde
You don''t have to fill a surface with anything when you create it, but I can''t see any problem with what you''re doing here. If it was something as simple as providing the wrong variable names for arguments, you would have gotten compiler errors... hmm... Does your app crash when you create the surface, or when you try to blit to it?

-Ironblayde
 Aeon Software
"Your superior intellect is no match for our puny weapons!"
MarkO
MarkO
I seem to get the same problem...or similiar problem..my app crashes whenever i try to blit to it..no error codes...i narrowed the problem down a bit last night i think but i havent been able to get a simple ddraw7 surface to work..my ddraw4 surface works just fine though
grasshopa55
grasshopa55
From what I can see, it looks good to me too. I might suggest, to narrow down the problem, comment out the code, line by line, and after each succesful run, uncomment the next line. This way, you know exactly what line is causing the crash.

I ran into a similar problem, but it had to do with the size of the bitmap I was blitting to the surface. It was bigger than the secondary buffer, and I was trying to blit the entire bitmap instead of just the section that was the same size as the secondary buffer. Just a suggestion.



Check out my latest project, Pimp Fighter. http://www.mayday-anime.com/grasshopa
-----------------------------kevin@mayday-anime.comhttp://www.mayday-anime.com
RWarden
RWarden
You guys know how to use a debugger, right?
Set a breakpoint at the top of the code, then step through the code line by line to see where it crashes. Most likely you''ll find that it is referencing a NULL pointer, or something like that.

-RWarden (roberte@maui.net)
SkyDruid
SkyDruid
Of course, if you''re running in fullscreen mode, the debugger is severely crippled. I''m reduced to using "run-to-cursor", watching to see if the program crashes or hangs, End Task-ing the program, stopping the debugger, and "run-to-cursor" the next line. If there''s a better way (other than LaMothe''s two-monitor mode), I''d sure like to hear it.
zenic
zenic
SkyDruid: If you are using Visual C++, i have found that you can debug it in fullscreen if you make sure that the window is NOT WS_EX_TOPMOST. the breakpoint is reached, and then you have to hit Alt-Tab a few times and wait about 3 seconds and DevStudio will popup. from there you just step through the code, as normal.
just be careful not to lock the surface, because that will cause a crash...

SikCiv: I had a blitting crash problem a while ago, and it turned out that i had requested an hDC for the surface and forgotton to release it. Also make sure you free up the surface if you have locked it before blitting.
+AA_970+
+AA_970+
Make sure the rectangle that you use when you blit from the larger surface to the smaller surface is not larger than the size of the smaller surface.

+AA_970+

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.