Ok so i added wxPaintDC in my redraw function and once the controls are there they now stay there unless you minimize the window, however they still dont appear right away when the window is first made, does anyone know what is wrong with that? Here is my code:
#include "wx/wx.h" #include "F:\wxWidgets-2.6.2\include\wx\msw\notebook.h" #include "F:\wxWidgets-2.6.2\include\wx\msw\glCanvas.h" #include "glut.h"
//this is the main application and what it does on startup class MyApp: public wxApp { public: virtual bool OnInit(); virtual void OnIdle(wxIdleEvent& event); virtual void OnClose(wxCloseEvent& event); virtual void OnPaint(wxPaintEvent& event); virtual void OnAbout(wxCommandEvent& event); DECLARE_EVENT_TABLE() private: wxFrame *frame; wxGLCanvas *MyGLCanvas; wxPanel *mainpanel; float red; };
//this is where all events are stored for the window BEGIN_EVENT_TABLE(MyApp, wxApp) //EVT_MENU(ID_Quit, MyFrame::OnQuit) //EVT_MENU(ID_About, MyFrame::OnAbout) EVT_BUTTON(2, MyApp::OnAbout) EVT_PAINT(MyApp::OnPaint) EVT_IDLE(MyApp::OnIdle) EVT_CLOSE(MyApp::OnClose) END_EVENT_TABLE()
//this gets the app goign IMPLEMENT_APP(MyApp)
enum { ID_Quit = 1, ID_About,
};
//creates new window bool MyApp::OnInit() { /* frame = new wxFrame((wxWindow *)NULL, 0, "Hello World", wxPoint(50,50), wxSize(450,340) ); frame->Show(TRUE); SetTopWindow(frame); wxPanel *first = new wxPanel(frame, 2, wxPoint(10,10), wxSize(300,300), wxTAB_TRAVERSAL, "Panel1"); wxButton *welcome = new wxButton(first, 2, "Hello Label", wxPoint(75, 100), wxSize(100,25),wxBU_EXACTFIT,wxDefaultValidator, "WelcomeButton"); return TRUE; */ red =0; frame = new wxFrame((wxFrame *)NULL, 1, "Hello GL World"); mainpanel = new wxPanel(frame,1, wxPoint(0,0), wxSize(3000, 100), 0, "Panel1"); wxNotebook *nb = new wxNotebook(mainpanel, 1, wxPoint(50, 50), wxSize(100,100), 0, "NoteBook 1"); MyGLCanvas = new wxGLCanvas(nb, 1, wxPoint(0,100), wxSize(3000,200), wxSUNKEN_BORDER, _("some text")); //MyGLCanvas = new wxGLCanvas(frame, -1, wxPoint(0,100), wxSize(3000,200), wxSUNKEN_BORDER, _("some text")); nb->InsertPage(0, MyGLCanvas, "Page1"); nb->InsertPage(1, MyGLCanvas, "Page2"); nb->InsertPage(2, MyGLCanvas, "Page3"); nb->InsertPage(3, MyGLCanvas, "Page4"); wxButton *trythis = new wxButton(mainpanel, 1, "Translate + 1", wxPoint(10, 10), wxSize(100, 25), 2, wxDefaultValidator, "button1"); frame->Show(TRUE); SetTopWindow(frame); MyGLCanvas->SetCurrent(); //..or try this instead return TRUE; }
void MyApp::OnPaint(wxPaintEvent& event) { wxPaintDC dc(frame); glClearColor(0.0, 0.0, 0.0, 0.0); glViewport(0, 0, (GLint)200, (GLint)200); glColor3f(red, 1.0, 1.0);
glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush();
MyGLCanvas->SwapBuffers(); }
void MyApp::OnIdle(wxIdleEvent& event) { }
void MyApp::OnClose(wxCloseEvent& event) { }
void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event)) { red+=.01; //wxMessageBox("This is a wxWindows Hello world sample", "About Hello World", wxOK | wxICON_INFORMATION, frame); }
|