//----------------------------------------------------------------------------- // name: init() // desc: ... //----------------------------------------------------------------------------- t_CKBOOL AudicleWindow::init( t_CKUINT w, t_CKUINT h, t_CKINT xpos, t_CKINT ypos, const char * name, t_CKBOOL fullscreen ) { if( m_windowID ) return TRUE; // log BB_log( BB_LOG_SYSTEM, "initializing windowing system..." ); // push log BB_pushlog(); // log BB_log( BB_LOG_SYSTEM, "setting window size: %d x %d...", w, h ); BB_log( BB_LOG_SYSTEM, "setting window position: %d, %d...", xpos, ypos ); // set modes glutInitDisplayMode( GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL ); glutInitWindowSize( w, h ); glutInitWindowPosition( xpos, ypos ); m_windowID = glutCreateWindow( name ); // set callback functions glutDisplayFunc ( g_main_draw ); glutReshapeFunc ( g_main_reshape ); glutKeyboardFunc( g_main_keyboard ); glutSpecialFunc ( g_main_special_keys ); glutMouseFunc ( g_main_mouse ); glutMotionFunc ( g_main_depressed_motion ); glutPassiveMotionFunc ( g_main_motion ); glutVisibilityFunc ( NULL ); glutIdleFunc( g_main_idle ); // log BB_log( BB_LOG_SYSTEM, "fullscreen mode: %s", fullscreen ? "ON" : "OFF" ); main()->our_fullscreen = fullscreen; if( fullscreen ) glutFullScreen( ); #if (GLUT_MACOSX_IMPLEMENTATION >= 2 ) glutWMCloseFunc ( g_main_die ); #endif // glEnable( GL_POINT_SMOOTH ); // glEnable( GL_LINE_SMOOTH ); // glEnable( GL_BLEND ); // glColorMask( true, true, true, true ); // glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); // glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glPolygonOffset( 1.0, 1.0 ); glLineWidth( 1 ); // glEnable( GL_POLYGON_SMOOTH ); glEnable( GL_DEPTH_TEST ); // glEnable( GL_NORMALIZE ); // glClearDepth( 1900 ); // glClearColor( 1.0, 1.0, 1.0, 0.f ); // glClearStencil( 0 ); glSelectBuffer( AG_PICK_BUFFER_SIZE, m_pick_buffer ); glViewport( 0, 0, w, h ); glGetIntegerv( GL_VIEWPORT, m_cur_vp ); m_hsize = 1.00; m_vsize = 1.33; glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); //perspective? glOrtho( -m_hsize, m_hsize, -m_vsize, m_vsize, -10, 10 ); setupFonts(); //this is silly as all hell #if defined(WIN32) ShowCursor( TRUE ); #endif // m_console = new ConsoleWindow(); // pop log BB_poplog(); return ( m_windowID != 0 ); }
static void registerCallbacks () { glutIdleFunc(gst_glut_IdleFunc); glutKeyboardFunc(gst_glut_KeyboardFunc); glutSpecialFunc(gst_glut_SpecialFunc); glutReshapeFunc(gst_glut_ReshapeFunc); glutVisibilityFunc(gst_glut_VisibilityFunc); glutDisplayFunc(gst_glut_DisplayFunc); glutMouseFunc(gst_glut_MouseFunc); glutMotionFunc(gst_glut_MotionFunc); glutPassiveMotionFunc(gst_glut_PassiveMotionFunc); glutEntryFunc(gst_glut_EntryFunc); glutKeyboardUpFunc(gst_glut_KeyboardUpFunc); glutSpecialUpFunc(gst_glut_SpecialUpFunc); glutMenuStateFunc(gst_glut_MenuStateFunc); glutMenuStatusFunc(gst_glut_MenuStatusFunc); glutOverlayDisplayFunc(gst_glut_OverlayDisplayFunc); glutWindowStatusFunc(gst_glut_WindowStatusFunc); glutSpaceballMotionFunc(gst_glut_SpaceballMotionFunc); glutSpaceballRotateFunc(gst_glut_SpaceballRotateFunc); glutSpaceballButtonFunc(gst_glut_SpaceballButtonFunc); glutButtonBoxFunc(gst_glut_ButtonBoxFunc); glutDialsFunc(gst_glut_DialsFunc); glutTabletMotionFunc(gst_glut_TabletMotionFunc); glutTabletButtonFunc(gst_glut_TabletButtonFunc); glutWMCloseFunc(gst_glut_WMCloseFunc); #if 0 glutJoystickFunc(gst_glut_JoystickFunc); glutMouseWheelFunc(gst_glut_MouseWheelFunc); glutCloseFunc(gst_glut_CloseFunc); glutMenuDestroyFunc(gst_glut_MenuDestroyFunc); #endif }
AppCtx* initApp() { AppCtx *appCtx= 0; appCtx= (AppCtx*)calloc( 1, sizeof(AppCtx) ); if ( appCtx ) { #if defined (WESTEROS_PLATFORM_EMBEDDED) appCtx->inputCtx= (InputCtx*)calloc( 1, sizeof(InputCtx) ); if ( !appCtx->inputCtx ) { free( appCtx ); appCtx= 0; goto exit; } appCtx->inputCtx->started= false; appCtx->inputCtx->stopRequested= false; #else int argc= 0; char **argv= 0; glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA ); glutInitWindowPosition(0,0); glutInitWindowSize(1280, 720); sprintf( appCtx->title, "Westeros-%d", getpid() ); appCtx->glutWindowId= glutCreateWindow(appCtx->title); g_appCtxMap.insert( std::pair<int,AppCtx*>( appCtx->glutWindowId, appCtx ) ); glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT); glewInit(); glutWMCloseFunc( onGlutClose ); glutDisplayFunc( onGlutDisplay ); glutReshapeFunc( onGlutReshape ); glutMotionFunc( onGlutMotion ); glutPassiveMotionFunc( onGlutMotion ); glutMouseFunc(onGlutMouse); glutKeyboardFunc( onGlutKeyboard ); glutSpecialFunc( onGlutSpecial ); glClearColor( 0, 0, 0, 1 ); appCtx->nativeWindow= getNativeWindow( appCtx ); printf("nativeWindow= %p\n", appCtx->nativeWindow ); #endif } exit: return appCtx; }
void Window::createWindow(int width, int height, std::string title) { int argc = 1; char a = '1'; char* argv[] = {&a}; glutInit(&argc, argv); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH ); glutInitWindowPosition( 0, 0 ); glutInitWindowSize(width, height); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutCreateWindow( title.c_str() ); glutWMCloseFunc( onClosing ); }
Game::Game() : univers(), simulator(&univers) { glClearColor(BACKGROUND_COLOR); #ifdef FULLSCREEN glutFullScreen(); #endif setSimulator(&simulator); setUnivers(&univers); Vvector pos(0, 0, 0); Vvector addx(10, 0, 0); Vvector addy(0, 10, 0); for (int i = 0; i < 48; i++) { for (int j = 0; j < 48; j++) { this->univers.addPlanet("Torus", pos); pos += addx; } pos = Vvector(0, pos.y() + addy.y(), pos.z()); } { glutIgnoreKeyRepeat(GLUT_KEY_REPEAT_DEFAULT); glutTimerFunc(KEY_REPEAT_PERIOD, keyboard, 0); } { glutReshapeFunc(windowResizingHandler); glutWindowStatusFunc(windowStatusHandler); #ifdef __APPLE__ glutWMCloseFunc(windowClosingHandler); #endif glutDisplayFunc(displayHandler); } }
int main(int argc,char* argv[]) { // //SET UP GRID HERE!!!! // MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&size); MPI_Comm_rank(MPI_COMM_WORLD,&rank); if(rank == 0) { int i, j; for(i = 0; i < maxW/10; ++i) for(j = 0; j< maxH/10; ++j) { grid[i][j] = rand() % 2; } grid[3][5] = 1; grid[4][6] = 1; grid[5][5] = 1; grid[5][4] = 1; grid[5][6] = 1; glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); // single buffering // glutInitWindowSize(400,300); glutInitWindowPosition(100,50); glutCreateWindow("Jake Shankman's Game of Life"); // glClearColor(1.0,1.0,1.0,0.0); // red, green, blue, alpha glShadeModel(GL_SMOOTH); // glViewport(0,0,(GLsizei)400,(GLsizei)300); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,400.0,0.0,300.0); glMatrixMode(GL_MODELVIEW); glutDisplayFunc(displayfunc); // register callback function //CALL IDLE FUNCTION!!!!! glutIdleFunc(idlefunc); // glutMouseFunc(mousefunc); glutMotionFunc(motionfunc); glutReshapeFunc(reshapefunc); glutWMCloseFunc(closefunc); // // glutMainLoop(); } else { int i, j, a; while(1) { MPI_Recv(&i,1,MPI_INT,0,tag,MPI_COMM_WORLD,&status); if(i == -1) { break; } MPI_Recv(&j,1,MPI_INT,0,tag,MPI_COMM_WORLD,&status); MPI_Recv(grid,(maxW/10)*(maxH/10),MPI_INT,0,tag,MPI_COMM_WORLD,&status); a = alive(i, j); MPI_Send(&a,1,MPI_INT,0,tag,MPI_COMM_WORLD); } } MPI_Finalize(); // return 0; }
static void make_new_window(int mode) { if ( (mode != MODE_WINDOW) && (mode != MODE_FULLSCREEN) ) { // nothing to be done here return; } if (glut_is_initialized && glut_is_freeglut) { if (!FREEGLUT_IS_INITIALIZED) { glut_is_initialized = false; fg_window_is_fullscreen = false; fg_window_state = 0; } } if (!glut_is_initialized) { boinc_glut_init(); } if (debug) fprintf(stderr, "make_new_window(): now calling glutCreateWindow(%s)...\n", aid.app_name); char window_title[256]; get_window_title(aid, window_title, 256); // just show the window if its hidden // if it used to be fullscreen (before // it was hidden, reset size and position // to defaults // bool have_window = false; if (glut_is_freeglut && GLUT_HAVE_WINDOW) { have_window = true; glutShowWindow(); if (fg_window_is_fullscreen) { glutPositionWindow(xpos, ypos); glutReshapeWindow(600, 400); fg_window_is_fullscreen = false; } fg_window_state = MODE_WINDOW; } #ifdef __APPLE__ if (win) have_window = true; #endif if (!have_window) { win = glutCreateWindow(window_title); if (debug) fprintf(stderr, "glutCreateWindow() succeeded. win = %d\n", win); glutReshapeFunc(app_graphics_resize); glutKeyboardFunc(keyboardD); glutKeyboardUpFunc(keyboardU); glutMouseFunc(mouse_click); glutMotionFunc(mouse_click_move); glutDisplayFunc(maybe_render); glEnable(GL_DEPTH_TEST); app_graphics_init(); } #ifdef __APPLE__ glutWMCloseFunc(CloseWindow); // Enable the window's close box BringAppToFront(); // Show window only after a successful call to throttled_app_render(); // this avoids momentary display of old image when screensaver restarts // which made image appear to "jump." need_show = true; #endif if (mode == MODE_FULLSCREEN) { glutFullScreen(); } return; }