i use sdl initialize opengl context:
sdl_init( sdl_init_video ); sdl_surface* screen = sdl_setvideomode( 1600, 1200, 0, sdl_opengl );
and do:
env = new senvironment; env->deploydefaultenvironment( null, "../../commonmedia" );
the engine starts , opens new window.
how can use existing window?
you can use deployenvironment instead of deploydefaultenvironment deployenvironment requires handle current window, , 1 of examples shows how can achieved using glut on windows. can current window handle on sdl using following code
sdl_syswminfo sysinfo; //will hold our window information sdl_version(&sysinfo.version); //set sdl version if(sdl_getwminfo(&sysinfo) <= 0) { printf("%s : %d\n", sdl_geterror(), sysinfo.window); return; //or throw exception or whatever } #ifdef __win32__ hwnd windowhandle = sysinfo.window; //win32 window handle #else window windowhandle = sysinfo.window; //x11 window handle #endif
finally definition of deployenvironment looks this:
deployenvironment (const std::vector< std::string > * commandline, const std::string & logfilename, const std::string & rootdir, const std::string & commonmediadir, const std::string & configfile, const bool openviewport, const bool createrenderer, const bool contexttakeover, void * externalwndhandle);
the command line parameter same deploydefaultenvironment, next 4 params paths, can use constants 'default_engine_log_file', 'default_engine_root_dir', 'default_engine_root_pack', 'default_engine_ini_file'. openviewport should false, should createrenderer, , contexttakeover should true. set externalwndhandle window handle stored in variable declared in code above. note example glut on windows, have no idea whether work on other oses.
Comments
Post a Comment