c++ - Nothing happens when program runs (and no Window is created) -
as of recent, very frustrated sdl2. out of options here, looking knowledgeable. i'm trying darn thing working on windows 8.1. had no problems using first sdl on windows 7 went breeze. however, sdl2 not same case.
i'm following tutorials on "http://lazyfoo.net/tutorials/sdl/01_hello_sdl/windows/codeblocks/index.php" using updated codeblocks + mingw32 release. i've tried on orwell dev c++ + mingw32. however, very odd happening, i've never before seen in programming. compiler not giving me errors. however, when program runs, nothing happens. window should created , delayed few seconds. i've tried part 2 tutorial show image, , again, nothing happens.
i've made sure neither program blocked windows firewall , ran program , .exe administrator.
the compiler gives no errors.
sdl2.dll in folder of .exe.
i've downloaded sdl2.0.3 link on website , downloaded , applied fix 1 wonky .h file gives compiler errors in sdl2.0.3 not sdl2.0.0 downloaded @ https://hg.libsdl.org/sdl/raw-file/e217ed463f25/include/sdl_platform.h
i've added lib , include folder in compiler options sdl2.0.3.
i've added linker string: -lmingw32 -lsdl2main -lsdl2 (also tried -lmingw32 -lsdl2 -lsdl2main , 10 other things found on forums).
i've tried using both debug , release compilers.
i've tried building program gui application , console application. in sdl1, compiled gui application. in sdl2, compiles, when ran, absolutely nothing. when ran console application, console windows pops up, program stops responding, , console shows process exited after 6.357 seconds return value 255.
i've followed instructions using both code::blocks , dev c++ ide , still not getting anything, same results. been working @ , googling 2 days. in god's name happening cause me stress? if have suggestions or have experienced tragedy, please help! t.t
the code basic shown:
//using sdl , standard io #include <sdl.h> #include <stdio.h> //screen dimension constants const int screen_width = 640; const int screen_height = 480; int main( int argc, char* args[] ) { //the window we'll rendering sdl_window* window = null; //the surface contained window sdl_surface* screensurface = null; //initialize sdl if( sdl_init( sdl_init_video ) < 0 ) { printf( "sdl not initialize! sdl_error: %s\n", sdl_geterror() ); } else { //create window window = sdl_createwindow( "sdl tutorial", sdl_windowpos_undefined, sdl_windowpos_undefined, screen_width, screen_height, sdl_window_shown ); if( window == null ) { printf( "window not created! sdl_error: %s\n", sdl_geterror() ); } else { //get window surface screensurface = sdl_getwindowsurface( window ); //fill surface white sdl_fillrect( screensurface, null, sdl_maprgb( screensurface->format, 0xff, 0xff, 0xff ) ); //update surface sdl_updatewindowsurface( window ); //wait 2 seconds sdl_delay( 2000 ); } } //destroy window sdl_destroywindow( window ); //quit sdl subsystems sdl_quit(); return 0; }
this compiler output dev c++:
compiling project changes... -------- - project file: c:\users\giovanni\desktop\test\giogame\giogame.dev - compiler name: mingw gcc 4.8.1 32-bit debug building makefile... -------- - filename: c:\users\giovanni\desktop\test\giogame\makefile.win - output file: c:\users\giovanni\desktop\test\giogame\giogame.exe processing makefile... -------- - makefile processor: c:\program files (x86)\dev-cpp\mingw32\bin\mingw32-make.exe - command: mingw32-make.exe -f "c:\users\giovanni\desktop\test\giogame\makefile.win" g++.exe -c 01_hello_sdl.cpp -o 01_hello_sdl.o -i"c:/program files (x86)/dev-cpp/mingw32/include" -i"c:/program files (x86)/dev-cpp/mingw32/mingw32/include" -i"c:/program files (x86)/dev-cpp/mingw32/lib/gcc/mingw32/4.8.1/include" -i"c:/program files (x86)/dev-cpp/mingw32/lib/gcc/mingw32/4.8.1/include/c++" -i"c:/users/giovanni/desktop/test/sdl2.0.3/include/sdl2" -g3 g++.exe 01_hello_sdl.o -o giogame.exe -l"c:/program files (x86)/dev-cpp/mingw32/lib" -l"c:/program files (x86)/dev-cpp/mingw32/mingw32/lib" -l"c:/users/giovanni/desktop/test/sdl2.0.3/lib" -static-libstdc++ -static-libgcc -lmingw32 -lsdl2main -lsdl2 -g3 compilation results... -------- - errors: 0 - warnings: 0 - output size: 143.41796875 kib - compilation time: 2.86s
finally solved. had feeling, problem windows or windows 8.1 shafting me fun. careful , redownloaded sdl2.0.3 , reapplied patch thing sdl_platform.h. uninstalled of ides tried, reinstalled dev c++ in windows 7 compatibility mode administrator on desktop (ie not in program files x86). then, setup again , bam worked.
could problem windows 8.1 administrator bs shenanigans, or compatibility mode, or corrupt download earlier, or sdl using or fact installed program files x86 has space in file path , limited rights because windows.
so problem: because windows.
the issue never letting windows enter event-loop. tutorial reading assumes window show without ever handling events, not happen on platforms.
just doing sdl_delay( 2000 );
sleep 2 seconds, not let thread handle events in meantime.
if replace 1 line
sdl_event e; bool quit=false; while(!quit) { while( sdl_pollevent( &e ) != 0 ) { if( e.type == sdl_quit ) { quit = true; } } }
it work fine (although it's busy waiting, can care later)
Comments
Post a Comment