mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
Abstract GSFrameBase class and callback
This commit is contained in:
parent
50b5d72bb2
commit
84c5899faf
7 changed files with 94 additions and 109 deletions
|
@ -1,80 +1,11 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <wx/glcanvas.h>
|
|
||||||
#include "Gui/GLGSFrame.h"
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rPlatform.h"
|
#include "rPlatform.h"
|
||||||
|
|
||||||
rCanvas::rCanvas(void *parent)
|
|
||||||
{
|
|
||||||
handle = static_cast<void*>(new wxGLCanvas(static_cast<wxWindow *>(parent),wxID_ANY,NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
rCanvas::~rCanvas()
|
|
||||||
{
|
|
||||||
delete static_cast<wxGLCanvas*>(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rCanvas::SetCurrent(void *ctx)
|
|
||||||
{
|
|
||||||
return static_cast<wxGLCanvas*>(handle)->SetCurrent(*static_cast<wxGLContext *>(ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rGLFrame::rGLFrame()
|
|
||||||
{
|
|
||||||
handle = static_cast<void*>(new GLGSFrame());
|
|
||||||
}
|
|
||||||
|
|
||||||
rGLFrame::~rGLFrame()
|
|
||||||
{
|
|
||||||
delete static_cast<GLGSFrame*>(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void rGLFrame::Close()
|
|
||||||
{
|
|
||||||
static_cast<GLGSFrame*>(handle)->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rGLFrame::IsShown()
|
|
||||||
{
|
|
||||||
return static_cast<GLGSFrame*>(handle)->IsShown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void rGLFrame::Hide()
|
|
||||||
{
|
|
||||||
static_cast<GLGSFrame*>(handle)->Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void rGLFrame::Show()
|
|
||||||
{
|
|
||||||
static_cast<GLGSFrame*>(handle)->Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void *rGLFrame::GetNewContext()
|
|
||||||
{
|
|
||||||
return static_cast<void *>(new wxGLContext(
|
|
||||||
static_cast<GLGSFrame*>(handle)->GetCanvas()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
void rGLFrame::Flip(void *ctx)
|
|
||||||
{
|
|
||||||
static_cast<GLGSFrame*>(handle)->Flip(
|
|
||||||
static_cast<wxGLContext*>(ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
void rGLFrame::SetCurrent(void *ctx)
|
|
||||||
{
|
|
||||||
static_cast<GLGSFrame*>(handle)->GetCanvas()->SetCurrent(*static_cast<wxGLContext*>(ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rImage::rImage()
|
rImage::rImage()
|
||||||
{
|
{
|
||||||
handle = static_cast<void*>(new wxImage());
|
handle = static_cast<void*>(new wxImage());
|
||||||
|
|
|
@ -2,39 +2,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct rCanvas
|
|
||||||
{
|
|
||||||
rCanvas(void *parent);
|
|
||||||
rCanvas(const rCanvas &) = delete;
|
|
||||||
~rCanvas();
|
|
||||||
/*rGLContext*/void *GetCurrent();
|
|
||||||
bool SetCurrent(/*rGLContext &*/ void *ctx);
|
|
||||||
|
|
||||||
void *handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rGLFrame
|
|
||||||
{
|
|
||||||
rGLFrame();
|
|
||||||
rGLFrame(const rGLFrame &) = delete;
|
|
||||||
~rGLFrame();
|
|
||||||
|
|
||||||
void Close();
|
|
||||||
bool IsShown();
|
|
||||||
void Hide();
|
|
||||||
void Show();
|
|
||||||
|
|
||||||
void *handle;
|
|
||||||
|
|
||||||
void SetCurrent( void *ctx);
|
|
||||||
void *GetNewContext();
|
|
||||||
void Flip(/*rGLContext*/void *ctx);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rPlatform
|
struct rPlatform
|
||||||
{
|
{
|
||||||
rGLFrame *getGLGSFrame();
|
|
||||||
static rPlatform &getPlatform();
|
|
||||||
static std::string getConfigDir();
|
static std::string getConfigDir();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "rpcs3/Ini.h"
|
#include "rpcs3/Ini.h"
|
||||||
|
#include "Utilities/rPlatform.h" // only for rImage
|
||||||
#include "Utilities/Log.h"
|
#include "Utilities/Log.h"
|
||||||
#include "Emu/Memory/Memory.h"
|
#include "Emu/Memory/Memory.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "GLGSRender.h"
|
#include "GLGSRender.h"
|
||||||
|
|
||||||
|
GetGSFrameCb GetGSFrame = nullptr;
|
||||||
|
|
||||||
|
void SetGetGSFrameCallback(GetGSFrameCb value)
|
||||||
|
{
|
||||||
|
GetGSFrame = value;
|
||||||
|
}
|
||||||
|
|
||||||
#define CMD_DEBUG 0
|
#define CMD_DEBUG 0
|
||||||
#define DUMP_VERTEX_DATA 0
|
#define DUMP_VERTEX_DATA 0
|
||||||
|
|
||||||
|
@ -767,13 +775,13 @@ GLGSRender::GLGSRender()
|
||||||
, m_vp_buf_num(-1)
|
, m_vp_buf_num(-1)
|
||||||
, m_context(nullptr)
|
, m_context(nullptr)
|
||||||
{
|
{
|
||||||
m_frame = new rGLFrame();// new GLGSFrame();
|
m_frame = GetGSFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLGSRender::~GLGSRender()
|
GLGSRender::~GLGSRender()
|
||||||
{
|
{
|
||||||
m_frame->Close();
|
m_frame->Close();
|
||||||
// delete m_context; // This won't do anything (deleting void* instead of wglContext*)
|
m_frame->DeleteContext(m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGSRender::Enable(bool enable, const u32 cap)
|
void GLGSRender::Enable(bool enable, const u32 cap)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Emu/RSX/GSRender.h"
|
#include "Emu/RSX/GSRender.h"
|
||||||
#include "Utilities/rPlatform.h"
|
|
||||||
#include "GLBuffers.h"
|
#include "GLBuffers.h"
|
||||||
#include "GLProgramBuffer.h"
|
#include "GLProgramBuffer.h"
|
||||||
|
|
||||||
|
@ -110,6 +109,28 @@ public:
|
||||||
void InitializeLocations();
|
void InitializeLocations();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GSFrameBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GSFrameBase() {}
|
||||||
|
GSFrameBase(const GSFrameBase&) = delete;
|
||||||
|
virtual void Close() = 0;
|
||||||
|
|
||||||
|
virtual bool IsShown() = 0;
|
||||||
|
virtual void Hide() = 0;
|
||||||
|
virtual void Show() = 0;
|
||||||
|
|
||||||
|
virtual void* GetNewContext() = 0;
|
||||||
|
virtual void SetCurrent(void* ctx) = 0;
|
||||||
|
virtual void DeleteContext(void* ctx) = 0;
|
||||||
|
virtual void Flip(void* ctx) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef GSFrameBase*(*GetGSFrameCb)();
|
||||||
|
|
||||||
|
void SetGetGSFrameCallback(GetGSFrameCb value);
|
||||||
|
|
||||||
class GLGSRender //TODO: find out why this used to inherit from wxWindow
|
class GLGSRender //TODO: find out why this used to inherit from wxWindow
|
||||||
: //public wxWindow
|
: //public wxWindow
|
||||||
/*,*/ public GSRender
|
/*,*/ public GSRender
|
||||||
|
@ -136,7 +157,7 @@ private:
|
||||||
void* m_context;
|
void* m_context;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
rGLFrame* m_frame;
|
GSFrameBase* m_frame;
|
||||||
u32 m_draw_frames;
|
u32 m_draw_frames;
|
||||||
u32 m_skip_frames;
|
u32 m_skip_frames;
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,49 @@ GLGSFrame::GLGSFrame()
|
||||||
canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
|
canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGSFrame::Flip(wxGLContext *context)
|
GLGSFrame::~GLGSFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGSFrame::Close()
|
||||||
|
{
|
||||||
|
GSFrame::Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GLGSFrame::IsShown()
|
||||||
|
{
|
||||||
|
return GSFrame::IsShown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGSFrame::Hide()
|
||||||
|
{
|
||||||
|
GSFrame::Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGSFrame::Show()
|
||||||
|
{
|
||||||
|
GSFrame::Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void* GLGSFrame::GetNewContext()
|
||||||
|
{
|
||||||
|
return new wxGLContext(GetCanvas());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGSFrame::SetCurrent(void* ctx)
|
||||||
|
{
|
||||||
|
GetCanvas()->SetCurrent(*(wxGLContext*)ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGSFrame::DeleteContext(void* ctx)
|
||||||
|
{
|
||||||
|
delete (wxGLContext*)ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLGSFrame::Flip(void* context)
|
||||||
{
|
{
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
canvas->SetCurrent(*context);
|
canvas->SetCurrent(*(wxGLContext*)context);
|
||||||
|
|
||||||
static Timer fps_t;
|
static Timer fps_t;
|
||||||
canvas->SwapBuffers();
|
canvas->SwapBuffers();
|
||||||
|
|
|
@ -1,16 +1,26 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "wx/glcanvas.h"
|
#include "wx/glcanvas.h"
|
||||||
#include "Gui/GSFrame.h"
|
#include "Gui/GSFrame.h"
|
||||||
|
#include "Emu/RSX/GL/GLGSRender.h"
|
||||||
|
|
||||||
struct GLGSFrame : public GSFrame
|
struct GLGSFrame : public GSFrame, public GSFrameBase
|
||||||
{
|
{
|
||||||
wxGLCanvas* canvas;
|
wxGLCanvas* canvas;
|
||||||
u32 m_frames;
|
u32 m_frames;
|
||||||
|
|
||||||
GLGSFrame();
|
GLGSFrame();
|
||||||
~GLGSFrame() {}
|
~GLGSFrame();
|
||||||
|
|
||||||
void Flip(wxGLContext *context);
|
virtual void Close() override;
|
||||||
|
|
||||||
|
virtual bool IsShown() override;
|
||||||
|
virtual void Hide() override;
|
||||||
|
virtual void Show() override;
|
||||||
|
|
||||||
|
virtual void* GetNewContext() override;
|
||||||
|
virtual void SetCurrent(void* ctx) override;
|
||||||
|
virtual void DeleteContext(void* ctx) override;
|
||||||
|
virtual void Flip(void* context) override;
|
||||||
|
|
||||||
wxGLCanvas* GetCanvas() const { return canvas; }
|
wxGLCanvas* GetCanvas() const { return canvas; }
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
#include "Emu/Io/XInput/XInputPadHandler.h"
|
#include "Emu/Io/XInput/XInputPadHandler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "Emu/RSX/GL/GLGSRender.h"
|
||||||
|
#include "Gui/GLGSFrame.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <wx/msw/wrapwin.h>
|
#include <wx/msw/wrapwin.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -103,6 +106,10 @@ bool Rpcs3App::OnInit()
|
||||||
return new NullPadHandler();
|
return new NullPadHandler();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
SetGetGSFrameCallback([]() -> GSFrameBase*
|
||||||
|
{
|
||||||
|
return new GLGSFrame();
|
||||||
|
});
|
||||||
|
|
||||||
TheApp = this;
|
TheApp = this;
|
||||||
SetAppName(_PRGNAME_);
|
SetAppName(_PRGNAME_);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue