From c25672bd63cce049e931030f70629eb689cf43eb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 29 Apr 2012 16:28:15 +0300 Subject: Add graphicsmanager class and move some code to it. --- src/opengl1graphics.cpp | 81 ++----------------------------------------------- 1 file changed, 3 insertions(+), 78 deletions(-) (limited to 'src/opengl1graphics.cpp') diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index 1f08443cc..33eabc236 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -51,6 +51,7 @@ OpenGL1Graphics::OpenGL1Graphics(): mFboId(0), mTextureId(0), mRboId(0) { mOpenGL = 2; + mName = "safe OpenGL"; } OpenGL1Graphics::~OpenGL1Graphics() @@ -65,85 +66,9 @@ void OpenGL1Graphics::setSync(bool sync) bool OpenGL1Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel, bool resize, bool noFrame) { - logger->log1("graphics backend: safe OpenGL"); - logger->log("Setting video mode %dx%d %s", - w, h, fs ? "fullscreen" : "windowed"); + setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame); - int displayFlags = SDL_ANYFORMAT | SDL_OPENGL; - - mWidth = w; - mHeight = h; - mBpp = bpp; - mFullscreen = fs; - mHWAccel = hwaccel; - mEnableResize = resize; - mNoFrame = noFrame; - - if (fs) - { - displayFlags |= SDL_FULLSCREEN; - } - else - { - // Resizing currently not supported on Windows, where it would require - // reuploading all textures. -#if !defined(_WIN32) - if (resize) - displayFlags |= SDL_RESIZABLE; -#endif - } - - if (noFrame) - displayFlags |= SDL_NOFRAME; - - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - if (!(mTarget = SDL_SetVideoMode(w, h, bpp, displayFlags))) - return false; - -#ifdef __APPLE__ - if (mSync) - { - const GLint VBL = 1; - CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL); - } -#endif - - // Setup OpenGL - glViewport(0, 0, w, h); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - int gotDoubleBuffer; - SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer); - logger->log("Using OpenGL %s double buffering.", - (gotDoubleBuffer ? "with" : "without")); - - char const *glExtensions = reinterpret_cast( - glGetString(GL_EXTENSIONS)); - - logger->log1("opengl extensions: "); - logger->log1(glExtensions); - - GLint texSize; - bool rectTex = strstr(glExtensions, "GL_ARB_texture_rectangle"); - if (rectTex && config.getBoolValue("rectangulartextures")) - { - logger->log1("using GL_ARB_texture_rectangle"); - Image::mTextureType = GL_TEXTURE_RECTANGLE_ARB; - glEnable(GL_TEXTURE_RECTANGLE_ARB); - glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &texSize); - Image::mTextureSize = texSize; - logger->log("OpenGL texture size: %d pixels (rectangle textures)", - Image::mTextureSize); - } - else - { - Image::mTextureType = GL_TEXTURE_2D; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize); - Image::mTextureSize = texSize; - logger->log("OpenGL texture size: %d pixels", Image::mTextureSize); - } - - return true; + return setOpenGLMode(); } static inline void drawQuad(Image *image, -- cgit v1.2.3-70-g09d2