BOOL GDEVICE::CreatePrimarySurface(int iBufferCount)
{
HRESULT hr;
DDSURFACEDESC2 desc;
ZeroMemory(&desc,sizeof(desc));
//desc.dwSize=sizeof(desc);//the line i deleted
desc.dwFlags=DDSD_CAPS;
desc.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE;
if(FullScreen)
{
desc.dwFlags|=DDSD_BACKBUFFERCOUNT;
desc.ddsCaps.dwCaps|=DDSCAPS_COMPLEX | DDSCAPS_FLIP;
desc.dwBackBufferCount=iBufferCount;
}
if(FAILED(hr=lpDD->CreateSurface(&desc,&lpddsPrimary,NULL)))
{
Release();
MessageBox(NULL,"Unable to create primary surface","error",MB_OK);
return FALSE;
}
return TRUE;
}
//And the source for the Release() function
int GDEVICE::Release()
{
if(lpddsBack)
lpddsBack->Release();
if(lpddsPrimary)
lpddsPrimary->Release();
if(lpDD)
lpDD->Release();
lpddsPrimary=lpddsBack=NULL; //make sure they are all NULL
lpDD=NULL;
return 0;
}
🔒 Locked
Release() problem
Advertisement
Original Post
Hi all,
i have a curious problem. Well, after i release every Dx stuffs,things are not really released untill i PostQuiMessage(0), i don't konw why.
This is the part of code involved. I delete a line to make an error and then call a MessageBox(), but that MessageBox appears in the BLACK SCREEN.
Hope i could find some help here
[edited by - remi on July 31, 2002 3:08:07 PM]
Since the backbuffer is an attached surface I am not sure if it has to be released separately.
Im Anfang war die Tat...
Faust
Im Anfang war die Tat...
Faust
quote:
Since the backbuffer is an attached surface I am not sure if it has to be released separately.
You must release() backbuffer even if it is an attached surface or seperate surface
Remi,Is this your mean: After you close you program by Alt+F4 you see MessageBox() instead of MessgeBox() appear before you close you program.
quote:
Since the backbuffer is an attached surface I am not sure if it has to be released separately.
You must release() backbuffer even if it is an attached surface or seperate surface
Remi,Is this your mean: After you close you program by Alt+F4 you see MessageBox() instead of MessgeBox() appear before you close you program (I bet I met this fact many times when programming). For me, the reason come from the parameter "NULL" in this line of code:
quote:
MessageBox(NULL,"Unable to create primary surface","error",MB_OK);
I am not sure but may be NULL means this MessageBox() will appear in another place instead of in DX surface.
quote:
Since the backbuffer is an attached surface I am not sure if it has to be released separately.
You must release() backbuffer even if it is an attached surface or seperate surface
Remi,Is this your mean: After you close you program by Alt+F4 you see MessageBox() instead of MessgeBox() appear before you close you program (I bet I met this fact many times when programming). For me, the reason come from the parameter "NULL" in this line of code:
quote:
MessageBox(NULL,"Unable to create primary surface","error",MB_OK);
I am not sure but may be NULL means this MessageBox() will appear in another place instead of in DX surface.
PS: Just my opinion
Oh, sorry for duplicate. Just because my bad manipulantion
MessageBox(NULL, ...); The NULL means its not attached to a specific window. If it is attached to a HWND you cannot (in my experience as opposed to what is in my win32 bible) focus on the window who the message box belongs to until the message box is dealt with.
I had a similar problem to what the original poster is having. When I have a fullscreen device and I want to return to my dialog after the game has completed, it simply wont do it. It will keep the aspect ratio of the surface and return to windows like that until I close the program. I thought it might involve DestroyWindow() and it might end the aspect ration. I haven''t tried it yet.
If you DestroyWindow(); CreateWindow(); right next to each other, tell me if it works.
I had a similar problem to what the original poster is having. When I have a fullscreen device and I want to return to my dialog after the game has completed, it simply wont do it. It will keep the aspect ratio of the surface and return to windows like that until I close the program. I thought it might involve DestroyWindow() and it might end the aspect ration. I haven''t tried it yet.
If you DestroyWindow(); CreateWindow(); right next to each other, tell me if it works.
You don''t have to release the attached backbuffer separately if you''re using ddraw.h. Only with ddarwex.h, you need to release the attached surfaces, too.
Those who do not love don''t live.
[MSDN|Google|Bloodshed|My lousy page|email.me]
Those who do not love don''t live.
[MSDN|Google|Bloodshed|My lousy page|email.me]
For the changed resolution, you could get the old one and reset to this one. Or you can do a call to ChangeDisplaySettings(0,0), which resets the resolution to the one saved in the registry (=standard resolution of the user). But the screen will still be black...
Those who do not love don''t live.
[MSDN|Google|Bloodshed|My lousy page|email.me]
Those who do not love don''t live.
[MSDN|Google|Bloodshed|My lousy page|email.me]
Tran Minh you can delete a double-posted reply, u just need to click "edit",then delete the reply and everything might be fine
....
Well, while the creation of the lpddsSurface failed, i call the Release() function that is supposed to Release all the Dx stuffs and then i call the MessageBox() function. So What i was expecting it that the BLACK_SCREEN disappears before the messagebox appears, but it''s not what happened. I even Sleep() the program between Release() and MessageBox but "NADA".
As flangazor said, if we first Destroy the Window and recreate it then things should work, it might work like that and it works cause i tried it
But what does all these mean, release() the Dx stuffs doesn''t work untill we destroy our window? if it''s the case then i doubt i know what IDIRECTDRAW::Release() really does.
Well, while the creation of the lpddsSurface failed, i call the Release() function that is supposed to Release all the Dx stuffs and then i call the MessageBox() function. So What i was expecting it that the BLACK_SCREEN disappears before the messagebox appears, but it''s not what happened. I even Sleep() the program between Release() and MessageBox but "NADA".
As flangazor said, if we first Destroy the Window and recreate it then things should work, it might work like that and it works cause i tried it
But what does all these mean, release() the Dx stuffs doesn''t work untill we destroy our window? if it''s the case then i doubt i know what IDIRECTDRAW::Release() really does.
BTW, I have a trouble with Visual C++ 6.0. It torment me nowsdays. So hope you can help me to sleep delicious from tomorrow
I open VC++ 6. Type my Win32 Application. Press Ctrl + F7 to compiler. After that Fress F5 to run. The first time the App run perfectly. And I press Alt+F4 to Close my App and then: Compiler my program again
ress Ctrl + F7 to compiler. After that Fress F5 to run. This time I get this error message:
..\Debug\mypro.exe: Can not open myro.exe for writing.
When I enter Debug folder to delete mypro.exe and then an error message come: Access denied. And then I Open Task Manager and see: my program "mypro" is still running!. It means that: my Program did not close correctly. Infact I don''t know how to fix it because most of my program written in VC++ 6 has the same scenario.
Hope you can help.
Thanks
PS: So each time I want to recompiler my program i must enter Task Manager to close my program by End Task. It is so terrible
I open VC++ 6. Type my Win32 Application. Press Ctrl + F7 to compiler. After that Fress F5 to run. The first time the App run perfectly. And I press Alt+F4 to Close my App and then: Compiler my program again
..\Debug\mypro.exe: Can not open myro.exe for writing.
When I enter Debug folder to delete mypro.exe and then an error message come: Access denied. And then I Open Task Manager and see: my program "mypro" is still running!. It means that: my Program did not close correctly. Infact I don''t know how to fix it because most of my program written in VC++ 6 has the same scenario.
Hope you can help.
Thanks
PS: So each time I want to recompiler my program i must enter Task Manager to close my program by End Task. It is so terrible
Hi Tran Minh Quang,
u''r right when u say that ur program was not closed properly. Many guys have the same problem( Me too in the past). I hope u''r making the same mistake like me
cause i have the solution!!!
In ur Main program loop, the second parameter of PeekMessage() fucntion must be set to NULL. Someone told me the reason but i can''t remember
Try and see if it works!
u''r right when u say that ur program was not closed properly. Many guys have the same problem( Me too in the past). I hope u''r making the same mistake like me
In ur Main program loop, the second parameter of PeekMessage() fucntion must be set to NULL. Someone told me the reason but i can''t remember
Try and see if it works!
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement