Added the ability to change the aspect ratio of the screen in the SDL

OpenGL port.  Normally, the window is double the native TIA frame
width, so we always get a ratio of 2.0 (2:1).

Now, if you're using OpenGL mode, the '-gl_aspect' commandline argument
can take a decimal number representing the ratio you want to use.
For example, normal TV mode would be 1.3333 (4:3).

Depending on the resolution you use, you can make the window look much
more like the original Atari.  I find that in 1600x1200 mode, an
aspect of 1.6 looks quite authentic.

This is only supported in the SDL OpenGL port for now, since changing
the aspect took only 1 line of code (I love 3D graphics :)  It may
never be supported in software SDL, since it is quite a bit harder
to do it in software.

Ditto for the Cyberstella DirectDraw7 code (it will probably never be
implemented, unless hardware scaling is available).  If/when I get
around to the Direct3D port, it will be trivial to do there as well.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@211 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-11-17 17:43:39 +00:00
parent 77477bd297
commit 6983686e91
7 changed files with 47 additions and 26 deletions

View File

@ -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: Settings.cxx,v 1.11 2003-11-06 22:22:32 stephena Exp $
// $Id: Settings.cxx,v 1.12 2003-11-17 17:43:39 stephena Exp $
//============================================================================
#include <cassert>
@ -231,6 +231,17 @@ Int32 Settings::getInt(const string& key) const
return -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float Settings::getFloat(const string& key) const
{
// Try to find the named setting and answer its value
for(uInt32 i = 0; i < mySize; ++i)
if(key == mySettings[i].key)
return atof(mySettings[i].value.c_str());
return -1.0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Settings::getBool(const string& key) const
{

View File

@ -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: Settings.hxx,v 1.9 2003-11-06 22:22:32 stephena Exp $
// $Id: Settings.hxx,v 1.10 2003-11-17 17:43:39 stephena Exp $
//============================================================================
#ifndef SETTINGS_HXX
@ -32,7 +32,7 @@ class Console;
This class provides an interface for accessing frontend specific settings.
@author Stephen Anthony
@version $Id: Settings.hxx,v 1.9 2003-11-06 22:22:32 stephena Exp $
@version $Id: Settings.hxx,v 1.10 2003-11-17 17:43:39 stephena Exp $
*/
class Settings
{
@ -72,6 +72,15 @@ class Settings
*/
Int32 getInt(const string& key) const;
/**
Get the value assigned to the specified key. If the key does
not exist then -1.0 is returned.
@param key The key of the setting to lookup
@return The floating point value of the setting
*/
float getFloat(const string& key) const;
/**
Get the value assigned to the specified key. If the key does
not exist then false is returned.

View File

@ -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.3 2003-11-12 15:12:06 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.4 2003-11-17 17:43:39 stephena Exp $
//============================================================================
#include <SDL.h>
@ -46,8 +46,8 @@ FrameBufferGL::~FrameBufferGL()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBufferGL::createScreen()
{
int w = myWidth * theZoomLevel;
int h = myHeight * theZoomLevel;
uInt32 w = (uInt32) (myWidth * theZoomLevel * theAspectRatio);
uInt32 h = myHeight * theZoomLevel;
myScreen = SDL_SetVideoMode(w, h, 0, mySDLFlags);
if(myScreen == NULL)
@ -63,7 +63,7 @@ bool FrameBufferGL::createScreen()
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, (GLdouble) myScreen->w/theZoomLevel,
glOrtho(0.0, (GLdouble) myScreen->w/(theZoomLevel * theAspectRatio),
(GLdouble) myScreen->h/theZoomLevel, 0.0, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
@ -105,6 +105,13 @@ bool FrameBufferGL::init()
myWidth = myMediaSource->width() << 1;
myHeight = myMediaSource->height();
// Get the aspect ratio for the display
// Since the display is already doubled horizontally, we half the
// ratio that is provided
theAspectRatio = myConsole->settings().getFloat("gl_aspect") / 2;
if(theAspectRatio <= 0.0)
theAspectRatio = 1.0;
// Now create the OpenGL SDL screen
Uint32 initflags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
if(SDL_Init(initflags) < 0)

View File

@ -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.3 2003-11-12 15:12:06 stephena Exp $
// $Id: FrameBufferGL.hxx,v 1.4 2003-11-17 17:43:39 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.3 2003-11-12 15:12:06 stephena Exp $
@version $Id: FrameBufferGL.hxx,v 1.4 2003-11-17 17:43:39 stephena Exp $
*/
class FrameBufferGL : public FrameBufferSDL
{
@ -143,18 +143,6 @@ class FrameBufferGL : public FrameBufferSDL
// The OpenGL font texture handles (one for each character)
GLuint myFontTextureID[256];
// Structure to hold a characters coordinates
struct Coordinates
{
GLfloat minX;
GLfloat maxX;
GLfloat minY;
GLfloat maxY;
};
// OpenGL texture coordinates for the font surface
Coordinates myFontCoord[256];
};
#endif

View File

@ -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: FrameBufferSDL.cxx,v 1.4 2003-11-12 19:36:25 stephena Exp $
// $Id: FrameBufferSDL.cxx,v 1.5 2003-11-17 17:43:39 stephena Exp $
//============================================================================
#include <SDL.h>
@ -33,6 +33,7 @@ FrameBufferSDL::FrameBufferSDL()
theMaxZoomLevel(1),
theGrabMouseIndicator(false),
theHideCursorIndicator(false),
theAspectRatio(1.0),
isFullscreen(false)
{
}
@ -177,7 +178,7 @@ uInt32 FrameBufferSDL::maxWindowSizeForScreen()
while(!found && (multiplier > 0))
{
// Figure out the desired size of the window
int width = myWidth * multiplier;
int width = (int) (myWidth * multiplier * theAspectRatio);
int height = myHeight * multiplier;
if((width < screenWidth) && (height < screenHeight))

View File

@ -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: FrameBufferSDL.hxx,v 1.4 2003-11-12 19:36:25 stephena Exp $
// $Id: FrameBufferSDL.hxx,v 1.5 2003-11-17 17:43:39 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_SDL_HXX
@ -34,7 +34,7 @@
the core FrameBuffer.
@author Stephen Anthony
@version $Id: FrameBufferSDL.hxx,v 1.4 2003-11-12 19:36:25 stephena Exp $
@version $Id: FrameBufferSDL.hxx,v 1.5 2003-11-17 17:43:39 stephena Exp $
*/
class FrameBufferSDL : public FrameBuffer
{
@ -145,6 +145,9 @@ class FrameBufferSDL : public FrameBuffer
// Indicates if the mouse cursor should be hidden
bool theHideCursorIndicator;
// The aspect ratio of the window
float theAspectRatio;
// Indicates whether the game is currently in fullscreen
bool isFullscreen;
};

View File

@ -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: SettingsUNIX.cxx,v 1.3 2003-11-09 23:53:20 stephena Exp $
// $Id: SettingsUNIX.cxx,v 1.4 2003-11-17 17:43:39 stephena Exp $
//============================================================================
#include <cstdlib>
@ -65,6 +65,7 @@ SettingsUNIX::SettingsUNIX()
set("video", "soft");
#ifdef DISPLAY_OPENGL
set("gl_filter", "nearest");
set("gl_aspect", "1");
#endif
set("sound", "oss");
set("fullscreen", "false");
@ -102,6 +103,7 @@ void SettingsUNIX::usage(string& message)
<< " -gl_filter <type> Type is one of the following:\n"
<< " nearest Normal scaling (GL_NEAREST)\n"
<< " linear Blurred scaling (GL_LINEAR)\n"
<< " -gl_aspect <number> Scale the width by the given amount\n"
<< endl
#endif
<< " -sound <type> Type is one of the following:\n"