Sturmritter![]() Member Posts: 17 From: San Rafael, CA, USA Registered: 06-13-2002 |
To any and all who might have an answer!!!! I've been trying to get a GDI-based Dialog blitted to an Offscreen DirectDraw (LPDIRECTDRAW7) Plain surface BEFORE it goes to the Primary Surface backbuffer! ShowWindow(DialogWindow, SW_NORMAL); seems to put it in the backbuffer of the primary, so I tried to bypass that by creating the following code: HDC hdcScreen, hdcBuffer; // Here's where ShowWindow(DlgWnd, SW_NORMAL); would normally go The code above compiles fine on MS Visual C++ compiler, but when I run program, my code returns an error that the Surface in question is locked by another thread. Is there a better way to accomplish my goal of blitting the dialog to an offscreen buffer? or can I force the surface to unlock somehow before relocking? Any comments are appreciated. I'm just trying to learn here =) Thanks in advance! - Sturmritter ------------------ quote: |
|
Sturmritter![]() Member Posts: 17 From: San Rafael, CA, USA Registered: 06-13-2002 |
Well, I discovered my problem (Well, at least partially....) I added another LPDIRECTDRAWSURFACE7 pointer called GDIPointer The new code looks like this: Manager->GetInterface(&DD7); While this works to blit the IMAGE of the current Dialog to an offscreen buffer, it does not track any dynamic changes to the Dialog. Therefore it seems a bit impractical for anything but static dialog boxes. HOWEVER, the process does work for any offscreen plain Direct Draw Surface! (Which is a good thing! hehe) Try it and you can blit multiple dialog images about the screen as if they were sprites! hehe. Not particularly useful unless you want to create a dialog as sprite, but it's neat to learn these things. I think I'm going to try another approach to blitting dialogs dynamically to offscreen buffers. I'll post what I learn here when I finish. Hope that helps, and thanks to all who at least looked at my earlier post! God Bless, Sturmritter ------------------ quote: |
|
Briant![]() Member Posts: 742 From: Stony Plain, Alberta, Canada Registered: 01-20-2001 |
Hi, Are you doing this just to learn how DDraw works? Or are you trying to get dialog boxes to appear (and work) overtop of the primary surface? Once you blit, it is no longer a dialog, but just a bitmap on a DX surface. Brian |
|
Sturmritter![]() Member Posts: 17 From: San Rafael, CA, USA Registered: 06-13-2002 |
I did it just to learn some capabilities, and see what could or could not be done. Eventually I do want to be able to draw the actual dialog onto the primary surface without it erasing everything there. (I'm not familiar enough with clipper objects to figure out how to associate it properly. I.e. with the dialog or with the surface.) Additionally I've got an interesting methodology that may hold some promise. Basically I have 3 surfaces I am working with. 1 Primary, and 2 plain. One plain surface is my basic construction site for bitmaps. Another plain surface I use specifically to display FPS and other data to benchmark. My method right now is to take my constructions, blit them to my FPS/data display surface, then blit the combined surfaces to the primary back buffer and then flip the page. How would I construct a clipper for the Dialog if I were to show the dialog window after I flip the primary backbuffer? Thanks in advance! - Sturmritter ------------------ quote: |
|
Sturmritter![]() Member Posts: 17 From: San Rafael, CA, USA Registered: 06-13-2002 |
Btw, Here is my Current RedrawScreen Function: /* Each surface is encapsulated to include Blit routines called by function Surface::BlitTo(*Surface, long SourceX, long SourceY); DD7 is a global LPDIRECTDRAW7 pointer Surface is the Primary Surface and Surface::Show() is function to flip surface buffers and display front. TextTo is a class to bitmap textstrings. Surfacebuffer is a local LPDIRECTDRAWSURFACE7 pointer in case of need to Restore lost surfaces. FPSCounterOn and DialogOn are global booleans which flag if these items ought to be displayed. bool RedrawScreen() LPDIRECTDRAW7 dd7; } Can someone determine where my flaw in logic is? What I get is a quick blit of the dialog to the front buffer before it suddenly disappears. Is this due to the last command being Surface->Show(); ? Again, any solutions or comments are welcome! - Sturmritter ------------------ quote: |
|
Sturmritter![]() Member Posts: 17 From: San Rafael, CA, USA Registered: 06-13-2002 |
Well, I've conquered this problem after all! Eliminating most of the primary surface buffer flipping, I created a clipper to the primary surface and then simplay flip the buffer only if no dialog needs to be displayed. (Aparently ShowWindow is basically a flip which blits the GDI surface to the front primary surface buffer.) Here is my solution to the above RedrawScreen function(): // Create a clipper for the Primary Surface in order to display GDI bool RedrawScreen() LPDIRECTDRAW7 dd7; Thanks for all your help! God Bless, ------------------ quote: |
|
Briant![]() Member Posts: 742 From: Stony Plain, Alberta, Canada Registered: 01-20-2001 |
Hey, You can improve the performace by moving this chunk of code:
Move it outside of the RedrawScreen function, because you should only need to do these steps once. Brian |
|
Sturmritter![]() Member Posts: 17 From: San Rafael, CA, USA Registered: 06-13-2002 |
Thanks Brian! I'll try that as well.
Do you happen to know any clean methods of dynamically changing the screen display modes and restoring the surfaces? Now that I have my dialog working, I've made it into a combo-list box which allows me to select display modes. When I activate it, however, I get the screen mode change, but when I attempt to restore my surfaces, I crash to the desktop. Any ideas on how to solve this? I've tried resetting the clipper for the primary surface and resetting the general display modes of my offscreen surfaces with no success. Do I need to create whole new surfaces at the new resolutions and then blit the information to them? or is their any easier and more time-efficient method? Thanks in advance! - Sturmritter ------------------ quote: |