///////////////////////////////////////////////////////// // createMess // ///////////////////////////////////////////////////////// bool gemsdlwindow :: create(void) { if(m_surface) { error("window already made!"); return false; } if ( SDL_InitSubSystem( SDL_INIT_VIDEO ) < 0 ) { error("could not (re)initialize SDL window infrastructure"); return false; } /* Fetch the video info */ const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo( ); m_videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */ if(2==m_buffer) { m_videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */ /* Sets up OpenGL double buffering */ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); } else { /* Sets up OpenGL double buffering */ SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 0 ); } m_videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */ m_videoFlags |= SDL_RESIZABLE; /* Enable window resizing */ if(videoInfo) { /* This checks to see if surfaces can be stored in memory */ if ( videoInfo->hw_available ) m_videoFlags |= SDL_HWSURFACE; else m_videoFlags |= SDL_SWSURFACE; /* This checks if hardware blits can be done */ if ( videoInfo->blit_hw ) m_videoFlags |= SDL_HWACCEL; } /* get a SDL surface */ m_surface = SDL_SetVideoMode( m_width, m_height, m_bpp, m_videoFlags ); if(!m_surface) return false; if(!createGemWindow()) { destroyMess(); return false; } titleMess(m_title); fullscreenMess(m_fullscreen); dispatch(); return true; }
///////////////////////////////////////////////////////// // Destructor // ///////////////////////////////////////////////////////// gemglfw2window :: ~gemglfw2window() { s_instances--; destroyMess(); if(s_instances==0) { glfwTerminate(); } }
//////////////////////////////////////////////////////// // Destructor // ///////////////////////////////////////////////////////// gemglxwindow :: ~gemglxwindow() { if(m_pimpl->win) { destroyMess(); } delete m_pimpl; }
///////////////////////////////////////////////////////// // Destructor // ///////////////////////////////////////////////////////// gemsdlwindow :: ~gemsdlwindow() { destroyMess(); sdl_count--; if(!sdl_count) { SDL_Quit(); // ???? } }
void gemw32window:: createMess(std::string s) { if(m_win) { error("window already made"); return; } if(!create()) { destroyMess(); return; } topmostMess(m_topmost); }
///////////////////////////////////////////////////////// // createMess // ///////////////////////////////////////////////////////// bool gemglfw2window :: create(void) { int mode = GLFW_WINDOW; if(0!=s_window) { error("window already made!"); return false; } if(m_fullscreen) mode=GLFW_FULLSCREEN; glfwOpenWindowHint(GLFW_FSAA_SAMPLES, m_fsaa); if(m_profile_major) { glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, m_profile_major); // We want OpenGL 3.3 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, m_profile_minor); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL } if (!glfwOpenWindow(m_width, m_height, 8, 8, 8, 8, /* RGBA bits */ 24, 8, /* depth/stencil bits */ mode)) { error("glfw couldn't create window"); return false; } // FIXXME: single/double buffering if(!createGemWindow()) { destroyMess(); return false; } s_window=this; titleMess(m_title); offsetMess(m_xoffset, m_yoffset); cursorMess(m_cursor); glfwSetWindowSizeCallback (windowsizeCb); glfwSetWindowCloseCallback (windowcloseCb); glfwSetWindowRefreshCallback(windowrefreshCb); glfwSetKeyCallback (keyCb); glfwSetCharCallback (charCb); glfwSetMouseButtonCallback (mousebuttonCb); glfwSetMousePosCallback (mouseposCb); glfwSetMouseWheelCallback (mousewheelCb); dispatch(); return (0!=s_window); }
void gemglxwindow :: createMess(const std::string&display) { if(m_pimpl->win) { error("window already made"); return; } m_display=display; if(!create()) { destroyMess(); return; } dimension(m_width, m_height); m_pimpl->doDispatch=true; }
///////////////////////////////////////////////////////// // Destructor // ///////////////////////////////////////////////////////// gemglutwindow :: ~gemglutwindow() { destroyMess(); }
///////////////////////////////////////////////////////// // createMess // ///////////////////////////////////////////////////////// bool gemglutwindow :: create(void) { if(m_window) { error("window already made!"); return false; } #ifdef FREEGLUT // display list sharing (with FreeGLUT) if(s_windowmap.size()>0) { std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin(); gemglutwindow*other=NULL; other=it->second; if(other && other->makeCurrent()) { glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT ); } } #endif unsigned int mode=GLUT_RGB | GLUT_DEPTH; if(2==m_buffer) mode|=GLUT_DOUBLE; else mode|=GLUT_SINGLE; glutInitDisplayMode(mode); m_window=glutCreateWindow(m_title.c_str()); s_windowmap[m_window]=this; glutDisplayFunc (&gemglutwindow::displayCb); glutVisibilityFunc(&gemglutwindow::visibleCb); glutCloseFunc (&gemglutwindow::closeCb); #ifdef FREEGLUT glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif glutKeyboardFunc(&gemglutwindow::keyboardCb); glutSpecialFunc(&gemglutwindow::specialCb); glutReshapeFunc(&gemglutwindow::reshapeCb); glutMouseFunc(&gemglutwindow::mouseCb); glutMotionFunc(&gemglutwindow::motionCb); glutPassiveMotionFunc(&gemglutwindow::passivemotionCb); glutEntryFunc(&gemglutwindow::entryCb); glutKeyboardUpFunc(&gemglutwindow::keyboardupCb); glutSpecialUpFunc(&gemglutwindow::specialupCb); glutJoystickFunc(&gemglutwindow::joystickCb, 20); glutMenuStateFunc(&gemglutwindow::menustateCb); glutMenuStatusFunc(&gemglutwindow::menustatusCb); glutWindowStatusFunc(&gemglutwindow::windowstatusCb); // glutNameFunc(&gemglutwindow::nameCb); if(!createGemWindow()) { destroyMess(); return false; } titleMess(m_title); fullscreenMess(m_fullscreen); dispatch(); return true; }
///////////////////////////////////////////////////////// // createMess // ///////////////////////////////////////////////////////// bool gemglutwindow :: create(void) { if(m_window) { error("window already made!"); return false; } #ifdef FREEGLUT // display list sharing (with FreeGLUT) if(s_windowmap.size()>0) { std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin(); gemglutwindow*other=NULL; other=it->second; if(other && other->makeCurrent()) { glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT ); } } #endif unsigned int mode=GLUT_RGB | GLUT_DEPTH; if(2==m_buffer) mode|=GLUT_DOUBLE; else mode|=GLUT_SINGLE; glutInitDisplayMode(mode); #ifdef FREEGLUT // glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutSetOption(GLUT_INIT_WINDOW_X, m_xoffset); glutSetOption(GLUT_INIT_WINDOW_Y, m_yoffset); glutSetOption(GLUT_INIT_WINDOW_WIDTH, m_width); glutSetOption(GLUT_INIT_WINDOW_HEIGHT, m_height); #endif m_window=glutCreateWindow(m_title.c_str()); s_windowmap[m_window]=this; glutReshapeWindow(m_width, m_height); glutPositionWindow(m_xoffset, m_yoffset); glutCloseFunc (&closeCb); glutKeyboardFunc(&keyboardCb); glutSpecialFunc(&specialCb); glutReshapeFunc(&reshapeCb); glutKeyboardUpFunc(&keyboardupCb); glutSpecialUpFunc(&specialupCb); glutJoystickFunc(&joystickCb, 20); glutMenuStateFunc(&menustateCb); glutMenuStatusFunc(&menustatusCb); glutWindowStatusFunc(&windowstatusCb); #if (defined GLUT_HAS_MULTI) && (GLUT_HAS_MULTI > 0) glutMultiEntryFunc(multiEntryCb); glutMultiButtonFunc(multiButtonCb); glutMultiMotionFunc(multiMotionCb); glutMultiPassiveFunc(multiPassivemotionCb); #else glutEntryFunc(&entryCb); glutMouseFunc(&mouseCb); glutMotionFunc(&motionCb); glutPassiveMotionFunc(&passivemotionCb); #endif // glutNameFunc(&nameCb); glutDisplayFunc (&displayCb); glutVisibilityFunc(&visibleCb); if(!createGemWindow()) { destroyMess(); return false; } titleMess(m_title); fullscreenMess(m_fullscreen); dispatch(); return true; }
gemw32window::~gemw32window(void) { destroyMess(); }