Having the line glClear( GL_COLOR_BUFFER_BIT ) in my function update_screen, causes the process not to be able to exit! It worked fine, before, but my laptop bricked, i got a new one, and now on this new laptop, on Fedora (Linux) 13, i get this error. Fedora 13 is in alpha stages, so this very well could be an OS problem, especially since the code worked before. But before i was working on Fedora 12, so it also feels unlikely.
The fallowing is my main.cpp with every line that could be deleted is deleted while still producing the problem.
#include "ScopeGuard.h"
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
// FUNCTIONS //
GLenum init_gl( int w, int h )
{
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0, w, h, 0, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
return glGetError();
}
bool make_sdl_gl_window( int w, int h )
{
if( ! SDL_SetVideoMode(w, h, 32, SDL_OPENGL) )
return false;
init_gl( w, h );
return true;
}
void update_screen()
{
glClear( GL_COLOR_BUFFER_BIT );
}
int main()
{
// Portably suppresses unused variable compiler warnings.
#define NOT_USED(var) ((void)(var))
bool quit = false;
SDL_Event event;
if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
return 1;
make_sdl_gl_window( 1200, 800 );
ScopeGuard quitSdl = scope_guard( SDL_Quit ); NOT_USED( quitSdl );
while( quit == false )
{
while( SDL_PollEvent( &event ) )
{
if( event.type == SDL_QUIT )
quit = true;
}
Uint8* keyState = SDL_GetKeyState( 0 );
if( keyState[SDLK_ESCAPE] )
quit = true;
update_screen();
}
}
If you're not familiar with Scope guard, check
this out.
What happens is the window appears. I hit esc (or click the X). The process' status goes to "sleeping". I go into System Monitor and "end process" and the window closes.
Compiler information:
$ g++ -o run -Wall -lGL -lSDL main.cpp
$ g++ -v
Using built-in specs.
Target: i686-redhat-linux
Configured with: ...
Thread model: posix
gcc version 4.4.3 20100409 (Red Hat 4.4.3-16) (GCC)
EDIT: Removed the info in Configured with: since it made the post's width unbearable.