bool GraphicsManager::setupSDLGL(int width, int height, uint32 flags) { _fsaaMax = probeFSAA(width, height, flags); 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_ALPHA_SIZE , 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); _screen = SDL_CreateWindow(_windowTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags); if (!_screen) return false; setWindowIcon(*_screen); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); _glContext = SDL_GL_CreateContext(_screen); if (_glContext != NULL) { // OpenGL 3.2 context created, continue. return (_gl3 = true); } // OpenGL 3.2 context not created. Spit out an error message, and try a 2.1 context. _gl3 = false; warning("Could not create OpenGL 3.2 context: %s", SDL_GetError()); warning("Your graphics card hardware or driver does not support OpenGL 3.2. " "Attempting to create OpenGL 2.1 context instead"); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); _glContext = SDL_GL_CreateContext(_screen); if (_glContext == NULL) { SDL_DestroyWindow(_screen); return false; } return true; }
bool GraphicsManager::setupSDLGL(int width, int height, int bpp, uint32 flags) { _fsaaMax = probeFSAA(width, height, bpp, flags); 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 , bpp); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); _screen = SDL_SetVideoMode(width, height, bpp, flags); if (!_screen) return false; return true; }
bool GraphicsManager::setupSDLGL(int width, int height, uint32 flags) { _fsaaMax = probeFSAA(width, height, flags); 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_ALPHA_SIZE , 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); int x = ConfigMan.getInt("x", SDL_WINDOWPOS_UNDEFINED); int y = ConfigMan.getInt("y", SDL_WINDOWPOS_UNDEFINED); _screen = SDL_CreateWindow(_windowTitle.c_str(), x, y, width, height, flags); if (!_screen) return false; setWindowIcon(*_screen); _gl3 = true; _glProfile = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK , _glProfile); _glContext = SDL_GL_CreateContext(_screen); if (_glContext) return true; // OpenGL 3.2 context not created. Spit out an error message, and try a 2.1 core context. _gl3 = false; _glProfile = SDL_GL_CONTEXT_PROFILE_CORE; warning("Could not create OpenGL 3.2 context: %s", SDL_GetError()); warning("Your graphics card hardware or driver does not support OpenGL 3.2. " "Attempting to create OpenGL 2.1 context instead"); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK , _glProfile); _glContext = SDL_GL_CreateContext(_screen); if (_glContext) return true; // No OpenGL 2.1 core context. Let SDL decide what to give us. _gl3 = false; _glProfile = 0; SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK , _glProfile); _glContext = SDL_GL_CreateContext(_screen); if (_glContext) return true; SDL_DestroyWindow(_screen); return false; }