I am quite new to wxAUI but I find it really amazing and I want to use it in my
applications. I have been trying for a whole day to make it work with a wxGLCanvas but I didn't succeded. Basically I have modified the standard
example with three panes and substituted the central one with a wxGLCanvas.
Then I draw something on the wxGLCanvas, but nothing is shown when I run
the application.
I have read on the forum that others have already used wxGLCanvas, and I woud like to know how they did.
I will put my code below.
- Code: Select all
#include <wx/wx.h>
#include <wx/glcanvas.h>
#include "manager.h"
class MyFrame : public wxFrame {
public:
MyFrame(wxWindow* parent) : wxFrame(parent, -1, _("wxAUI Test"),
wxDefaultPosition, wxSize(800,600),
wxDEFAULT_FRAME_STYLE)
{
// notify wxAUI which frame to use
m_mgr.SetFrame(this);
// create several text controls
wxTextCtrl* text1 = new wxTextCtrl(this, -1, _("Pane 1 - sample text"),
wxDefaultPosition, wxSize(200,150),
wxNO_BORDER | wxTE_MULTILINE);
wxTextCtrl* text2 = new wxTextCtrl(this, -1, _("Pane 2 - sample text"),
wxDefaultPosition, wxSize(200,150),
wxNO_BORDER | wxTE_MULTILINE);
wxGLCanvas* pgl = new wxGLCanvas(this,-1,wxDefaultPosition,wxSize(200,150));
pgl->SetCurrent();
glClearColor(1.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, (GLint)200, (GLint)150);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(-0.5, -0.5, 5);
glVertex3f(-0.5, 0.5, 5);
glVertex3f(0.5, 0.5, -5);
glVertex3f(0.5, -0.5, -5);
glEnd();
glFlush();
pgl->SwapBuffers();
// add the panes to the manager
m_mgr.AddPane(text1, wxLEFT, wxT("Pane Number One"));
m_mgr.AddPane(text2, wxBOTTOM, wxT("Pane Number Two"));
m_mgr.AddPane(pgl, wxCENTER);
// tell the manager to "commit" all the changes just made
m_mgr.Update();
}
~MyFrame()
{
// deinitialize the frame manager
m_mgr.UnInit();
}
private:
wxFrameManager m_mgr;
};
// our normal wxApp-derived class, as usual
class MyApp : public wxApp {
public:
bool OnInit()
{
wxFrame* frame = new MyFrame(NULL);
SetTopWindow(frame);
frame->Show();
return true;
}
};
DECLARE_APP(MyApp);
IMPLEMENT_APP(MyApp);
Thanks,
Lello.