It seems that the freopen method works but you have to call the IMG_Load function at least once...
A working example
#include <iostream>#include <SDL/SDL.h>#include <SDL/SDL_opengl.h>#include <SDL/SDL_image.h>using namespace std; SDL_Surface *screen; int init_sdl(){ freopen( "CON", "w", stdout ); SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);int videoflags= SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_OPENGL|SDL_ASYNCBLIT; screen = SDL_SetVideoMode(300, 300 , 32, videoflags); glViewport( 0, 0,300, 300 );};int main_loop(){ SDL_Event event; Uint8 *keystate; int done=0; while(!done) { cout<<"1"<<endl; glClearColor (0.7f, 0.9f, 0.9f, 1.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SDL_GL_SwapBuffers( ); keystate = SDL_GetKeyState(NULL); if ( keystate[SDLK_ESCAPE] ) {done=1;} while ( SDL_PollEvent(&event) ) { if ( event.type == SDL_QUIT ) { done = 1; } } //while } //while return 0;}int dummy(){ SDL_Surface *img = IMG_Load("ab.bmp");}; int main(int argc, char *argv[]){ init_sdl(); main_loop(); return 0;}
compiled as a 'win32 console' application
linker parameters
-lmingw32
-lopengl32
-lSDLmain
-lSDL
-lSDL_Image
-s
note that the dummy() function is not called.
Can anyone confirm that it works ?