void VideoEngine::PopState() { // Restore the most recent context information and pop it from stack if(_context_stack.empty()) { IF_PRINT_WARNING(VIDEO_DEBUG) << "no video states were saved on the stack" << std::endl; return; } _current_context = _context_stack.top(); _context_stack.pop(); // Restore the modelview transformation glMatrixMode(GL_MODELVIEW); PopMatrix(); glViewport(_current_context.viewport.left, _current_context.viewport.top, _current_context.viewport.width, _current_context.viewport.height); if(_current_context.scissoring_enabled) { EnableScissoring(); glScissor(static_cast<GLint>((_current_context.scissor_rectangle.left / static_cast<float>(VIDEO_STANDARD_RES_WIDTH)) * _current_context.viewport.width), static_cast<GLint>((_current_context.scissor_rectangle.top / static_cast<float>(VIDEO_STANDARD_RES_HEIGHT)) * _current_context.viewport.height), static_cast<GLsizei>((_current_context.scissor_rectangle.width / static_cast<float>(VIDEO_STANDARD_RES_WIDTH)) * _current_context.viewport.width), static_cast<GLsizei>((_current_context.scissor_rectangle.height / static_cast<float>(VIDEO_STANDARD_RES_HEIGHT)) * _current_context.viewport.height) ); } else { DisableScissoring(); } }
bool VideoEngine::ApplySettings() { if(_target == VIDEO_TARGET_SDL_WINDOW) { // Losing GL context, so unload images first if(TextureManager && TextureManager->UnloadTextures() == false) { IF_PRINT_WARNING(VIDEO_DEBUG) << "failed to delete OpenGL textures during a context change" << std::endl; } int32 flags = SDL_OPENGL; if(_temp_fullscreen == true) { flags |= SDL_FULLSCREEN; } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 2); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); if(SDL_SetVideoMode(_temp_width, _temp_height, 0, flags) == false) { // RGB values of 1 for each and 8 for depth seemed to be sufficient. // 565 and 16 here because it works with them on this computer. // NOTE from prophile: this ought to be changed to 5558 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); if(SDL_SetVideoMode(_temp_width, _temp_height, 0, flags) == false) { IF_PRINT_WARNING(VIDEO_DEBUG) << "SDL_SetVideoMode() failed with error: " << SDL_GetError() << std::endl; _temp_fullscreen = _fullscreen; _temp_width = _screen_width; _temp_height = _screen_height; if(TextureManager && _screen_width > 0) { // Test to see if we already had a valid video mode TextureManager->ReloadTextures(); } return false; } } // Clear GL state, after SDL_SetVideoMode() for OSX compatibility DisableBlending(); DisableTexture2D(); DisableAlphaTest(); DisableStencilTest(); DisableScissoring(); DisableVertexArray(); DisableColorArray(); DisableTextureCoordArray(); // Turn off writing to the depth buffer glDepthMask(GL_FALSE); _screen_width = _temp_width; _screen_height = _temp_height; _fullscreen = _temp_fullscreen; if(TextureManager) TextureManager->ReloadTextures(); return true; } // if (_target == VIDEO_TARGET_SDL_WINDOW) // Used by the editor, which uses QT4 else if(_target == VIDEO_TARGET_QT_WIDGET) { _screen_width = _temp_width; _screen_height = _temp_height; _fullscreen = _temp_fullscreen; return true; } return false; } // bool VideoEngine::ApplySettings()