Hopefully finally fixed the issue of OpenGL texture re-generation whose

behaviour differs between OSX and other systems.

Disabled output of the TIA display while in the debugger; this code
needs to be rewritten.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1567 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-12-20 23:32:46 +00:00
parent a8a2689269
commit 5dc7cba2a8
6 changed files with 58 additions and 25 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferGL.cxx,v 1.119 2008-12-18 23:36:32 stephena Exp $ // $Id: FrameBufferGL.cxx,v 1.120 2008-12-20 23:32:45 stephena Exp $
//============================================================================ //============================================================================
#ifdef DISPLAY_OPENGL #ifdef DISPLAY_OPENGL
@ -361,19 +361,28 @@ cerr << "dimensions: " << endl
<< " imageh = " << mode.image_h << endl << " imageh = " << mode.image_h << endl
<< endl; << endl;
////////////////////////////////////////////////////////////////////
// Note that the following must be done in the order given
// Basically, all surfaces must first be free'd before being
// recreated
// So, we delete the TIA surface first, then reset all other surfaces
// (which frees all surfaces and then reloads all surfaces), then
// re-create the TIA surface (if necessary)
// In this way, all free()'s come before all reload()'s
////////////////////////////////////////////////////////////////////
// The framebuffer only takes responsibility for TIA surfaces // The framebuffer only takes responsibility for TIA surfaces
// Other surfaces (such as the ones used for dialogs) are allocated // Other surfaces (such as the ones used for dialogs) are allocated
// in the Dialog class // in the Dialog class
if(!inUIMode) delete myTiaSurface; myTiaSurface = NULL;
{
delete myTiaSurface;
myTiaSurface = new FBSurfaceGL(*this, baseWidth, baseHeight,
mode.image_w, mode.image_h);
}
// Any previously allocated textures currently in use by various UI items // Any previously allocated textures currently in use by various UI items
// need to be refreshed as well (only seems to be required for OSX) // need to be refreshed as well (only seems to be required for OSX)
reloadSurfaces(); resetSurfaces();
if(!inUIMode)
myTiaSurface = new FBSurfaceGL(*this, baseWidth, baseHeight,
mode.image_w, mode.image_h);
// Make sure any old parts of the screen are erased // Make sure any old parts of the screen are erased
p_glClear(GL_COLOR_BUFFER_BIT); p_glClear(GL_COLOR_BUFFER_BIT);
@ -603,7 +612,7 @@ cerr << " FBSurfaceGL::~FBSurfaceGL(): myTexID = " << myTexID << " @ " << this
if(myTexture) if(myTexture)
SDL_FreeSurface(myTexture); SDL_FreeSurface(myTexture);
p_glDeleteTextures(1, &myTexID); free();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -787,6 +796,14 @@ void FBSurfaceGL::update()
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::free()
{
p_glDeleteTextures(1, &myTexID);
cerr << " ==> FBSurfaceGL::free(): myTexID = " << myTexID << " @ " << this << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::reload() void FBSurfaceGL::reload()
{ {
@ -813,8 +830,6 @@ void FBSurfaceGL::reload()
myFilterParamName = "GL_NEAREST"; myFilterParamName = "GL_NEAREST";
} }
*/ */
// p_glDeleteTextures(1, &myTexID);
p_glGenTextures(1, &myTexID); p_glGenTextures(1, &myTexID);
p_glBindTexture(myTexTarget, myTexID); p_glBindTexture(myTexTarget, myTexID);
p_glTexParameteri(myTexTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); p_glTexParameteri(myTexTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferGL.hxx,v 1.62 2008-12-14 21:44:06 stephena Exp $ // $Id: FrameBufferGL.hxx,v 1.63 2008-12-20 23:32:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_GL_HXX #ifndef FRAMEBUFFER_GL_HXX
@ -35,7 +35,7 @@ class FBSurfaceGL;
This class implements an SDL OpenGL framebuffer. This class implements an SDL OpenGL framebuffer.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBufferGL.hxx,v 1.62 2008-12-14 21:44:06 stephena Exp $ @version $Id: FrameBufferGL.hxx,v 1.63 2008-12-20 23:32:46 stephena Exp $
*/ */
class FrameBufferGL : public FrameBuffer class FrameBufferGL : public FrameBuffer
{ {
@ -206,7 +206,7 @@ class FrameBufferGL : public FrameBuffer
A surface suitable for OpenGL rendering mode. A surface suitable for OpenGL rendering mode.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBufferGL.hxx,v 1.62 2008-12-14 21:44:06 stephena Exp $ @version $Id: FrameBufferGL.hxx,v 1.63 2008-12-20 23:32:46 stephena Exp $
*/ */
class FBSurfaceGL : public FBSurface class FBSurfaceGL : public FBSurface
{ {
@ -232,6 +232,7 @@ class FBSurfaceGL : public FBSurface
void setHeight(uInt32 h); void setHeight(uInt32 h);
void translateCoords(Int32& x, Int32& y) const; void translateCoords(Int32& x, Int32& y) const;
void update(); void update();
void free();
void reload(); void reload();
private: private:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferSoft.hxx,v 1.56 2008-12-12 15:51:06 stephena Exp $ // $Id: FrameBufferSoft.hxx,v 1.57 2008-12-20 23:32:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_SOFT_HXX #ifndef FRAMEBUFFER_SOFT_HXX
@ -32,7 +32,7 @@ class RectList;
This class implements an SDL software framebuffer. This class implements an SDL software framebuffer.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.56 2008-12-12 15:51:06 stephena Exp $ @version $Id: FrameBufferSoft.hxx,v 1.57 2008-12-20 23:32:46 stephena Exp $
*/ */
class FrameBufferSoft : public FrameBuffer class FrameBufferSoft : public FrameBuffer
{ {
@ -172,7 +172,7 @@ class FrameBufferSoft : public FrameBuffer
A surface suitable for software rendering mode. A surface suitable for software rendering mode.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.56 2008-12-12 15:51:06 stephena Exp $ @version $Id: FrameBufferSoft.hxx,v 1.57 2008-12-20 23:32:46 stephena Exp $
*/ */
class FBSurfaceSoft : public FBSurface class FBSurfaceSoft : public FBSurface
{ {
@ -195,6 +195,7 @@ class FBSurfaceSoft : public FBSurface
void setHeight(uInt32 h); void setHeight(uInt32 h);
void translateCoords(Int32& x, Int32& y) const; void translateCoords(Int32& x, Int32& y) const;
void update(); void update();
void free() { } // Not required for software mode
void reload() { } // Not required for software mode void reload() { } // Not required for software mode
private: private:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TiaOutputWidget.cxx,v 1.18 2008-07-25 12:41:41 stephena Exp $ // $Id: TiaOutputWidget.cxx,v 1.19 2008-12-20 23:32:46 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -143,6 +143,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::drawWidget(bool hilite) void TiaOutputWidget::drawWidget(bool hilite)
{ {
return;
// FIXME - check if we're in 'greyed out mode' and act accordingly // FIXME - check if we're in 'greyed out mode' and act accordingly
instance().frameBuffer().refresh(); instance().frameBuffer().refresh();
instance().frameBuffer().drawMediaSource(); instance().frameBuffer().drawMediaSource();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.cxx,v 1.144 2008-12-12 18:32:53 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.145 2008-12-20 23:32:46 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
@ -408,9 +408,17 @@ FBSurface* FrameBuffer::surface(int id) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::reloadSurfaces() void FrameBuffer::resetSurfaces()
{ {
// Free all resources for each surface, then reload them
// Due to possible timing and/or synchronization issues, all free()'s
// are done first, then all reload()'s
// Any derived FrameBuffer classes that call this method should be
// aware of these restrictions, and act accordingly
map<int,FBSurface*>::iterator iter; map<int,FBSurface*>::iterator iter;
for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter)
iter->second->free();
for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter) for(iter = mySurfaceList.begin(); iter != mySurfaceList.end(); ++iter)
iter->second->reload(); iter->second->reload();
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.hxx,v 1.106 2008-12-12 18:32:53 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.107 2008-12-20 23:32:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -91,7 +91,7 @@ enum {
turn drawn here as well. turn drawn here as well.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.106 2008-12-12 18:32:53 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.107 2008-12-20 23:32:46 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
@ -387,10 +387,10 @@ class FrameBuffer
virtual string about() const = 0; virtual string about() const = 0;
/** /**
Issues the 'reload' instruction to all surfaces that the Issues a 'free' and 'reload' instruction to all surfaces that the
framebuffer knows about. framebuffer knows about.
*/ */
void reloadSurfaces(); void resetSurfaces();
protected: protected:
// The parent system for the framebuffer // The parent system for the framebuffer
@ -549,7 +549,7 @@ class FrameBuffer
FrameBuffer type. FrameBuffer type.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.106 2008-12-12 18:32:53 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.107 2008-12-20 23:32:46 stephena Exp $
*/ */
// Text alignment modes for drawString() // Text alignment modes for drawString()
enum TextAlignment { enum TextAlignment {
@ -683,8 +683,15 @@ class FBSurface
*/ */
virtual void update() = 0; virtual void update() = 0;
/**
This method should be called to free any resources being used by
the surface.
*/
virtual void free() = 0;
/** /**
This method should be called to reload the surface data/state. This method should be called to reload the surface data/state.
It will normally be called after free().
*/ */
virtual void reload() = 0; virtual void reload() = 0;