mirror of https://github.com/stella-emu/stella.git
- When switching to fullscreen OpenGL mode, only use some predefined, common
resolutions. Fixes the problem in Linux of getting weird refresh rates, and will hopefully fix the fullscreen OpenGL Windows problems as well. - Removed the option of automatically pausing when toggling fullscreen/ windowed mode since it was getting on my nerves :) git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@233 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
1f45ed9744
commit
fa5d1f97ac
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Console.cxx,v 1.23 2004-04-04 02:03:15 stephena Exp $
|
||||
// $Id: Console.cxx,v 1.24 2004-04-12 23:28:42 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -207,7 +207,7 @@ Console::~Console()
|
|||
void Console::update()
|
||||
{
|
||||
myFrameBuffer.update();
|
||||
// FIXME mySound.update();
|
||||
mySound.update();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: TIA.cxx,v 1.27 2004-04-04 02:03:15 stephena Exp $
|
||||
// $Id: TIA.cxx,v 1.28 2004-04-12 23:28:42 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -1637,7 +1637,7 @@ inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
|
|||
myFramePointer = ending;
|
||||
|
||||
// Add sound bytes to the sound queue every scanline
|
||||
mySound.update();
|
||||
//FIXME mySound.update();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferGL.cxx,v 1.14 2004-04-04 02:03:15 stephena Exp $
|
||||
// $Id: FrameBufferGL.cxx,v 1.15 2004-04-12 23:28:42 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -47,10 +47,33 @@ FrameBufferGL::~FrameBufferGL()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FrameBufferGL::createScreen()
|
||||
{
|
||||
uInt32 w = (uInt32) (myWidth * theZoomLevel * theAspectRatio);
|
||||
uInt32 h = myHeight * theZoomLevel;
|
||||
GLint viewportX = 0, viewportY = 0;
|
||||
uInt32 screenWidth = 0;
|
||||
uInt32 screenHeight = 0;
|
||||
|
||||
myScreen = SDL_SetVideoMode(w, h, 0, mySDLFlags);
|
||||
uInt32 imageWidth = (uInt32) (myWidth * theZoomLevel * theAspectRatio);
|
||||
uInt32 imageHeight = myHeight * theZoomLevel;
|
||||
|
||||
// Determine if we're in fullscreen or windowed mode
|
||||
// In fullscreen mode, we clip the SDL screen to known resolutions
|
||||
// In windowed mode, we use the actual image resolution for the SDL screen
|
||||
if(mySDLFlags & SDL_FULLSCREEN)
|
||||
{
|
||||
SDL_Rect rect = viewport(imageWidth, imageHeight);
|
||||
|
||||
viewportX = rect.x;
|
||||
viewportY = rect.y;
|
||||
screenWidth = rect.w;
|
||||
screenHeight = rect.h;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenWidth = imageWidth;
|
||||
screenHeight = imageHeight;
|
||||
viewportX = viewportY = 0;
|
||||
}
|
||||
|
||||
myScreen = SDL_SetVideoMode(screenWidth, screenHeight, 0, mySDLFlags);
|
||||
if(myScreen == NULL)
|
||||
{
|
||||
cerr << "ERROR: Unable to open SDL window: " << SDL_GetError() << endl;
|
||||
|
@ -58,14 +81,16 @@ bool FrameBufferGL::createScreen()
|
|||
}
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT);
|
||||
glViewport(0, 0, myScreen->w, myScreen->h);
|
||||
|
||||
// Center the screen horizontally and vertically
|
||||
glViewport(viewportX, viewportY, imageWidth, imageHeight);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glOrtho(0.0, (GLdouble) myScreen->w/(theZoomLevel * theAspectRatio),
|
||||
(GLdouble) myScreen->h/theZoomLevel, 0.0, 0.0, 1.0);
|
||||
glOrtho(0.0, (GLdouble) imageWidth/(theZoomLevel * theAspectRatio),
|
||||
(GLdouble) imageHeight/theZoomLevel, 0.0, 0.0, 1.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
@ -82,6 +107,9 @@ bool FrameBufferGL::createScreen()
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
||||
// Make sure any old parts of the screen are erased
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
theRedrawEntireFrameIndicator = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -476,3 +504,44 @@ void FrameBufferGL::toggleFilter()
|
|||
// The filtering has changed, so redraw the entire screen
|
||||
theRedrawEntireFrameIndicator = true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SDL_Rect FrameBufferGL::viewport(uInt32 width, uInt32 height)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
rect.x = rect.y = 0;
|
||||
rect.w = width; rect.h = height;
|
||||
|
||||
struct Screenmode
|
||||
{
|
||||
uInt32 w;
|
||||
uInt32 h;
|
||||
};
|
||||
|
||||
// List of valid fullscreen OpenGL modes
|
||||
Screenmode myScreenmode[6] = {
|
||||
{320, 200 },
|
||||
{640, 480 },
|
||||
{800, 600 },
|
||||
{1024, 768 },
|
||||
{1280, 1024},
|
||||
{1600, 1200}
|
||||
};
|
||||
|
||||
for(uInt32 i = 0; i < 6; i++)
|
||||
{
|
||||
if(width <= myScreenmode[i].w && height <= myScreenmode[i].h)
|
||||
{
|
||||
rect.x = (myScreenmode[i].w - width) / 2;
|
||||
rect.y = (myScreenmode[i].h - height) / 2;
|
||||
rect.w = myScreenmode[i].w;
|
||||
rect.h = myScreenmode[i].h;
|
||||
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, it probably indicates an error
|
||||
// But we have to return something ...
|
||||
return rect;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferGL.hxx,v 1.7 2003-12-10 18:58:56 stephena Exp $
|
||||
// $Id: FrameBufferGL.hxx,v 1.8 2004-04-12 23:28:42 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_GL_HXX
|
||||
|
@ -34,7 +34,7 @@ class MediaSource;
|
|||
This class implements an SDL OpenGL framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferGL.hxx,v 1.7 2003-12-10 18:58:56 stephena Exp $
|
||||
@version $Id: FrameBufferGL.hxx,v 1.8 2004-04-12 23:28:42 stephena Exp $
|
||||
*/
|
||||
class FrameBufferGL : public FrameBufferSDL
|
||||
{
|
||||
|
@ -123,6 +123,8 @@ class FrameBufferGL : public FrameBufferSDL
|
|||
|
||||
bool createTextures();
|
||||
|
||||
SDL_Rect viewport(uInt32 width, uInt32 height);
|
||||
|
||||
uInt32 power_of_two(uInt32 input)
|
||||
{
|
||||
uInt32 value = 1;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: mainSDL.cxx,v 1.69 2004-04-04 02:03:15 stephena Exp $
|
||||
// $Id: mainSDL.cxx,v 1.70 2004-04-12 23:28:43 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -334,9 +334,6 @@ void handleEvents()
|
|||
else if(key == SDLK_RETURN)
|
||||
{
|
||||
theDisplay->toggleFullscreen();
|
||||
// Pause when switching modes
|
||||
if(!theConsole->eventHandler().doPause())
|
||||
theConsole->eventHandler().sendEvent(Event::Pause, 1);
|
||||
}
|
||||
#ifdef DISPLAY_OPENGL
|
||||
else if(key == SDLK_f && theUseOpenGLFlag)
|
||||
|
@ -687,11 +684,7 @@ int main(int argc, char* argv[])
|
|||
theShowInfoFlag = theSettings->getBool("showinfo");
|
||||
|
||||
// Request that the SDL window be centered, if possible
|
||||
#if defined(UNIX)
|
||||
setenv("SDL_VIDEO_CENTERED", "1", 1);
|
||||
#else
|
||||
putenv("SDL_VIDEO_CENTERED=1");
|
||||
#endif
|
||||
|
||||
// Get a pointer to the file which contains the cartridge ROM
|
||||
const char* file = argv[argc - 1];
|
||||
|
@ -746,6 +739,7 @@ int main(int argc, char* argv[])
|
|||
if(!theDisplay)
|
||||
{
|
||||
cerr << "ERROR: Couldn't set up display.\n";
|
||||
delete[] image;
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue