mirror of https://github.com/stella-emu/stella.git
Made sure aspect ratio is taken into account when checking for maximum size
of SDL screen. Still TODO is change OpenGL mode so that aspect ratio and non-integral scaling are not used when in debugger or launcher mode (ie, when we know the absolute coordinates of the screen). We do this since those modes are mostly GUI-based, and the GUI doesn't look quite right when using OpenGL scaling. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@456 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
298c6f2456
commit
e6e91f3522
|
@ -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.25 2005-05-29 16:09:21 stephena Exp $
|
||||
// $Id: FrameBufferGL.cxx,v 1.26 2005-05-30 16:25:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -55,18 +55,6 @@ bool FrameBufferGL::initSubsystem()
|
|||
{
|
||||
mySDLFlags |= SDL_OPENGL;
|
||||
|
||||
// Get the aspect ratio for the display
|
||||
// Since the display is already doubled horizontally, we half the
|
||||
// ratio that is provided
|
||||
if(theUseAspectRatioFlag)
|
||||
{
|
||||
theAspectRatio = myOSystem->settings().getFloat("gl_aspect") / 2;
|
||||
if(theAspectRatio <= 0.0)
|
||||
theAspectRatio = 1.0;
|
||||
}
|
||||
else
|
||||
theAspectRatio = 1.0;
|
||||
|
||||
// Set up the OpenGL attributes
|
||||
myDepth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
|
||||
switch(myDepth)
|
||||
|
@ -157,6 +145,14 @@ bool FrameBufferGL::initSubsystem()
|
|||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::setAspectRatio()
|
||||
{
|
||||
theAspectRatio = myOSystem->settings().getFloat("gl_aspect") / 2;
|
||||
if(theAspectRatio <= 0.0)
|
||||
theAspectRatio = 1.0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FrameBufferGL::createScreen()
|
||||
{
|
||||
|
@ -508,8 +504,7 @@ void FrameBufferGL::setDimensions(GLdouble* orthoWidth, GLdouble* orthoHeight)
|
|||
scaleX = float(myImageDim.w) / myScreenDim.w;
|
||||
scaleY = float(myImageDim.h) / myScreenDim.h;
|
||||
|
||||
// Figure out which dimension is closest to the 10% mark,
|
||||
// and calculate the scaling required to bring it to exactly 10%
|
||||
cerr << "scaleX = " << scaleX << ", scaleY = " << scaleY << endl;
|
||||
if(scaleX > scaleY)
|
||||
myFSScaleFactor = float(myScreenDim.w) / myImageDim.w;
|
||||
else
|
||||
|
|
|
@ -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.13 2005-05-19 19:43:38 stephena Exp $
|
||||
// $Id: FrameBufferGL.hxx,v 1.14 2005-05-30 16:25:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_GL_HXX
|
||||
|
@ -34,7 +34,7 @@ class OSystem;
|
|||
This class implements an SDL OpenGL framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferGL.hxx,v 1.13 2005-05-19 19:43:38 stephena Exp $
|
||||
@version $Id: FrameBufferGL.hxx,v 1.14 2005-05-30 16:25:46 stephena Exp $
|
||||
*/
|
||||
class FrameBufferGL : public FrameBuffer
|
||||
{
|
||||
|
@ -58,6 +58,11 @@ class FrameBufferGL : public FrameBuffer
|
|||
*/
|
||||
virtual bool initSubsystem();
|
||||
|
||||
/**
|
||||
This routine is called to set the aspect ratio of the screen.
|
||||
*/
|
||||
virtual void setAspectRatio();
|
||||
|
||||
/**
|
||||
This routine is called whenever the screen needs to be recreated.
|
||||
It updates the global screen variable.
|
||||
|
|
|
@ -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: FrameBufferSoft.cxx,v 1.22 2005-05-29 16:09:21 stephena Exp $
|
||||
// $Id: FrameBufferSoft.cxx,v 1.23 2005-05-30 16:25:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -71,6 +71,13 @@ bool FrameBufferSoft::initSubsystem()
|
|||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSoft::setAspectRatio()
|
||||
{
|
||||
// Aspect ratio correction not yet available in software mode
|
||||
theAspectRatio = 1.0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FrameBufferSoft::createScreen()
|
||||
{
|
||||
|
|
|
@ -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: FrameBufferSoft.hxx,v 1.13 2005-05-16 00:02:31 stephena Exp $
|
||||
// $Id: FrameBufferSoft.hxx,v 1.14 2005-05-30 16:25:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_SOFT_HXX
|
||||
|
@ -34,7 +34,7 @@ class RectList;
|
|||
This class implements an SDL software framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.13 2005-05-16 00:02:31 stephena Exp $
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.14 2005-05-30 16:25:46 stephena Exp $
|
||||
*/
|
||||
class FrameBufferSoft : public FrameBuffer
|
||||
{
|
||||
|
@ -58,6 +58,11 @@ class FrameBufferSoft : public FrameBuffer
|
|||
*/
|
||||
virtual bool initSubsystem();
|
||||
|
||||
/**
|
||||
This routine is called to set the aspect ratio of the screen.
|
||||
*/
|
||||
virtual void setAspectRatio();
|
||||
|
||||
/**
|
||||
This routine is called whenever the screen needs to be recreated.
|
||||
It updates the global screen variable.
|
||||
|
|
|
@ -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: FrameBuffer.cxx,v 1.40 2005-05-28 17:25:41 stephena Exp $
|
||||
// $Id: FrameBuffer.cxx,v 1.41 2005-05-30 16:25:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -41,7 +41,6 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
|
|||
theZoomLevel(2),
|
||||
theMaxZoomLevel(2),
|
||||
theAspectRatio(1.0),
|
||||
theUseAspectRatioFlag(true),
|
||||
myFrameRate(0),
|
||||
myPauseStatus(false),
|
||||
theOverlayChangedIndicator(false),
|
||||
|
@ -132,8 +131,10 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
|
|||
// Set window title
|
||||
setWindowTitle(title);
|
||||
|
||||
// Indicate whether we want to use aspect ratio correction
|
||||
theUseAspectRatioFlag = useAspect;
|
||||
// Get the aspect ratio for the display if it's been enabled
|
||||
theAspectRatio = 1.0;
|
||||
if(useAspect)
|
||||
setAspectRatio();
|
||||
|
||||
// Get the maximum size of a window for the current desktop
|
||||
theMaxZoomLevel = maxWindowSizeForScreen();
|
||||
|
@ -420,7 +421,7 @@ uInt32 FrameBuffer::maxWindowSizeForScreen()
|
|||
{
|
||||
uInt32 sWidth = myDesktopDim.w;
|
||||
uInt32 sHeight = myDesktopDim.h;
|
||||
uInt32 multiplier = sWidth / myBaseDim.w;
|
||||
uInt32 multiplier = 10;
|
||||
|
||||
// If screenwidth or height could not be found, use default zoom value
|
||||
if(sWidth == 0 || sHeight == 0)
|
||||
|
@ -430,7 +431,7 @@ uInt32 FrameBuffer::maxWindowSizeForScreen()
|
|||
while(!found && (multiplier > 0))
|
||||
{
|
||||
// Figure out the desired size of the window
|
||||
uInt32 width = myBaseDim.w * multiplier;
|
||||
uInt32 width = (uInt32) (myBaseDim.w * multiplier * theAspectRatio);
|
||||
uInt32 height = myBaseDim.h * multiplier;
|
||||
|
||||
if((width < sWidth) && (height < sHeight))
|
||||
|
|
|
@ -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: FrameBuffer.hxx,v 1.35 2005-05-28 17:25:41 stephena Exp $
|
||||
// $Id: FrameBuffer.hxx,v 1.36 2005-05-30 16:25:47 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_HXX
|
||||
|
@ -40,7 +40,7 @@ class OSystem;
|
|||
All GUI elements (ala ScummVM) are drawn here as well.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBuffer.hxx,v 1.35 2005-05-28 17:25:41 stephena Exp $
|
||||
@version $Id: FrameBuffer.hxx,v 1.36 2005-05-30 16:25:47 stephena Exp $
|
||||
*/
|
||||
class FrameBuffer
|
||||
{
|
||||
|
@ -187,16 +187,6 @@ class FrameBuffer
|
|||
*/
|
||||
bool fullScreen();
|
||||
|
||||
/**
|
||||
Answers the current zoom level of the framebuffer image in the X axis.
|
||||
*/
|
||||
inline const float zoomLevelX() { return theZoomLevel * theAspectRatio; }
|
||||
|
||||
/**
|
||||
Answers the current zoom level of the framebuffer image in the X axis.
|
||||
*/
|
||||
inline const float zoomLevelY() { return (float) theZoomLevel; }
|
||||
|
||||
/**
|
||||
Calculate the maximum window size that the current screen can hold.
|
||||
Only works in X11/Win32 for now, otherwise always return 4.
|
||||
|
@ -252,6 +242,11 @@ class FrameBuffer
|
|||
*/
|
||||
virtual bool initSubsystem() = 0;
|
||||
|
||||
/**
|
||||
This routine is called to set the aspect ratio of the screen.
|
||||
*/
|
||||
virtual void setAspectRatio() = 0;
|
||||
|
||||
/**
|
||||
This routine is called whenever the screen needs to be recreated.
|
||||
It updates the global screen variable.
|
||||
|
@ -415,9 +410,6 @@ class FrameBuffer
|
|||
// The aspect ratio of the window
|
||||
float theAspectRatio;
|
||||
|
||||
// Indicates whether to use aspect ratio correction
|
||||
bool theUseAspectRatioFlag;
|
||||
|
||||
// The font object to use
|
||||
StellaFont* myFont;
|
||||
|
||||
|
|
Loading…
Reference in New Issue