Cocoa Port: Refactor ClientDisplayView to improve subclasses' ease-of-use for the HUD-related methods.
This commit is contained in:
parent
aa8069ce1a
commit
c7af5cbe11
|
@ -79,6 +79,7 @@ void ClientDisplayView::__InstanceInit(const ClientDisplayViewProperties &props)
|
|||
memset(&_emuDisplayInfo, 0, sizeof(_emuDisplayInfo));
|
||||
memset(&_emuFrameInfo, 0, sizeof(_emuFrameInfo));
|
||||
_hudString = "\x01"; // Char value 0x01 will represent the "text box" character, which will always be first in the string.
|
||||
_hudNeedsUpdate = true;
|
||||
|
||||
FT_Error error = FT_Init_FreeType(&_ftLibrary);
|
||||
if (error)
|
||||
|
@ -139,6 +140,7 @@ void ClientDisplayView::_UpdateHUDString()
|
|||
}
|
||||
|
||||
this->_hudString = ss.str();
|
||||
this->_hudNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void ClientDisplayView::_SetHUDShowInfoItem(bool &infoItemFlag, const bool visibleState)
|
||||
|
@ -150,7 +152,6 @@ void ClientDisplayView::_SetHUDShowInfoItem(bool &infoItemFlag, const bool visib
|
|||
|
||||
infoItemFlag = visibleState;
|
||||
this->_UpdateHUDString();
|
||||
this->FrameProcessHUD();
|
||||
}
|
||||
|
||||
void ClientDisplayView::Init()
|
||||
|
@ -187,6 +188,11 @@ void ClientDisplayView::SetScaleFactor(const double scaleFactor)
|
|||
}
|
||||
}
|
||||
|
||||
void ClientDisplayView::_UpdateClientSize()
|
||||
{
|
||||
this->_hudNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void ClientDisplayView::_UpdateViewScale()
|
||||
{
|
||||
double checkWidth = this->_renderProperty.normalWidth;
|
||||
|
@ -253,6 +259,8 @@ void ClientDisplayView::SetupViewProperties()
|
|||
{
|
||||
this->_UpdateClientSize();
|
||||
}
|
||||
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
double ClientDisplayView::GetRotation() const
|
||||
|
@ -393,6 +401,7 @@ bool ClientDisplayView::GetHUDVisibility() const
|
|||
void ClientDisplayView::SetHUDVisibility(const bool visibleState)
|
||||
{
|
||||
this->_isHUDVisible = visibleState;
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::GetHUDShowVideoFPS() const
|
||||
|
@ -403,6 +412,7 @@ bool ClientDisplayView::GetHUDShowVideoFPS() const
|
|||
void ClientDisplayView::SetHUDShowVideoFPS(const bool visibleState)
|
||||
{
|
||||
this->_SetHUDShowInfoItem(this->_showVideoFPS, visibleState);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::GetHUDShowRender3DFPS() const
|
||||
|
@ -413,6 +423,7 @@ bool ClientDisplayView::GetHUDShowRender3DFPS() const
|
|||
void ClientDisplayView::SetHUDShowRender3DFPS(const bool visibleState)
|
||||
{
|
||||
this->_SetHUDShowInfoItem(this->_showRender3DFPS, visibleState);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::GetHUDShowFrameIndex() const
|
||||
|
@ -423,6 +434,7 @@ bool ClientDisplayView::GetHUDShowFrameIndex() const
|
|||
void ClientDisplayView::SetHUDShowFrameIndex(const bool visibleState)
|
||||
{
|
||||
this->_SetHUDShowInfoItem(this->_showFrameIndex, visibleState);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::GetHUDShowLagFrameCount() const
|
||||
|
@ -433,6 +445,7 @@ bool ClientDisplayView::GetHUDShowLagFrameCount() const
|
|||
void ClientDisplayView::SetHUDShowLagFrameCount(const bool visibleState)
|
||||
{
|
||||
this->_SetHUDShowInfoItem(this->_showLagFrameCount, visibleState);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::GetHUDShowCPULoadAverage() const
|
||||
|
@ -443,6 +456,7 @@ bool ClientDisplayView::GetHUDShowCPULoadAverage() const
|
|||
void ClientDisplayView::SetHUDShowCPULoadAverage(const bool visibleState)
|
||||
{
|
||||
this->_SetHUDShowInfoItem(this->_showCPULoadAverage, visibleState);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::GetHUDShowRTC() const
|
||||
|
@ -453,6 +467,17 @@ bool ClientDisplayView::GetHUDShowRTC() const
|
|||
void ClientDisplayView::SetHUDShowRTC(const bool visibleState)
|
||||
{
|
||||
this->_SetHUDShowInfoItem(this->_showRTC, visibleState);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
bool ClientDisplayView::HUDNeedsUpdate() const
|
||||
{
|
||||
return this->_hudNeedsUpdate;
|
||||
}
|
||||
|
||||
void ClientDisplayView::ClearHUDNeedsUpdate()
|
||||
{
|
||||
this->_hudNeedsUpdate = false;
|
||||
}
|
||||
|
||||
// NDS GPU Interface
|
||||
|
@ -501,7 +526,7 @@ void ClientDisplayView::ProcessDisplays()
|
|||
// Do nothing. This is implementation dependent.
|
||||
}
|
||||
|
||||
void ClientDisplayView::FrameProcessHUD()
|
||||
void ClientDisplayView::UpdateView()
|
||||
{
|
||||
// Do nothing. This is implementation dependent.
|
||||
}
|
||||
|
@ -516,6 +541,12 @@ void ClientDisplayView::HandleGPUFrameEndEvent(const NDSDisplayInfo &ndsDisplayI
|
|||
this->_emuDisplayInfo = ndsDisplayInfo;
|
||||
}
|
||||
|
||||
void ClientDisplayView::HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo)
|
||||
{
|
||||
this->SetHUDInfo(frameInfo);
|
||||
this->UpdateView();
|
||||
}
|
||||
|
||||
// Touch screen input handling
|
||||
void ClientDisplayView::GetNDSPoint(const int inputID, const bool isInitialTouchPress,
|
||||
const double clientX, const double clientY,
|
||||
|
@ -945,7 +976,7 @@ void ClientDisplay3DView::SetHUDVertices(float viewportWidth, float viewportHeig
|
|||
vtxBufferPtr[6] = 0.0f; vtxBufferPtr[7] = -textBoxTextOffset;
|
||||
|
||||
// Calculate the vertices of the remaining characters in the string.
|
||||
for (size_t i = 1; i < length; i++)
|
||||
for (size_t i = 1, j = 8; i < length; i++, j+=8)
|
||||
{
|
||||
const char c = cString[i];
|
||||
|
||||
|
@ -966,10 +997,10 @@ void ClientDisplay3DView::SetHUDVertices(float viewportWidth, float viewportHeig
|
|||
|
||||
const float charWidth = this->_glyphInfo[c].width * charSize / (float)this->_glyphTileSize;
|
||||
|
||||
vtxBufferPtr[(i*8)+0] = charLocX; vtxBufferPtr[(i*8)+1] = charLocY + charSize; // Top Left
|
||||
vtxBufferPtr[(i*8)+2] = charLocX + charWidth; vtxBufferPtr[(i*8)+3] = charLocY + charSize; // Top Right
|
||||
vtxBufferPtr[(i*8)+4] = charLocX + charWidth; vtxBufferPtr[(i*8)+5] = charLocY; // Bottom Right
|
||||
vtxBufferPtr[(i*8)+6] = charLocX; vtxBufferPtr[(i*8)+7] = charLocY; // Bottom Left
|
||||
vtxBufferPtr[j+0] = charLocX; vtxBufferPtr[j+1] = charLocY + charSize; // Top Left
|
||||
vtxBufferPtr[j+2] = charLocX + charWidth; vtxBufferPtr[j+3] = charLocY + charSize; // Top Right
|
||||
vtxBufferPtr[j+4] = charLocX + charWidth; vtxBufferPtr[j+5] = charLocY; // Bottom Right
|
||||
vtxBufferPtr[j+6] = charLocX; vtxBufferPtr[j+7] = charLocY; // Bottom Left
|
||||
charLocX += (charWidth + (charSize * 0.03f) + 0.10f);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ protected:
|
|||
NDSDisplayInfo _emuDisplayInfo;
|
||||
NDSFrameInfo _emuFrameInfo;
|
||||
std::string _hudString;
|
||||
bool _hudNeedsUpdate;
|
||||
|
||||
FT_Library _ftLibrary;
|
||||
const char *_lastFontFilePath;
|
||||
|
@ -146,7 +147,7 @@ protected:
|
|||
virtual void _UpdateNormalSize() = 0;
|
||||
virtual void _UpdateOrder() = 0;
|
||||
virtual void _UpdateRotation() = 0;
|
||||
virtual void _UpdateClientSize() = 0;
|
||||
virtual void _UpdateClientSize();
|
||||
virtual void _UpdateViewScale();
|
||||
|
||||
virtual void _LoadNativeDisplayByID(const NDSDisplayID displayID);
|
||||
|
@ -210,18 +211,19 @@ public:
|
|||
virtual void SetHUDShowCPULoadAverage(const bool visibleState);
|
||||
bool GetHUDShowRTC() const;
|
||||
virtual void SetHUDShowRTC(const bool visibleState);
|
||||
bool HUDNeedsUpdate() const;
|
||||
void ClearHUDNeedsUpdate();
|
||||
|
||||
// NDS GPU interface
|
||||
// Client view interface
|
||||
virtual void LoadDisplays();
|
||||
virtual void ProcessDisplays();
|
||||
virtual void FrameProcessHUD();
|
||||
virtual void FrameRender() = 0;
|
||||
virtual void UpdateView();
|
||||
virtual void FrameFinish() = 0;
|
||||
|
||||
// Emulator interface
|
||||
const NDSDisplayInfo& GetEmuDisplayInfo() const;
|
||||
virtual void HandleGPUFrameEndEvent(const NDSDisplayInfo &ndsDisplayInfo);
|
||||
virtual void HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo) = 0;
|
||||
virtual void HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo);
|
||||
|
||||
// Touch screen input handling
|
||||
void GetNDSPoint(const int inputID, const bool isInitialTouchPress,
|
||||
|
@ -274,8 +276,6 @@ public:
|
|||
void SetHUDTextureCoordinates(float *texCoordBufferPtr);
|
||||
void SetScreenVertices(float *vtxBufferPtr);
|
||||
void SetScreenTextureCoordinates(float w0, float h0, float w1, float h1, float *texCoordBufferPtr);
|
||||
|
||||
virtual void UpdateView() = 0;
|
||||
};
|
||||
|
||||
#endif // _CLIENT_DISPLAY_VIEW_H_
|
||||
|
|
|
@ -4856,6 +4856,7 @@ void OGLVideoOutput::_UpdateClientSize()
|
|||
this->_needUpdateViewport = true;
|
||||
|
||||
this->GetHUDLayer()->SetNeedsUpdateVertices();
|
||||
this->ClientDisplay3DView::_UpdateClientSize();
|
||||
}
|
||||
|
||||
void OGLVideoOutput::_UpdateViewScale()
|
||||
|
@ -4874,11 +4875,9 @@ void OGLVideoOutput::_UpdateViewport()
|
|||
|
||||
if (theLayer->IsVisible())
|
||||
{
|
||||
theLayer->UpdateViewportOGL();
|
||||
theLayer->SetNeedsUpdateViewport();
|
||||
}
|
||||
}
|
||||
|
||||
this->_needUpdateViewport = false;
|
||||
}
|
||||
|
||||
void OGLVideoOutput::_LoadNativeDisplayByID(const NDSDisplayID displayID)
|
||||
|
@ -4957,8 +4956,8 @@ void OGLVideoOutput::CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize
|
|||
|
||||
void OGLVideoOutput::SetHUDVisibility(const bool visibleState)
|
||||
{
|
||||
this->ClientDisplay3DView::SetHUDVisibility(visibleState);
|
||||
this->GetHUDLayer()->SetVisibility(visibleState);
|
||||
this->ClientDisplay3DView::SetHUDVisibility(visibleState);
|
||||
}
|
||||
|
||||
void OGLVideoOutput::SetFiltersPreferGPU(const bool preferGPU)
|
||||
|
@ -5011,19 +5010,25 @@ void OGLVideoOutput::ProcessDisplays()
|
|||
}
|
||||
}
|
||||
|
||||
void OGLVideoOutput::FrameProcessHUD()
|
||||
{
|
||||
if (this->GetHUDVisibility())
|
||||
void OGLVideoOutput::FrameFinish()
|
||||
{
|
||||
for (size_t i = 0; i < _layerList->size(); i++)
|
||||
{
|
||||
this->GetHUDLayer()->ProcessOGL();
|
||||
OGLVideoLayer *theLayer = (*_layerList)[i];
|
||||
|
||||
if (theLayer->IsVisible())
|
||||
{
|
||||
theLayer->FinishOGL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OGLVideoOutput::FrameRender()
|
||||
void OGLVideoOutput::RenderViewOGL()
|
||||
{
|
||||
if (this->_needUpdateViewport)
|
||||
{
|
||||
this->_UpdateViewport();
|
||||
this->_needUpdateViewport = false;
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
@ -5039,19 +5044,6 @@ void OGLVideoOutput::FrameRender()
|
|||
}
|
||||
}
|
||||
|
||||
void OGLVideoOutput::FrameFinish()
|
||||
{
|
||||
for (size_t i = 0; i < _layerList->size(); i++)
|
||||
{
|
||||
OGLVideoLayer *theLayer = (*_layerList)[i];
|
||||
|
||||
if (theLayer->IsVisible())
|
||||
{
|
||||
theLayer->FinishOGL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
OGLFilter::OGLFilter()
|
||||
|
@ -6117,6 +6109,11 @@ void OGLImage::RenderOGL()
|
|||
|
||||
#pragma mark -
|
||||
|
||||
void OGLVideoLayer::SetNeedsUpdateViewport()
|
||||
{
|
||||
this->_needUpdateViewport = true;
|
||||
}
|
||||
|
||||
void OGLVideoLayer::SetNeedsUpdateVertices()
|
||||
{
|
||||
this->_needUpdateVertices = true;
|
||||
|
@ -6129,15 +6126,6 @@ bool OGLVideoLayer::IsVisible()
|
|||
|
||||
void OGLVideoLayer::SetVisibility(const bool visibleState)
|
||||
{
|
||||
if (!this->_isVisible && visibleState)
|
||||
{
|
||||
this->_isVisible = visibleState;
|
||||
this->UpdateViewportOGL();
|
||||
this->ProcessOGL();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this->_isVisible = visibleState;
|
||||
}
|
||||
|
||||
|
@ -6145,8 +6133,8 @@ void OGLVideoLayer::SetVisibility(const bool visibleState)
|
|||
|
||||
OGLHUDLayer::OGLHUDLayer(OGLVideoOutput *oglVO)
|
||||
{
|
||||
_needUpdateVertices = true;
|
||||
_isVisible = false;
|
||||
_needUpdateViewport = true;
|
||||
_output = oglVO;
|
||||
|
||||
_glyphInfo = NULL;
|
||||
|
@ -6185,14 +6173,14 @@ OGLHUDLayer::OGLHUDLayer(OGLVideoOutput *oglVO)
|
|||
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(GLshort) * HUD_MAX_CHARACTERS * 6, NULL, GL_STATIC_DRAW_ARB);
|
||||
GLshort *idxBufferPtr = (GLshort *)glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
|
||||
for (size_t i = 0; i < HUD_MAX_CHARACTERS; i++)
|
||||
for (size_t i = 0, j = 0, k = 0; i < HUD_MAX_CHARACTERS; i++, j+=6, k+=4)
|
||||
{
|
||||
idxBufferPtr[(i*6)+0] = (i*4)+0;
|
||||
idxBufferPtr[(i*6)+1] = (i*4)+1;
|
||||
idxBufferPtr[(i*6)+2] = (i*4)+2;
|
||||
idxBufferPtr[(i*6)+3] = (i*4)+2;
|
||||
idxBufferPtr[(i*6)+4] = (i*4)+3;
|
||||
idxBufferPtr[(i*6)+5] = (i*4)+0;
|
||||
idxBufferPtr[j+0] = k+0;
|
||||
idxBufferPtr[j+1] = k+1;
|
||||
idxBufferPtr[j+2] = k+2;
|
||||
idxBufferPtr[j+3] = k+2;
|
||||
idxBufferPtr[j+4] = k+3;
|
||||
idxBufferPtr[j+5] = k+0;
|
||||
}
|
||||
|
||||
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
|
||||
|
@ -6338,51 +6326,25 @@ void OGLHUDLayer::_UpdateVerticesOGL()
|
|||
const size_t length = this->_output->GetHUDString().length();
|
||||
if (length <= 1)
|
||||
{
|
||||
this->_needUpdateVertices = false;
|
||||
this->_output->ClearHUDNeedsUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->_vboVertexID);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, HUD_VERTEX_ATTRIBUTE_BUFFER_SIZE, NULL, GL_STREAM_DRAW_ARB);
|
||||
float *vtxBufferPtr = (float *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
|
||||
this->_output->SetHUDVertices((float)this->_output->GetViewportWidth(), (float)this->_output->GetViewportHeight(), vtxBufferPtr);
|
||||
|
||||
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
this->_needUpdateVertices = false;
|
||||
}
|
||||
|
||||
void OGLHUDLayer::UpdateViewportOGL()
|
||||
{
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_program->GetProgramID());
|
||||
glUniform2f(this->_uniformViewSize, this->_output->GetViewProperties().clientWidth, this->_output->GetViewProperties().clientHeight);
|
||||
}
|
||||
|
||||
this->_needUpdateVertices = true;
|
||||
};
|
||||
|
||||
void OGLHUDLayer::ProcessOGL()
|
||||
{
|
||||
const size_t length = this->_output->GetHUDString().length();
|
||||
if (length <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, this->_vboTexCoordID);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, HUD_VERTEX_ATTRIBUTE_BUFFER_SIZE, NULL, GL_STREAM_DRAW_ARB);
|
||||
float *texCoordBufferPtr = (float *)glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
|
||||
this->_output->SetHUDTextureCoordinates(texCoordBufferPtr);
|
||||
|
||||
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
this->_needUpdateVertices = true;
|
||||
this->_output->ClearHUDNeedsUpdate();
|
||||
}
|
||||
|
||||
void OGLHUDLayer::RenderOGL()
|
||||
|
@ -6396,9 +6358,15 @@ void OGLHUDLayer::RenderOGL()
|
|||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_program->GetProgramID());
|
||||
|
||||
if (this->_needUpdateViewport)
|
||||
{
|
||||
glUniform2f(this->_uniformViewSize, this->_output->GetViewProperties().clientWidth, this->_output->GetViewProperties().clientHeight);
|
||||
this->_needUpdateViewport = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->_needUpdateVertices)
|
||||
if (this->_output->HUDNeedsUpdate())
|
||||
{
|
||||
this->_UpdateVerticesOGL();
|
||||
}
|
||||
|
@ -6438,6 +6406,7 @@ OGLDisplayLayer::OGLDisplayLayer(OGLVideoOutput *oglVO)
|
|||
_isVisible = true;
|
||||
_output = oglVO;
|
||||
_useClientStorage = GL_FALSE;
|
||||
_needUpdateViewport = true;
|
||||
_needUpdateRotationScale = true;
|
||||
_needUpdateVertices = true;
|
||||
|
||||
|
@ -6521,15 +6490,15 @@ OGLDisplayLayer::OGLDisplayLayer(OGLVideoOutput *oglVO)
|
|||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
||||
|
||||
// Set up VAO
|
||||
glGenVertexArraysDESMUME(1, &this->_vaoMainStatesID);
|
||||
glBindVertexArrayDESMUME(this->_vaoMainStatesID);
|
||||
glGenVertexArraysDESMUME(1, &_vaoMainStatesID);
|
||||
glBindVertexArrayDESMUME(_vaoMainStatesID);
|
||||
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vboVertexID);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_Position, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vboTexCoordID);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_TexCoord0, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(OGLVertexAttributeID_TexCoord0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
|
||||
glEnableVertexAttribArray(OGLVertexAttributeID_Position);
|
||||
glEnableVertexAttribArray(OGLVertexAttributeID_TexCoord0);
|
||||
|
@ -7271,26 +7240,6 @@ void OGLDisplayLayer::LoadCustomDisplayByID_OGL(const NDSDisplayID displayID)
|
|||
glFlush();
|
||||
}
|
||||
|
||||
void OGLDisplayLayer::UpdateViewportOGL()
|
||||
{
|
||||
const ClientDisplayViewProperties &cdv = this->_output->GetViewProperties();
|
||||
|
||||
const double w = cdv.clientWidth;
|
||||
const double h = cdv.clientHeight;
|
||||
|
||||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_finalOutputProgram->GetProgramID());
|
||||
glUniform2f(this->_uniformFinalOutputViewSize, w, h);
|
||||
}
|
||||
else
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-w/2.0, -w/2.0 + w, -h/2.0, -h/2.0 + h, -1.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
void OGLDisplayLayer::_ProcessDisplayByID(const NDSDisplayID displayID, GLsizei &inoutWidth, GLsizei &inoutHeight, GLuint &inoutTexID)
|
||||
{
|
||||
const bool willFilterOnGPU = this->_output->WillFilterOnGPU();
|
||||
|
@ -7387,6 +7336,24 @@ void OGLDisplayLayer::RenderOGL()
|
|||
if (this->_output->GetContextInfo()->IsShaderSupported())
|
||||
{
|
||||
glUseProgram(this->_finalOutputProgram->GetProgramID());
|
||||
|
||||
if (this->_needUpdateViewport)
|
||||
{
|
||||
glUniform2f(this->_uniformFinalOutputViewSize, this->_output->GetViewportWidth(), this->_output->GetViewportHeight());
|
||||
this->_needUpdateViewport = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->_needUpdateViewport)
|
||||
{
|
||||
const GLdouble w = this->_output->GetViewportWidth();
|
||||
const GLdouble h = this->_output->GetViewportHeight();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-w/2.0, -w/2.0 + w, -h/2.0, -h/2.0 + h, -1.0, 1.0);
|
||||
|
||||
this->_needUpdateViewport = false;
|
||||
}
|
||||
|
||||
if (this->_needUpdateRotationScale)
|
||||
|
|
|
@ -257,19 +257,19 @@ class OGLVideoLayer
|
|||
protected:
|
||||
OGLVideoOutput *_output;
|
||||
bool _isVisible;
|
||||
bool _needUpdateViewport;
|
||||
bool _needUpdateRotationScale;
|
||||
bool _needUpdateVertices;
|
||||
|
||||
public:
|
||||
virtual ~OGLVideoLayer() {};
|
||||
|
||||
void SetNeedsUpdateViewport();
|
||||
void SetNeedsUpdateVertices();
|
||||
|
||||
virtual bool IsVisible();
|
||||
virtual void SetVisibility(const bool visibleState);
|
||||
|
||||
virtual void UpdateViewportOGL() {};
|
||||
virtual void ProcessOGL() = 0;
|
||||
virtual void RenderOGL() = 0;
|
||||
virtual void FinishOGL() {};
|
||||
};
|
||||
|
@ -299,8 +299,6 @@ public:
|
|||
|
||||
void CopyHUDFont(const FT_Face &fontFace, const size_t glyphSize, const size_t glyphTileSize, GlyphInfo *glyphInfo);
|
||||
|
||||
virtual void UpdateViewportOGL();
|
||||
virtual void ProcessOGL();
|
||||
virtual void RenderOGL();
|
||||
};
|
||||
|
||||
|
@ -378,8 +376,7 @@ public:
|
|||
void LoadNativeDisplayByID_OGL(const NDSDisplayID displayID);
|
||||
void LoadCustomDisplayByID_OGL(const NDSDisplayID displayID);
|
||||
|
||||
virtual void UpdateViewportOGL();
|
||||
virtual void ProcessOGL();
|
||||
void ProcessOGL();
|
||||
virtual void RenderOGL();
|
||||
virtual void FinishOGL();
|
||||
};
|
||||
|
@ -417,6 +414,7 @@ public:
|
|||
|
||||
virtual void Init();
|
||||
|
||||
// NDS screen filters
|
||||
virtual void SetOutputFilter(const OutputFilterTypeID filterID);
|
||||
virtual void SetPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
|
@ -432,10 +430,10 @@ public:
|
|||
const void *customBuffer0, const size_t customWidth0, const size_t customHeight0,
|
||||
const void *customBuffer1, const size_t customWidth1, const size_t customHeight1);
|
||||
|
||||
// Client view interface
|
||||
virtual void ProcessDisplays();
|
||||
virtual void FrameProcessHUD();
|
||||
virtual void FrameRender();
|
||||
virtual void FrameFinish();
|
||||
virtual void RenderViewOGL();
|
||||
};
|
||||
|
||||
extern void (*glBindVertexArrayDESMUME)(GLuint id);
|
||||
|
|
|
@ -72,25 +72,17 @@ public:
|
|||
virtual void SetUseVerticalSync(const bool useVerticalSync);
|
||||
virtual void SetScaleFactor(const double scaleFactor);
|
||||
|
||||
virtual void SetupViewProperties();
|
||||
|
||||
// NDS screen filters
|
||||
virtual void SetFiltersPreferGPU(const bool preferGPU);
|
||||
virtual void SetOutputFilter(const OutputFilterTypeID filterID);
|
||||
virtual void SetPixelScaler(const VideoFilterTypeID filterID);
|
||||
|
||||
virtual void SetHUDVisibility(const bool visibleState);
|
||||
virtual void SetHUDShowVideoFPS(const bool visibleState);
|
||||
virtual void SetHUDShowRender3DFPS(const bool visibleState);
|
||||
virtual void SetHUDShowFrameIndex(const bool visibleState);
|
||||
virtual void SetHUDShowLagFrameCount(const bool visibleState);
|
||||
virtual void SetHUDShowCPULoadAverage(const bool visibleState);
|
||||
virtual void SetHUDShowRTC(const bool visibleState);
|
||||
|
||||
virtual void FrameFinish();
|
||||
virtual void HandleGPUFrameEndEvent(const NDSDisplayInfo &ndsDisplayInfo);
|
||||
virtual void HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo);
|
||||
|
||||
// Client view interface
|
||||
virtual void UpdateView();
|
||||
virtual void FrameFinish();
|
||||
|
||||
// Emulator interface
|
||||
virtual void HandleGPUFrameEndEvent(const NDSDisplayInfo &ndsDisplayInfo);
|
||||
};
|
||||
|
||||
#endif // _MAC_OGLDISPLAYOUTPUT_H_
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
|
||||
- (void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
|
||||
{
|
||||
_cdv->FrameRender();
|
||||
_cdv->RenderViewOGL();
|
||||
[super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp];
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void MacOGLDisplayView::_FrameRenderAndFlush()
|
|||
}
|
||||
else
|
||||
{
|
||||
this->FrameRender();
|
||||
this->RenderViewOGL();
|
||||
CGLFlushDrawable(this->_context);
|
||||
}
|
||||
}
|
||||
|
@ -244,15 +244,6 @@ void MacOGLDisplayView::SetScaleFactor(const double scaleFactor)
|
|||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetupViewProperties()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetupViewProperties();
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetFiltersPreferGPU(const bool preferGPU)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
|
@ -277,65 +268,10 @@ void MacOGLDisplayView::SetPixelScaler(const VideoFilterTypeID filterID)
|
|||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDVisibility(const bool visibleState)
|
||||
void MacOGLDisplayView::UpdateView()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDVisibility(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowVideoFPS(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowVideoFPS(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowRender3DFPS(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowRender3DFPS(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowFrameIndex(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowFrameIndex(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowLagFrameCount(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowLagFrameCount(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowCPULoadAverage(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowCPULoadAverage(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::SetHUDShowRTC(const bool visibleState)
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->OGLVideoOutput::SetHUDShowRTC(visibleState);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
@ -358,22 +294,3 @@ void MacOGLDisplayView::HandleGPUFrameEndEvent(const NDSDisplayInfo &ndsDisplayI
|
|||
this->ProcessDisplays();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::HandleEmulatorFrameEndEvent(const NDSFrameInfo &frameInfo)
|
||||
{
|
||||
this->SetHUDInfo(frameInfo);
|
||||
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->FrameProcessHUD();
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
||||
void MacOGLDisplayView::UpdateView()
|
||||
{
|
||||
CGLLockContext(this->_context);
|
||||
CGLSetCurrentContext(this->_context);
|
||||
this->_FrameRenderAndFlush();
|
||||
CGLUnlockContext(this->_context);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue