Added some OpenGL options to FrameBufferGL that only exist on SDL 1.2.10

or greater.  I'm hoping that one older systems, the code will still run
and just ignore these new options.

Added commandline argument '-gl_vsync', which enables v-sync'ed updates
for OpenGL, if it's available (see above).  Also added a setting for
this in the VideoDialog.

Fixed OSX OpenGL handling so that it doesn't specify an OpenGL library name,
and updated FrameBufferGL to use the default name in that case.  OSX users
will probably need to reset their settings file for this to take effect.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1175 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-12-04 18:54:51 +00:00
parent 1cbef3f8f9
commit dddbbfdfdf
5 changed files with 81 additions and 43 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: FrameBufferGL.cxx,v 1.68 2006-11-04 19:38:24 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.69 2006-12-04 18:54:51 stephena Exp $
//============================================================================
#ifdef DISPLAY_OPENGL
@ -35,6 +35,16 @@
#include "scaler.hxx"
#endif
// There's probably a cleaner way of doing this
// These values come from SDL_video.c
// If they change, this code will break horribly
#ifndef SDL_GL_ACCELERATED_VISUAL
#define SDL_GL_ACCELERATED_VISUAL SDL_GLattr(15)
#endif
#ifndef SDL_GL_SWAP_CONTROL
#define SDL_GL_SWAP_CONTROL SDL_GLattr(16)
#endif
// Maybe this code could be cleaner ...
static void (APIENTRY* p_glClear)( GLbitfield );
static void (APIENTRY* p_glEnable)( GLenum );
@ -116,7 +126,9 @@ bool FrameBufferGL::loadFuncs(const string& library)
if(SDL_WasInit(SDL_INIT_VIDEO) == 0)
SDL_Init(SDL_INIT_VIDEO);
if(SDL_GL_LoadLibrary(library.c_str()) < 0)
if(library == "" && SDL_GL_LoadLibrary(0) < 0) // Let SDL choose the GL library
return false;
else if(SDL_GL_LoadLibrary(library.c_str()) < 0)
return false;
// Otherwise, fill the function pointers for GL functions
@ -320,8 +332,14 @@ bool FrameBufferGL::createScreen()
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, myRGB[2] );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, myRGB[3] );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
// SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
// SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
// There's no guarantee this is supported on all hardware
// We leave it to the user to test and decide
if(myOSystem->settings().getBool("gl_vsync"))
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
else
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
// Set the screen coordinates
GLdouble orthoWidth = 0.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: Settings.cxx,v 1.92 2006-11-25 01:34:35 stephena Exp $
// $Id: Settings.cxx,v 1.93 2006-12-04 18:54:51 stephena Exp $
//============================================================================
#include <cassert>
@ -40,6 +40,7 @@ Settings::Settings(OSystem* osystem)
setInternal("gl_aspect", "2.0");
setInternal("gl_fsmax", "false");
setInternal("gl_lib", "");
setInternal("gl_vsync", "true");
setInternal("scale_ui", "Zoom1x");
setInternal("scale_tia", "Zoom1x");
@ -81,7 +82,7 @@ Settings::Settings(OSystem* osystem)
setInternal("tiadefaults", "false");
setInternal("autoslot", "false");
setInternal("fastscbios", "false");
setInternal("fastscbios", "true");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -279,12 +280,13 @@ void Settings::usage()
#ifdef DISPLAY_OPENGL
<< " gl SDL OpenGL mode\n"
<< endl
<< " -gl_lib <filename> Specify the OpenGL library\n"
<< " -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"
<< " -gl_fsmax <1|0> Use the largest available screenmode in fullscreen OpenGL\n"
<< " -gl_lib <filename> Specify the OpenGL library\n"
<< " -gl_vsync <1|0> Enable synchronize to vertical blank interrupt\n"
<< endl
#endif
<< " -zoom <size> Makes window be 'size' times normal\n"

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: VideoDialog.cxx,v 1.34 2006-11-28 21:48:56 stephena Exp $
// $Id: VideoDialog.cxx,v 1.35 2006-12-04 18:54:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -98,13 +98,9 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
wid.push_back(myPalettePopup);
ypos += lineHeight + 4;
// Move over to the next column
xpos += 115; ypos = 10;
// Available scalers
myScalerPopup = new PopUpWidget(this, font, xpos, ypos, pwidth,
lineHeight, "Scaler: ",
font.getStringWidth("Scaler: "));
lineHeight, "Scaler: ", lwidth);
myScalerPopup->appendEntry("Zoom1x", 1);
myScalerPopup->appendEntry("Zoom2x", 2);
myScalerPopup->appendEntry("Zoom3x", 3);
@ -118,7 +114,9 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
myScalerPopup->appendEntry("HQ3x", 10);
#endif
wid.push_back(myScalerPopup);
ypos += lineHeight + 4;
// Move over to the next column
xpos += 115; ypos = 10;
// Framerate
myFrameRateSlider = new SliderWidget(this, font, xpos, ypos, 30, lineHeight,
@ -138,16 +136,22 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
wid.push_back(myFullscreenCheckbox);
ypos += lineHeight + 4;
// TIA defaults
myTiaDefaultsCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Use TIA defaults");
wid.push_back(myTiaDefaultsCheckbox);
ypos += lineHeight + 4;
// Use desktop res in OpenGL
myUseDeskResCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Desktop Res in FS");
wid.push_back(myUseDeskResCheckbox);
ypos += lineHeight + 4;
// TIA defaults
myTiaDefaultsCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Use TIA defaults");
wid.push_back(myTiaDefaultsCheckbox);
// Use sync to vblank in OpenGL
myUseVSyncCheckbox = new CheckboxWidget(this, font, xpos + 5, ypos,
"Enable VSync");
wid.push_back(myUseVSyncCheckbox);
ypos += lineHeight + 20;
// Add Defaults, OK and Cancel buttons
@ -226,6 +230,17 @@ void VideoDialog::loadConfig()
myAspectRatioSlider->setValue(i);
myAspectRatioLabel->setLabel(s);
// Palette
s = instance()->settings().getString("palette");
if(s == "standard")
myPalettePopup->setSelectedTag(1);
else if(s == "original")
myPalettePopup->setSelectedTag(2);
else if(s == "z26")
myPalettePopup->setSelectedTag(3);
else if(s == "user")
myPalettePopup->setSelectedTag(4);
// Scaler
s = instance()->settings().getString("scale_tia");
if(s == "Zoom1x")
@ -253,28 +268,21 @@ void VideoDialog::loadConfig()
else
myScalerPopup->setSelectedTag(0);
// Palette
s = instance()->settings().getString("palette");
if(s == "standard")
myPalettePopup->setSelectedTag(1);
else if(s == "original")
myPalettePopup->setSelectedTag(2);
else if(s == "z26")
myPalettePopup->setSelectedTag(3);
else if(s == "user")
myPalettePopup->setSelectedTag(4);
// Fullscreen
b = instance()->settings().getBool("fullscreen");
myFullscreenCheckbox->setState(b);
// Use TIA defaults instead of tweaked values
b = instance()->settings().getBool("tiadefaults");
myTiaDefaultsCheckbox->setState(b);
// Use desktop resolution in fullscreen mode
b = instance()->settings().getBool("gl_fsmax");
myUseDeskResCheckbox->setState(b);
// Use TIA defaults instead of tweaked values
b = instance()->settings().getBool("tiadefaults");
myTiaDefaultsCheckbox->setState(b);
// Use sync to vertical blank
b = instance()->settings().getBool("gl_vsync");
myUseVSyncCheckbox->setState(b);
// Make sure that mutually-exclusive items are not enabled at the same time
i = myRendererPopup->getSelectedTag() - 1;
@ -361,6 +369,11 @@ void VideoDialog::saveConfig()
b = myFullscreenCheckbox->getState();
instance()->frameBuffer().setFullscreen(b);
// Use TIA defaults instead of tweaked values
b = myTiaDefaultsCheckbox->getState();
instance()->settings().setBool("tiadefaults", b);
myTiaDefaultsCheckbox->setState(b);
// Use desktop resolution in fullscreen mode
b = myUseDeskResCheckbox->getState();
if(b != instance()->settings().getBool("gl_fsmax"))
@ -369,11 +382,13 @@ void VideoDialog::saveConfig()
restart = true;
}
// Use TIA defaults instead of tweaked values
b = myTiaDefaultsCheckbox->getState();
instance()->settings().setBool("tiadefaults", b);
myTiaDefaultsCheckbox->setState(b);
// Use sync to vertical blank
b = myUseVSyncCheckbox->getState();
if(b != instance()->settings().getBool("gl_vsync"))
{
instance()->settings().setBool("gl_vsync", b);
restart = true;
}
// Finally, issue a complete framebuffer re-initialization
// Not all options may require a full re-initialization, so we only
@ -399,8 +414,9 @@ void VideoDialog::setDefaults()
myAspectRatioLabel->setLabel("2.0");
myFullscreenCheckbox->setState(false);
myUseDeskResCheckbox->setState(true);
myTiaDefaultsCheckbox->setState(false);
myUseDeskResCheckbox->setState(true);
myUseVSyncCheckbox->setState(true);
// Make sure that mutually-exclusive items are not enabled at the same time
handleRendererChange(0); // 0 indicates software mode
@ -416,6 +432,7 @@ void VideoDialog::handleRendererChange(int item)
myAspectRatioSlider->setEnabled(active);
myAspectRatioLabel->setEnabled(active);
myUseDeskResCheckbox->setEnabled(active);
myUseVSyncCheckbox->setEnabled(active);
// Also, in OpenGL mode, certain software related items are disabled
myDirtyPopup->setEnabled(!active);

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: VideoDialog.hxx,v 1.14 2006-11-18 13:29:11 stephena Exp $
// $Id: VideoDialog.hxx,v 1.15 2006-12-04 18:54:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -59,8 +59,9 @@ class VideoDialog : public Dialog
StaticTextWidget* myFrameRateLabel;
PopUpWidget* myScalerPopup;
CheckboxWidget* myFullscreenCheckbox;
CheckboxWidget* myUseDeskResCheckbox;
CheckboxWidget* myTiaDefaultsCheckbox;
CheckboxWidget* myUseDeskResCheckbox;
CheckboxWidget* myUseVSyncCheckbox;
enum {
kRendererChanged = 'VDrd',

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: SettingsMACOSX.cxx,v 1.11 2006-03-09 03:16:30 markgrebe Exp $
// $Id: SettingsMACOSX.cxx,v 1.12 2006-12-04 18:54:51 stephena Exp $
//============================================================================
#include <cassert>
@ -42,7 +42,7 @@ SettingsMACOSX::SettingsMACOSX(OSystem* osystem)
: Settings(osystem)
{
setInternal("video", "gl"); // Use opengl mode by default
setInternal("gl_lib", "libGL.so");
setInternal("gl_lib", ""); // Let the system decide which lib to use
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -