int main ( int argc, char *argv[] ) { GLboolean retval; ESContext esContext; //UserData userData; void *userData; esInitContext ( &esContext ); staticContext = &esContext; userData = fwl_init_instance(); //before setting any structs we need a struct allocated esContext.userData = userData;//&userData; //Blackberry PlayBook 1024x600 (7") 170 PPI //equivalent 7" on Acer x203w desktop monitor: 600x352 retval = esCreateWindow ( &esContext, "winGLES2", 600, 352, ES_WINDOW_RGB | ES_WINDOW_DEPTH | ES_WINDOW_STENCIL ); //retval = esCreateWindow ( &esContext, "winGLES2", 1024, 600, ES_WINDOW_RGB | ES_WINDOW_DEPTH | ES_WINDOW_STENCIL ); fwl_setOrientation (0); //int: 0, 90, 180, 270 setDisplayed(1); //0=not 1=displayed if( retval == GL_FALSE ) printf("ouch - esCreateWindow returns false\n"); printf("%s\n",glGetString(GL_VERSION)); printf("%s\n",glGetString(GL_SHADING_LANGUAGE_VERSION)); if ( !fwInit ( &esContext ) ) return 0; //statusbarOnResize(600,352); fwl_setScreenDim(600,352); //esRegisterUpdateFunc ( &esContext, fwUpdate ); esRegisterDrawFunc ( &esContext, fwDraw ); esRegisterKeyFunc ( &esContext, fwOnKey ); esRegisterMouseFunc ( &esContext, fwOnMouse ); esRegisterResizeFunc( &esContext, fwOnResize ); esMainLoop ( &esContext ); finalizeRenderSceneUpdateScene(); }
/** * Main */ int main (int argc, char **argv) { const char *libver; const char *progver; #if defined(_ANDROID) int tempIsAndroid = 1 ; #else int tempIsAndroid = 0 ; #endif char consoleBuffer[200]; fwl_init_instance(); //before setting any structs we need a struct allocated fwl_ConsoleSetup(MC_DEF_AQUA , MC_TARGET_AQUA , MC_HAVE_MOTIF , MC_TARGET_MOTIF , MC_MSC_HAVE_VER , tempIsAndroid); /* first, get the FreeWRL shared lib, and verify the version. */ libver = libFreeWRL_get_version(); progver = freewrl_get_version(); if (strcmp(progver, libver)) { sprintf(consoleBuffer ,"FreeWRL expected library version %s, got %s...\n",progver, libver); fwl_StringConsoleMessage(consoleBuffer); } #ifdef _MSC_VER /* Set fonts directory ideally we would check if we are in a) projectfiles go ../../fonts b) else c:/windows/Fonts */ if(strstr(argv[0],"projectfiles")) { /* we are testing - use local fonts (may be obsolete someday) */ static char *fdir; fdir = malloc(MAX_PATH); strcpy(fdir,"FREEWRL_FONTS_DIR="); strcat(fdir,"C:/fonts"); _putenv( fdir ); } else { /* deployed system (with intalled fonts) - use system fonts we plan to use a professional installer to install the fonts to %windir%\Fonts directory where all the system fonts already are. Then in this program we will get the %windir%\Fonts directory, and set it as temporary environment variable for InputFunctions.C > makeFontsDirectory() to fetch. */ static char *fdir; char *syspath; syspath = getenv("windir"); printf("windir path=[%s]\n",syspath); fdir = malloc(MAX_PATH); strcpy(fdir,"FREEWRL_FONTS_DIR="); strcat(fdir,syspath); strcat(fdir,"/Fonts"); _putenv( fdir ); } get_current_dir(); /* VBO preference - comment out for vbos (vertex buffer objects - a rendering optimization) */ _putenv("FREEWRL_NO_VBOS=1"); //_putenv("FREEWRL_USE_VBOS=1"); #endif /* install the signal handlers */ signal(SIGTERM, (void(*)(int)) fv_catch_SIGQUIT); signal(SIGSEGV, (void(*)(int)) fv_catch_SIGSEGV); #if !defined(CYGWIN) signal(SIGQUIT, (void(*)(int)) fv_catch_SIGQUIT); signal(SIGALRM, (void(*)(int)) fv_catch_SIGALRM); signal(SIGHUP, (void(*)(int)) fv_catch_SIGHUP); #endif /* Before we parse the command line, setup the FreeWRL default parameters */ fv_params = calloc(1, sizeof(freewrl_params_t)); /* Default values */ fv_params->width = 600; fv_params->height = 400; fv_params->eai = FALSE; fv_params->fullscreen = FALSE; fv_params->winToEmbedInto = -1; fv_params->verbose = FALSE; // fv_params->collision = 1; // if you set it, you need to update ui button with a call //setMenuButton_collision(fv_params->collision); //fwl_init_StereoDefaults(); /* parse command line arguments */ if (fv_parseCommandLine(argc, argv)) { if(argc > 1) { start_url = argv[optind]; #ifdef _MSC_VER start_url = strBackslash2fore(start_url); #endif } else { start_url = NULL; } } /* doug- redirect stdout to a file - works, useful for sending bug reports */ /*freopen("freopen.txt", "w", stdout ); */ /* Put env parse here, because this gives systems that do not have env vars the chance to do it their own way. */ fv_parseEnvVars(); /* start threads, parse initial scene, etc */ if ( 1 == 1) { /* give control to the library */ if (!fwl_initFreeWRL(fv_params)) { ERROR_MSG("main: aborting during initialization.\n"); exit(1); } fwl_startFreeWRL(start_url); } else { /* keep control if (!fv_initFreeWRL(fv_params)) { ERROR_MSG("main: aborting during initialization.\n"); exit(1); } fv_startFreeWRL(start_url); */ } return 0; }