2015-12-02 17:12:48 +01:00
|
|
|
#include "stdafx.h"
|
2014-08-29 00:49:26 +02:00
|
|
|
#include "stdafx_gui.h"
|
2014-05-02 08:30:32 +02:00
|
|
|
#include "GLGSFrame.h"
|
|
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
GLGSFrame::GLGSFrame() : GSFrame("OpenGL")
|
2014-08-25 00:23:26 +02:00
|
|
|
{
|
2016-03-15 18:07:43 +01:00
|
|
|
const int context_attrs[] =
|
|
|
|
|
{
|
|
|
|
|
WX_GL_RGBA,
|
|
|
|
|
WX_GL_DEPTH_SIZE, 16,
|
|
|
|
|
WX_GL_DOUBLEBUFFER,
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
m_canvas = new wxGLCanvas(this, wxID_ANY, context_attrs);
|
2015-10-05 02:42:48 +02:00
|
|
|
m_canvas->SetSize(GetClientSize());
|
2014-08-25 00:23:26 +02:00
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
m_canvas->Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
|
2014-08-25 00:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
void* GLGSFrame::make_context()
|
2014-08-25 00:23:26 +02:00
|
|
|
{
|
2015-10-05 02:42:48 +02:00
|
|
|
return new wxGLContext(m_canvas);
|
2014-08-25 00:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
void GLGSFrame::set_current(draw_context_t ctx)
|
2014-08-25 00:23:26 +02:00
|
|
|
{
|
2015-10-05 02:42:48 +02:00
|
|
|
m_canvas->SetCurrent(*(wxGLContext*)ctx.get());
|
2014-08-25 00:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
void GLGSFrame::delete_context(void* ctx)
|
2014-08-25 00:23:26 +02:00
|
|
|
{
|
|
|
|
|
delete (wxGLContext*)ctx;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
void GLGSFrame::flip(draw_context_t context)
|
2014-05-02 08:30:32 +02:00
|
|
|
{
|
2015-10-05 02:42:48 +02:00
|
|
|
GSFrame::flip(context);
|
2014-12-21 17:29:51 +01:00
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
if (!m_canvas) return;
|
2014-05-02 08:30:32 +02:00
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
m_canvas->SetCurrent(*(wxGLContext*)context.get());
|
|
|
|
|
m_canvas->SwapBuffers();
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
void GLGSFrame::OnSize(wxSizeEvent& event)
|
|
|
|
|
{
|
2015-10-05 02:42:48 +02:00
|
|
|
if (m_canvas)
|
|
|
|
|
m_canvas->SetSize(GetClientSize());
|
2014-05-02 08:30:32 +02:00
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
event.Skip();
|
2016-01-06 00:52:48 +01:00
|
|
|
}
|