Cocoa Port: Simplify OpenGL context handling.
This commit is contained in:
parent
91f2bb9ee5
commit
34656d977c
|
@ -4281,11 +4281,6 @@ void GetGLVersionOGL(GLint *outMajor, GLint *outMinor, GLint *outRevision)
|
|||
}
|
||||
}
|
||||
|
||||
OGLInfo* OGLInfoCreate_Legacy()
|
||||
{
|
||||
return new OGLInfo_Legacy;
|
||||
}
|
||||
|
||||
void glBindVertexArray_LegacyAPPLE(GLuint vaoID)
|
||||
{
|
||||
glBindVertexArrayAPPLE(vaoID);
|
||||
|
@ -4301,7 +4296,6 @@ void glGenVertexArrays_LegacyAPPLE(GLsizei n, GLuint *vaoIDs)
|
|||
glGenVertexArraysAPPLE(n, vaoIDs);
|
||||
}
|
||||
|
||||
OGLInfo* (*OGLInfoCreate_Func)() = &OGLInfoCreate_Legacy;
|
||||
void (*glBindVertexArrayDESMUME)(GLuint id) = &glBindVertexArray_LegacyAPPLE;
|
||||
void (*glDeleteVertexArraysDESMUME)(GLsizei n, const GLuint *ids) = &glDeleteVertexArrays_LegacyAPPLE;
|
||||
void (*glGenVertexArraysDESMUME)(GLsizei n, GLuint *ids) = &glGenVertexArrays_LegacyAPPLE;
|
||||
|
@ -4452,7 +4446,7 @@ static void InitHQnxLUTs()
|
|||
|
||||
#pragma mark -
|
||||
|
||||
OGLInfo::OGLInfo()
|
||||
OGLContextInfo::OGLContextInfo()
|
||||
{
|
||||
GetGLVersionOGL(&_versionMajor, &_versionMinor, &_versionRevision);
|
||||
_shaderSupport = ShaderSupport_Unsupported;
|
||||
|
@ -4464,42 +4458,42 @@ OGLInfo::OGLInfo()
|
|||
_isFBOSupported = false;
|
||||
}
|
||||
|
||||
ShaderSupportTier OGLInfo::GetShaderSupport()
|
||||
ShaderSupportTier OGLContextInfo::GetShaderSupport()
|
||||
{
|
||||
return this->_shaderSupport;
|
||||
}
|
||||
|
||||
bool OGLInfo::IsUsingShader150()
|
||||
bool OGLContextInfo::IsUsingShader150()
|
||||
{
|
||||
return this->_useShader150;
|
||||
}
|
||||
|
||||
bool OGLInfo::IsVBOSupported()
|
||||
bool OGLContextInfo::IsVBOSupported()
|
||||
{
|
||||
return this->_isVBOSupported;
|
||||
}
|
||||
|
||||
bool OGLInfo::IsVAOSupported()
|
||||
bool OGLContextInfo::IsVAOSupported()
|
||||
{
|
||||
return this->_isVAOSupported;
|
||||
}
|
||||
|
||||
bool OGLInfo::IsPBOSupported()
|
||||
bool OGLContextInfo::IsPBOSupported()
|
||||
{
|
||||
return this->_isPBOSupported;
|
||||
}
|
||||
|
||||
bool OGLInfo::IsShaderSupported()
|
||||
bool OGLContextInfo::IsShaderSupported()
|
||||
{
|
||||
return (this->_shaderSupport != ShaderSupport_Unsupported);
|
||||
}
|
||||
|
||||
bool OGLInfo::IsFBOSupported()
|
||||
bool OGLContextInfo::IsFBOSupported()
|
||||
{
|
||||
return this->_isFBOSupported;
|
||||
}
|
||||
|
||||
OGLInfo_Legacy::OGLInfo_Legacy()
|
||||
OGLContextInfo_Legacy::OGLContextInfo_Legacy()
|
||||
{
|
||||
_shaderSupport = ShaderSupport_Unsupported;
|
||||
_useShader150 = false;
|
||||
|
@ -4595,7 +4589,7 @@ OGLInfo_Legacy::OGLInfo_Legacy()
|
|||
_isFBOSupported = this->IsExtensionPresent(oglExtensionSet, "GL_EXT_framebuffer_object");
|
||||
}
|
||||
|
||||
void OGLInfo_Legacy::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
||||
void OGLContextInfo_Legacy::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
||||
{
|
||||
std::string oglExtensionString = std::string((const char *)glGetString(GL_EXTENSIONS));
|
||||
|
||||
|
@ -4617,7 +4611,7 @@ void OGLInfo_Legacy::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
|||
}
|
||||
}
|
||||
|
||||
bool OGLInfo_Legacy::IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const
|
||||
bool OGLContextInfo_Legacy::IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const
|
||||
{
|
||||
if (oglExtensionSet.size() == 0)
|
||||
{
|
||||
|
@ -4910,6 +4904,7 @@ bool OGLShaderProgram::LinkOGL()
|
|||
|
||||
OGLVideoOutput::OGLVideoOutput()
|
||||
{
|
||||
_contextInfo = NULL;
|
||||
_needUpdateViewport = true;
|
||||
_layerList = new std::vector<OGLVideoLayer *>;
|
||||
_layerList->reserve(8);
|
||||
|
@ -4927,9 +4922,6 @@ OGLVideoOutput::~OGLVideoOutput()
|
|||
delete this->_layerList;
|
||||
this->_layerList = NULL;
|
||||
}
|
||||
|
||||
delete this->_info;
|
||||
this->_info = NULL;
|
||||
}
|
||||
|
||||
void OGLVideoOutput::_UpdateNormalSize()
|
||||
|
@ -4979,15 +4971,14 @@ void OGLVideoOutput::_UpdateViewport()
|
|||
this->_needUpdateViewport = false;
|
||||
}
|
||||
|
||||
OGLInfo* OGLVideoOutput::GetInfo()
|
||||
OGLContextInfo* OGLVideoOutput::GetContextInfo()
|
||||
{
|
||||
return this->_info;
|
||||
return this->_contextInfo;
|
||||
}
|
||||
|
||||
void OGLVideoOutput::Init()
|
||||
{
|
||||
this->_info = OGLInfoCreate_Func();
|
||||
this->_canFilterOnGPU = ( this->_info->IsShaderSupported() && this->_info->IsFBOSupported() );
|
||||
this->_canFilterOnGPU = ( this->_contextInfo->IsShaderSupported() && this->_contextInfo->IsFBOSupported() );
|
||||
this->_filtersPreferGPU = this->_canFilterOnGPU;
|
||||
this->_willFilterOnGPU = false;
|
||||
|
||||
|
@ -5009,7 +5000,7 @@ void OGLVideoOutput::Init()
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// Set up fixed-function pipeline render states.
|
||||
if (!this->_info->IsShaderSupported())
|
||||
if (!this->_contextInfo->IsShaderSupported())
|
||||
{
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -5427,7 +5418,7 @@ GLuint OGLFilterDeposterize::RunFilterOGL(GLuint srcTexID)
|
|||
|
||||
#pragma mark -
|
||||
|
||||
OGLImage::OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GLsizei viewportWidth, GLsizei viewportHeight)
|
||||
OGLImage::OGLImage(OGLContextInfo *contextInfo, GLsizei imageWidth, GLsizei imageHeight, GLsizei viewportWidth, GLsizei viewportHeight)
|
||||
{
|
||||
_needUploadVertices = true;
|
||||
_useDeposterize = false;
|
||||
|
@ -5483,7 +5474,7 @@ OGLImage::OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GL
|
|||
glGenVertexArraysDESMUME(1, &_vaoMainStatesID);
|
||||
glBindVertexArrayDESMUME(_vaoMainStatesID);
|
||||
|
||||
if (oglInfo->IsShaderSupported())
|
||||
if (contextInfo->IsShaderSupported())
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vboVertexID);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_Position, 2, GL_INT, GL_FALSE, 0, 0);
|
||||
|
@ -5508,10 +5499,10 @@ OGLImage::OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GL
|
|||
_isVAOPresent = true;
|
||||
|
||||
_pixelScaler = VideoFilterTypeID_None;
|
||||
_useShader150 = oglInfo->IsUsingShader150();
|
||||
_shaderSupport = oglInfo->GetShaderSupport();
|
||||
_useShader150 = contextInfo->IsUsingShader150();
|
||||
_shaderSupport = contextInfo->GetShaderSupport();
|
||||
|
||||
_canUseShaderOutput = oglInfo->IsShaderSupported();
|
||||
_canUseShaderOutput = contextInfo->IsShaderSupported();
|
||||
if (_canUseShaderOutput)
|
||||
{
|
||||
_finalOutputProgram = new OGLShaderProgram;
|
||||
|
@ -5530,7 +5521,7 @@ OGLImage::OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GL
|
|||
_finalOutputProgram = NULL;
|
||||
}
|
||||
|
||||
_canUseShaderBasedFilters = (oglInfo->IsShaderSupported() && oglInfo->IsFBOSupported());
|
||||
_canUseShaderBasedFilters = (contextInfo->IsShaderSupported() && contextInfo->IsFBOSupported());
|
||||
if (_canUseShaderBasedFilters)
|
||||
{
|
||||
_filterDeposterize = new OGLFilterDeposterize(_vf->GetSrcWidth(), _vf->GetSrcHeight(), _shaderSupport, _useShader150);
|
||||
|
@ -6252,11 +6243,11 @@ OGLHUDLayer::OGLHUDLayer(OGLVideoOutput *oglVO)
|
|||
_glyphSize = 0.0f;
|
||||
_glyphTileSize = 0.0f;
|
||||
|
||||
if (_output->GetInfo()->IsShaderSupported())
|
||||
if (_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
_program = new OGLShaderProgram;
|
||||
_program->SetShaderSupport(oglVO->GetInfo()->GetShaderSupport());
|
||||
_program->SetVertexAndFragmentShaderOGL(HUDOutputVertShader_100, HUDOutputFragShader_110, oglVO->GetInfo()->IsUsingShader150());
|
||||
_program->SetShaderSupport(oglVO->GetContextInfo()->GetShaderSupport());
|
||||
_program->SetVertexAndFragmentShaderOGL(HUDOutputVertShader_100, HUDOutputFragShader_110, oglVO->GetContextInfo()->IsUsingShader150());
|
||||
|
||||
glUseProgram(_program->GetProgramID());
|
||||
_uniformViewSize = glGetUniformLocation(_program->GetProgramID(), "viewSize");
|
||||
|
@ -6301,7 +6292,7 @@ OGLHUDLayer::OGLHUDLayer(OGLVideoOutput *oglVO)
|
|||
glGenVertexArraysDESMUME(1, &_vaoMainStatesID);
|
||||
glBindVertexArrayDESMUME(_vaoMainStatesID);
|
||||
|
||||
if (oglVO->GetInfo()->IsShaderSupported())
|
||||
if (oglVO->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vboVertexID);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_Position, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
|
@ -6329,7 +6320,7 @@ OGLHUDLayer::OGLHUDLayer(OGLVideoOutput *oglVO)
|
|||
|
||||
OGLHUDLayer::~OGLHUDLayer()
|
||||
{
|
||||
if (_output->GetInfo()->IsShaderSupported())
|
||||
if (_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(0);
|
||||
delete this->_program;
|
||||
|
@ -6455,7 +6446,7 @@ void OGLHUDLayer::_UpdateVerticesOGL()
|
|||
|
||||
void OGLHUDLayer::UpdateViewportOGL()
|
||||
{
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_program->GetProgramID());
|
||||
glUniform2f(this->_uniformViewSize, this->_output->GetViewProperties().clientWidth, this->_output->GetViewProperties().clientHeight);
|
||||
|
@ -6492,7 +6483,7 @@ void OGLHUDLayer::RenderOGL()
|
|||
return;
|
||||
}
|
||||
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_program->GetProgramID());
|
||||
}
|
||||
|
@ -6634,7 +6625,7 @@ OGLDisplayLayer::OGLDisplayLayer(OGLVideoOutput *oglVO)
|
|||
glGenVertexArraysDESMUME(1, &this->_vaoMainStatesID);
|
||||
glBindVertexArrayDESMUME(this->_vaoMainStatesID);
|
||||
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vboVertexID);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
@ -6657,9 +6648,9 @@ OGLDisplayLayer::OGLDisplayLayer(OGLVideoOutput *oglVO)
|
|||
|
||||
glBindVertexArrayDESMUME(0);
|
||||
|
||||
_useShader150 = _output->GetInfo()->IsUsingShader150();
|
||||
_shaderSupport = _output->GetInfo()->GetShaderSupport();
|
||||
if (_output->GetInfo()->IsShaderSupported())
|
||||
_useShader150 = _output->GetContextInfo()->IsUsingShader150();
|
||||
_shaderSupport = _output->GetContextInfo()->GetShaderSupport();
|
||||
if (_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
_finalOutputProgram = new OGLShaderProgram;
|
||||
_finalOutputProgram->SetShaderSupport(_shaderSupport);
|
||||
|
@ -6702,7 +6693,7 @@ OGLDisplayLayer::OGLDisplayLayer(OGLVideoOutput *oglVO)
|
|||
|
||||
OGLDisplayLayer::~OGLDisplayLayer()
|
||||
{
|
||||
if (_output->GetInfo()->IsVAOSupported())
|
||||
if (_output->GetContextInfo()->IsVAOSupported())
|
||||
{
|
||||
glDeleteVertexArraysDESMUME(1, &this->_vaoMainStatesID);
|
||||
}
|
||||
|
@ -6721,7 +6712,7 @@ OGLDisplayLayer::~OGLDisplayLayer()
|
|||
glDeleteTextures(1, &this->_texHQ4xLUT);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
if (_output->GetInfo()->IsShaderSupported())
|
||||
if (_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(0);
|
||||
delete this->_finalOutputProgram;
|
||||
|
@ -6906,7 +6897,7 @@ void OGLDisplayLayer::_UpdateRotationScaleOGL()
|
|||
const double r = cdv.rotation;
|
||||
const double s = cdv.viewScale;
|
||||
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUniform1f(this->_uniformFinalOutputAngleDegrees, r);
|
||||
glUniform1f(this->_uniformFinalOutputScalar, s);
|
||||
|
@ -7461,7 +7452,7 @@ void OGLDisplayLayer::UpdateViewportOGL()
|
|||
const double w = cdv.clientWidth;
|
||||
const double h = cdv.clientHeight;
|
||||
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_finalOutputProgram->GetProgramID());
|
||||
glUniform2f(this->_uniformFinalOutputViewSize, w, h);
|
||||
|
@ -7598,7 +7589,7 @@ void OGLDisplayLayer::ProcessOGL()
|
|||
|
||||
void OGLDisplayLayer::RenderOGL()
|
||||
{
|
||||
if (this->_output->GetInfo()->IsShaderSupported())
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_finalOutputProgram->GetProgramID());
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ enum ShaderSupportTier
|
|||
ShaderSupport_FutureTier = 6,
|
||||
};
|
||||
|
||||
class OGLInfo
|
||||
class OGLContextInfo
|
||||
{
|
||||
protected:
|
||||
GLint _versionMajor;
|
||||
|
@ -65,8 +65,8 @@ protected:
|
|||
bool _isFBOSupported;
|
||||
|
||||
public:
|
||||
OGLInfo();
|
||||
virtual ~OGLInfo() {};
|
||||
OGLContextInfo();
|
||||
virtual ~OGLContextInfo() {};
|
||||
|
||||
bool IsUsingShader150();
|
||||
bool IsVBOSupported();
|
||||
|
@ -80,10 +80,10 @@ public:
|
|||
virtual bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const = 0;
|
||||
};
|
||||
|
||||
class OGLInfo_Legacy : public OGLInfo
|
||||
class OGLContextInfo_Legacy : public OGLContextInfo
|
||||
{
|
||||
public:
|
||||
OGLInfo_Legacy();
|
||||
OGLContextInfo_Legacy();
|
||||
|
||||
virtual void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet);
|
||||
virtual bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const;
|
||||
|
@ -229,7 +229,7 @@ protected:
|
|||
|
||||
public:
|
||||
OGLImage() {};
|
||||
OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GLsizei viewportWidth, GLsizei viewportHeight);
|
||||
OGLImage(OGLContextInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GLsizei viewportWidth, GLsizei viewportHeight);
|
||||
virtual ~OGLImage();
|
||||
|
||||
bool GetFiltersPreferGPU();
|
||||
|
@ -388,7 +388,7 @@ public:
|
|||
class OGLVideoOutput : public ClientDisplay3DView
|
||||
{
|
||||
protected:
|
||||
OGLInfo *_info;
|
||||
OGLContextInfo *_contextInfo;
|
||||
GLsizei _viewportWidth;
|
||||
GLsizei _viewportHeight;
|
||||
bool _needUpdateViewport;
|
||||
|
@ -406,7 +406,7 @@ public:
|
|||
OGLVideoOutput();
|
||||
~OGLVideoOutput();
|
||||
|
||||
OGLInfo* GetInfo();
|
||||
OGLContextInfo* GetContextInfo();
|
||||
|
||||
GLsizei GetViewportWidth();
|
||||
GLsizei GetViewportHeight();
|
||||
|
@ -437,9 +437,6 @@ public:
|
|||
virtual void FrameFinish();
|
||||
};
|
||||
|
||||
OGLInfo* OGLInfoCreate_Legacy();
|
||||
|
||||
extern OGLInfo* (*OGLInfoCreate_Func)();
|
||||
extern void (*glBindVertexArrayDESMUME)(GLuint id);
|
||||
extern void (*glDeleteVertexArraysDESMUME)(GLsizei n, const GLuint *ids);
|
||||
extern void (*glGenVertexArraysDESMUME)(GLsizei n, GLuint *ids);
|
||||
|
|
|
@ -23,11 +23,6 @@ enum OGLVertexAttributeID
|
|||
OGLVertexAttributeID_TexCoord0 = 8
|
||||
};
|
||||
|
||||
OGLInfo* OGLInfoCreate_3_2()
|
||||
{
|
||||
return new OGLInfo_3_2;
|
||||
}
|
||||
|
||||
void glBindVertexArray_3_2(GLuint vaoID)
|
||||
{
|
||||
glBindVertexArray(vaoID);
|
||||
|
@ -43,7 +38,7 @@ void glGenVertexArrays_3_2(GLsizei n, GLuint *vaoIDs)
|
|||
glGenVertexArrays(n, vaoIDs);
|
||||
}
|
||||
|
||||
OGLInfo_3_2::OGLInfo_3_2()
|
||||
OGLContextInfo_3_2::OGLContextInfo_3_2()
|
||||
{
|
||||
_useShader150 = true;
|
||||
_isVBOSupported = true;
|
||||
|
@ -70,7 +65,7 @@ OGLInfo_3_2::OGLInfo_3_2()
|
|||
}
|
||||
}
|
||||
|
||||
void OGLInfo_3_2::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
||||
void OGLContextInfo_3_2::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
||||
{
|
||||
GLint extensionCount = 0;
|
||||
|
||||
|
@ -82,7 +77,7 @@ void OGLInfo_3_2::GetExtensionSetOGL(std::set<std::string> *oglExtensionSet)
|
|||
}
|
||||
}
|
||||
|
||||
bool OGLInfo_3_2::IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const
|
||||
bool OGLContextInfo_3_2::IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const
|
||||
{
|
||||
if (oglExtensionSet.size() == 0)
|
||||
{
|
||||
|
|
|
@ -26,15 +26,13 @@
|
|||
|
||||
#include "OGLDisplayOutput.h"
|
||||
|
||||
class OGLInfo_3_2 : public OGLInfo
|
||||
class OGLContextInfo_3_2 : public OGLContextInfo
|
||||
{
|
||||
public:
|
||||
OGLInfo_3_2();
|
||||
OGLContextInfo_3_2();
|
||||
|
||||
virtual void GetExtensionSetOGL(std::set<std::string> *oglExtensionSet);
|
||||
virtual bool IsExtensionPresent(const std::set<std::string> &oglExtensionSet, const std::string &extensionName) const;
|
||||
};
|
||||
|
||||
OGLInfo* OGLInfoCreate_3_2();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -61,6 +61,7 @@ class OGLVideoOutput;
|
|||
@property (assign) NSInteger outputFilter;
|
||||
@property (assign) NSInteger pixelScaler;
|
||||
|
||||
- (void) initContext;
|
||||
- (BOOL) handleKeyPress:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
|
||||
- (BOOL) handleMouseButton:(NSEvent *)theEvent buttonPressed:(BOOL)buttonPressed;
|
||||
- (void) requestScreenshot:(NSURL *)fileURL fileType:(NSBitmapImageFileType)fileType;
|
||||
|
|
|
@ -1261,10 +1261,12 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
[self setMasterWindow:[self window]];
|
||||
[masterWindow setTitle:(NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]];
|
||||
[masterWindow setInitialFirstResponder:view];
|
||||
[view setInputManager:[emuControl inputManager]];
|
||||
[[emuControl windowList] addObject:self];
|
||||
[emuControl updateAllWindowTitles];
|
||||
|
||||
[view initContext];
|
||||
[view setInputManager:[emuControl inputManager]];
|
||||
|
||||
// Set up the scaling factor if this is a Retina window
|
||||
float scaleFactor = 1.0f;
|
||||
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
|
||||
|
@ -1609,11 +1611,6 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
cdsVideoOutput = nil;
|
||||
|
||||
_cdv = new MacOGLDisplayView();
|
||||
_cdv->Init();
|
||||
|
||||
NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"SourceSansPro-Bold" ofType:@"otf"];
|
||||
_cdv->SetHUDFontUsingPath([fontPath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
|
||||
localContext = [[NSOpenGLContext alloc] initWithCGLContextObj:((MacOGLDisplayView *)_cdv)->GetContext()];
|
||||
|
||||
return self;
|
||||
|
@ -1763,6 +1760,16 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
|
|||
return [[self cdsVideoOutput] pixelScaler];
|
||||
}
|
||||
|
||||
#pragma mark Class Methods
|
||||
- (void) initContext
|
||||
{
|
||||
[localContext setView:self];
|
||||
_cdv->Init();
|
||||
|
||||
NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"SourceSansPro-Bold" ofType:@"otf"];
|
||||
_cdv->SetHUDFontUsingPath([fontPath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
}
|
||||
|
||||
#pragma mark InputHIDManagerTarget Protocol
|
||||
- (BOOL) handleHIDQueue:(IOHIDQueueRef)hidQueue hidManager:(InputHIDManager *)hidManager
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ protected:
|
|||
|
||||
public:
|
||||
void operator delete(void *ptr);
|
||||
MacOGLDisplayView();
|
||||
|
||||
virtual void Init();
|
||||
|
||||
|
|
|
@ -21,18 +21,24 @@
|
|||
void MacOGLDisplayView::operator delete(void *ptr)
|
||||
{
|
||||
CGLContextObj context = ((MacOGLDisplayView *)ptr)->GetContext();
|
||||
OGLContextInfo *contextInfo = ((MacOGLDisplayView *)ptr)->GetContextInfo();
|
||||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(context);
|
||||
::operator delete(ptr);
|
||||
CGLSetCurrentContext(prevContext);
|
||||
|
||||
CGLReleaseContext(context);
|
||||
if (context != NULL)
|
||||
{
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(context);
|
||||
::operator delete(ptr);
|
||||
CGLSetCurrentContext(prevContext);
|
||||
|
||||
delete contextInfo;
|
||||
CGLReleaseContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::Init()
|
||||
MacOGLDisplayView::MacOGLDisplayView()
|
||||
{
|
||||
// Initialize the OpenGL context
|
||||
bool useContext_3_2 = false;
|
||||
CGLPixelFormatAttribute attributes[] = {
|
||||
kCGLPFAColorSize, (CGLPixelFormatAttribute)24,
|
||||
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)8,
|
||||
|
@ -42,16 +48,14 @@ void MacOGLDisplayView::Init()
|
|||
(CGLPixelFormatAttribute)0, (CGLPixelFormatAttribute)0,
|
||||
(CGLPixelFormatAttribute)0 };
|
||||
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
|
||||
|
||||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
// If we can support a 3.2 Core Profile context, then request that in our
|
||||
// pixel format attributes.
|
||||
if (IsOSXVersionSupported(10, 7, 0))
|
||||
useContext_3_2 = IsOSXVersionSupported(10, 70, 0);
|
||||
if (useContext_3_2)
|
||||
{
|
||||
attributes[9] = kCGLPFAOpenGLProfile;
|
||||
attributes[10] = (CGLPixelFormatAttribute)kCGLOGLPVersion_3_2_Core;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_3_2;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -63,9 +67,9 @@ void MacOGLDisplayView::Init()
|
|||
{
|
||||
// If we can't get a 3.2 Core Profile context, then switch to using a
|
||||
// legacy context instead.
|
||||
useContext_3_2 = false;
|
||||
attributes[9] = (CGLPixelFormatAttribute)0;
|
||||
attributes[10] = (CGLPixelFormatAttribute)0;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
|
||||
CGLChoosePixelFormat(attributes, &cglPixFormat, &virtualScreenCount);
|
||||
}
|
||||
|
||||
|
@ -74,6 +78,25 @@ void MacOGLDisplayView::Init()
|
|||
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(this->_context);
|
||||
|
||||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
if (useContext_3_2)
|
||||
{
|
||||
this->_contextInfo = new OGLContextInfo_3_2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
this->_contextInfo = new OGLContextInfo_Legacy;
|
||||
}
|
||||
|
||||
CGLSetCurrentContext(prevContext);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::Init()
|
||||
{
|
||||
CGLContextObj prevContext = CGLGetCurrentContext();
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::Init();
|
||||
CGLSetCurrentContext(prevContext);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
isPreviewImageLoaded = false;
|
||||
|
||||
// Initialize the OpenGL context
|
||||
bool useContext_3_2 = false;
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24,
|
||||
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8,
|
||||
|
@ -71,11 +72,11 @@
|
|||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
// If we can support a 3.2 Core Profile context, then request that in our
|
||||
// pixel format attributes.
|
||||
if (IsOSXVersionSupported(10, 7, 0))
|
||||
useContext_3_2 = IsOSXVersionSupported(10, 7, 0);
|
||||
if (useContext_3_2)
|
||||
{
|
||||
attributes[8] = NSOpenGLPFAOpenGLProfile;
|
||||
attributes[9] = NSOpenGLProfileVersion3_2Core;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_3_2;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -84,9 +85,9 @@
|
|||
{
|
||||
// If we can't get a 3.2 Core Profile context, then switch to using a
|
||||
// legacy context instead.
|
||||
useContext_3_2 = false;
|
||||
attributes[8] = (NSOpenGLPixelFormatAttribute)0;
|
||||
attributes[9] = (NSOpenGLPixelFormatAttribute)0;
|
||||
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
|
||||
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
}
|
||||
|
||||
|
@ -103,8 +104,20 @@
|
|||
const NSRect newViewportRect = frameRect;
|
||||
#endif
|
||||
|
||||
OGLInfo *oglInfo = OGLInfoCreate_Func();
|
||||
oglImage = new OGLImage(oglInfo, 64, 64, newViewportRect.size.width, newViewportRect.size.height);
|
||||
OGLContextInfo *contextInfo = NULL;
|
||||
|
||||
#ifdef _OGLDISPLAYOUTPUT_3_2_H_
|
||||
if (useContext_3_2)
|
||||
{
|
||||
contextInfo = new OGLContextInfo_3_2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
contextInfo = new OGLContextInfo_Legacy;
|
||||
}
|
||||
|
||||
oglImage = new OGLImage(contextInfo, 64, 64, newViewportRect.size.width, newViewportRect.size.height);
|
||||
oglImage->SetFiltersPreferGPUOGL(true);
|
||||
oglImage->SetSourceDeposterize(false);
|
||||
oglImage->SetOutputFilterOGL(OutputFilterTypeID_Bilinear);
|
||||
|
|
Loading…
Reference in New Issue