Hello everybody, I hope this is my last problem...
This 'error' from couple of weeks cannot be solved by me and I can't find some
helpful info on google and here about it.
If I select from project options 'console application', the program starts,
and two windows are shown. Main one with graphics, and the second one - just
common console. If I want to close my app, I click on X in the console window,
and it's working fine. When I choose in project options - win32gui, only one
window is showed (as it should be) with opengl graphics. Then, if I click X,
window is not showed anymore (ok), but I need to reset program manually - left
alt + f2. The program is still in task manager. It becomes a big problem, if I
just start the exe file without dev c++ environment. Every time I need to kill
the program process in task manager. On some another forum I read, it's a
problem with glut version, but guy who solved the problem had 3.7.6 version,
as I have the same one. Using freeglut version 2.6.0, the same problem. Some
time ago I downloaded glut and freeglut manually from opengl website, but it
changed nothing. Till now, the problem remains unsolved. I don't think
something is wrong with the code, coz I tried many combination writing
postquitmessage(0) in one and another cases. Here's fragment of code:
What should I do, to force the program to quit properly, so no its process
remains in task manager after I hit the X button?
Thank you from mountain ;)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm sorry for bothering you guys, found my problem by accident. I searched for
the solution for very long time, and after posting post on this forum, I
suddenly become smarter hehe. For everybody, who can't handle the simmilar
program, here is the solution. You propably use some internet tutorial to
learn opengl, or as I, you prefer books...In many cases I saw something like
this : you've got two functions, winmain and wndProc (for event handling). If
you write some let's say some game, you use simmilar :
The declaration of 'done' is : bool done; in wndProc function ( ! ). The
problem is, even if app is closed, the loop is still running. All you need to
do, is make global declaration of bool done; and in your cases (WM_CLOSE and
WM_DESTROY), add 'bool = true;', so the main loop is forced to end. You can
compare the code, with the above one:
case WM_DESTROY:
{
wglMakeCurrent( hDC, NULL );
wglDeleteContext( hRC );
glDeleteTextures(6, obiekt_tekstury);
hwnd = NULL;
done = true; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PostQuitMessage( 0 );
return 0;
}
break;
After this, my application is closing properly, and its process is killed in
task manager. Thats the solution in my problem case, that made me mad for long
couple of weeks.
Perhaps I missunderstand something by learning ogl from book ( KEVIN HAWKINS,
DAVE ASTLE 'OPENGL GAME PROGRAMMING' ) or so.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everybody, I hope this is my last problem...
This 'error' from couple of weeks cannot be solved by me and I can't find some
helpful info on google and here about it.
If I select from project options 'console application', the program starts,
and two windows are shown. Main one with graphics, and the second one - just
common console. If I want to close my app, I click on X in the console window,
and it's working fine. When I choose in project options - win32gui, only one
window is showed (as it should be) with opengl graphics. Then, if I click X,
window is not showed anymore (ok), but I need to reset program manually - left
alt + f2. The program is still in task manager. It becomes a big problem, if I
just start the exe file without dev c++ environment. Every time I need to kill
the program process in task manager. On some another forum I read, it's a
problem with glut version, but guy who solved the problem had 3.7.6 version,
as I have the same one. Using freeglut version 2.6.0, the same problem. Some
time ago I downloaded glut and freeglut manually from opengl website, but it
changed nothing. Till now, the problem remains unsolved. I don't think
something is wrong with the code, coz I tried many combination writing
postquitmessage(0) in one and another cases. Here's fragment of code:
case WM_CLOSE:
{
wglMakeCurrent( hDC, NULL );
wglDeleteContext( hRC );
DestroyWindow( hwnd );
return 0;
}
break;
case WM_DESTROY:
{
wglMakeCurrent( hDC, NULL );
wglDeleteContext( hRC );
glDeleteTextures(6, obiekt_tekstury);
PostQuitMessage( 0 );
return 0;
}
What should I do, to force the program to quit properly, so no its process
remains in task manager after I hit the X button?
Thank you from mountain ;)
Hmm sorry for bothering you guys, found my problem by accident. I searched for
the solution for very long time, and after posting post on this forum, I
suddenly become smarter hehe. For everybody, who can't handle the simmilar
program, here is the solution. You propably use some internet tutorial to
learn opengl, or as I, you prefer books...In many cases I saw something like
this : you've got two functions, winmain and wndProc (for event handling). If
you write some let's say some game, you use simmilar :
while ( !done )
{
PeekMessage( &msg, hwnd, 0, 0, PM_REMOVE );
if( msg.message == WM_QUIT )
{
done = true; //this case never happens, dunno why, but nvm
}
else
{
DrawScene();
TranslateMessage( &msg );
DispatchMessage ( &msg );
} //else
}
return msg.wParam;
} //WinApi WINMAIN
The declaration of 'done' is : bool done; in wndProc function ( ! ). The
problem is, even if app is closed, the loop is still running. All you need to
do, is make global declaration of bool done; and in your cases (WM_CLOSE and
WM_DESTROY), add 'bool = true;', so the main loop is forced to end. You can
compare the code, with the above one:
//globals
...
bool done;
...
//globals
case WM_CLOSE:
{
wglMakeCurrent( hDC, NULL );
wglDeleteContext( hRC );
done = true; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DestroyWindow( hwnd );
return 0;
}
break;
case WM_DESTROY:
{
wglMakeCurrent( hDC, NULL );
wglDeleteContext( hRC );
glDeleteTextures(6, obiekt_tekstury);
hwnd = NULL;
done = true; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PostQuitMessage( 0 );
return 0;
}
break;
After this, my application is closing properly, and its process is killed in
task manager. Thats the solution in my problem case, that made me mad for long
couple of weeks.
Perhaps I missunderstand something by learning ogl from book ( KEVIN HAWKINS,
DAVE ASTLE 'OPENGL GAME PROGRAMMING' ) or so.