bool COpenGL::resizeDisplayScreen(const CRect<Uint16>& newDim) { // NOTE: try not to free the last SDL_Surface of the screen, this is freed automatically by SDL const int w = m_VidConfig.mAspectCorrection.w; const int h = m_VidConfig.mAspectCorrection.h; #if SDL_VERSION_ATLEAST(2, 0, 0) aspectCorrectResizing(newDim, w, h); #else screen = SDL_SetVideoMode( newDim.w, newDim.h, 32, m_Mode ); if (!screen) { g_pLogFile->textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError()); return false; } aspectCorrectResizing(newDim, w, h); if(FilteredSurface) { Scaler.setDynamicFactor( float(FilteredSurface->w)/float(aspectCorrectionRect.w), float(FilteredSurface->h)/float(aspectCorrectionRect.h)); setUpViewPort(aspectCorrectionRect); } #endif return true; }
bool COpenGL::init() { CVideoEngine::init(); const GLint oglfilter = m_VidConfig.m_opengl_filter; // Setup the view port for the first time setUpViewPort(g_pVideoDriver->getGameResolution(), g_pVideoDriver->getResolution()); // Set clear colour glClearColor(0,0,0,0); // Set projection glMatrixMode( GL_PROJECTION ); glLoadIdentity(); #if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) // TODO: dont check for iphone but for opengles #define glOrtho glOrthof #endif glOrtho( 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f ); // Now Initialize modelview matrix glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); /*Using the standard OpenGL API for specifying a 2D texture image: glTexImage2D, glSubTexImage2D, glCopyTexImage2D, and glCopySubTexImage2D. The target for these commands is GL_TEXTURE_RECTANGLE_ARB though. This is similar to how the texture cube map functionality uses the 2D texture image specification API though with its own texture target. The texture target GL_TEXTURE_RECTANGLE_ARB should also be used for glGetTexImage, glGetTexLevelParameteriv, and glGetTexLevelParameterfv.*/ // Enable Texture loading for the blit screen glEnable(m_texparam); createTexture(m_texture, oglfilter, m_GamePOTVideoDim.w, m_GamePOTVideoDim.h); if(m_VidConfig.m_ScaleXFilter <= 1) { // In that case we can do a texture based rendering createTexture(m_texFX, oglfilter, m_GamePOTVideoDim.w, m_GamePOTVideoDim.h, true); } // If there were any errors int error; error = glGetError(); if( error != GL_NO_ERROR) { g_pLogFile->ftextOut("OpenGL Init(): %d<br>",error); return false; } else { g_pLogFile->ftextOut("OpenGL Init(): Interface succesfully opened!<br>"); } return true; }
bool COpenGL::resizeDisplayScreen(const GsRect<Uint16>& newDim) { // NOTE: try not to free the last SDL_Surface of the screen, this is freed automatically by SDL const int w = m_VidConfig.mAspectCorrection.w; const int h = m_VidConfig.mAspectCorrection.h; // Render a black surface which cleans the screen, in case there already is some content in the screen if(mpScreenSfc->empty()) { clearSurfaces(); transformScreenToDisplay(); } #if SDL_VERSION_ATLEAST(2, 0, 0) updateAspectRect(newDim, w, h); setUpViewPort(mAspectCorrectionRect); #else mDisplaySfc.setPtr(SDL_SetVideoMode( newDim.w, newDim.h, 32, m_Mode )); if (mDisplaySfc.empty()) { gLogging.textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError()); return false; } updateAspectRect(newDim, w, h); setUpViewPort(mAspectCorrectionRect); #endif return true; }
bool COpenGL::resizeDisplayScreen(const CRect<Uint16>& newDim) { // NOTE: try not to free the last SDL_Surface of the screen, this is freed automatically by SDL screen = SDL_SetVideoMode( newDim.w, newDim.h, 32, m_Mode ); if (!screen) { g_pLogFile->textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError()); return false; } if(FilteredSurface) { Scaler.setDynamicFactor( float(FilteredSurface->w)/float(screen->w), float(FilteredSurface->h)/float(screen->h)); setUpViewPort(g_pVideoDriver->getGameResolution(), newDim); } return true; }
bool COpenGL::init() { CVideoEngine::init(); const GLint oglfilter = m_VidConfig.m_opengl_filter; #if SDL_VERSION_ATLEAST(2, 0, 0) Uint32 flags = SDL_WINDOW_OPENGL; if(m_VidConfig.Fullscreen) flags |= SDL_WINDOW_FULLSCREEN; else flags |= (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); window = SDL_CreateWindow("Commander Genius", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_VidConfig.m_DisplayRect.w, m_VidConfig.m_DisplayRect.h, flags); glcontext = SDL_GL_CreateContext(window); // Set clear colour glClearColor(0,0,0,0); // Set projection glMatrixMode( GL_PROJECTION ); glLoadIdentity(); #if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) // TODO: dont check for iphone but for opengles #define glOrtho glOrthof #endif glOrtho( 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f ); // Now Initialize modelview matrix glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Setup the view port for the first time #if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) glViewport(0, 0, 480, 320); #else setUpViewPort(mAspectCorrectionRect); #endif /*Using the standard OpenGL API for specifying a 2D texture image: glTexImage2D, glSubTexImage2D, glCopyTexImage2D, and glCopySubTexImage2D. The target for these commands is GL_TEXTURE_RECTANGLE_ARB though. This is similar to how the texture cube map functionality uses the 2D texture image specification API though with its own texture target. The texture target GL_TEXTURE_RECTANGLE_ARB should also be used for glGetTexImage, glGetTexLevelParameteriv, and glGetTexLevelParameterfv.*/ // Enable Texture loading for the blit screen glEnable(m_texparam); createTexture(m_texture, oglfilter, m_GamePOTScaleDim.w, m_GamePOTScaleDim.h); if(m_VidConfig.m_ScaleXFilter <= 1) { // In that case we can do a texture based rendering createTexture(m_texFX, oglfilter, m_GamePOTScaleDim.w, m_GamePOTScaleDim.h, true); } #else // not SDL 2.0 // Setup the view port for the first time setUpViewPort(mAspectCorrectionRect); // Set clear colour glClearColor(0,0,0,0); // Set projection glMatrixMode( GL_PROJECTION ); glLoadIdentity(); #if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) // TODO: dont check for iphone but for opengles #define glOrtho glOrthof #endif glOrtho( 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f ); // Now Initialize modelview matrix glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); /*Using the standard OpenGL API for specifying a 2D texture image: glTexImage2D, glSubTexImage2D, glCopyTexImage2D, and glCopySubTexImage2D. The target for these commands is GL_TEXTURE_RECTANGLE_ARB though. This is similar to how the texture cube map functionality uses the 2D texture image specification API though with its own texture target. The texture target GL_TEXTURE_RECTANGLE_ARB should also be used for glGetTexImage, glGetTexLevelParameteriv, and glGetTexLevelParameterfv.*/ // Enable Texture loading for the blit screen glEnable(m_texparam); createTexture(m_texture, oglfilter, m_GamePOTScaleDim.w, m_GamePOTScaleDim.h); //if(m_VidConfig.m_ScaleXFilter <= 1) { // In that case we can do a texture based rendering createTexture(m_texFX, oglfilter, m_GamePOTScaleDim.w, m_GamePOTScaleDim.h, true); } /*else { createTexture(m_texFX, oglfilter, m_GamePOTScaleDim.w, m_GamePOTScaleDim.h, true); }*/ #endif // If there were any errors int error; error = glGetError(); if( error != GL_NO_ERROR) { gLogging.ftextOut("OpenGL Init(): %d<br>",error); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_DestroyWindow(window); SDL_GL_DeleteContext(glcontext); #endif return false; } gLogging.ftextOut("OpenGL Init(): Interface successfully opened!<br>"); GLfloat light_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_position[] = { 0.0, 0.0, 1.0, 0.0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); return true; }