title: wxWidgets painting wxGLCanvas on a wxPanel
body: <p>I am trying to draw my wxGLCanvas in a panel and fill the area of the panel but the result is shown in the image below. I had the OpenGL cube sample running fine but in that example, the wxGLCanvas is parented to a wxFrame. When I try to parent it to a wxPanel, I get a fraction of the panel displaying my wxGLCanvas.</p>
  
  <p><img src="https://i.stack.imgur.com/LT9J7.png" alt="enter image description here"> </p>
  
  <p>The red box should fill the panel in the image.
  Here is the constructor for my window which creates all of the stuff in the image.</p>
  
  <pre><code>wxBEGIN_EVENT_TABLE(MainWindow, wxFrame)
  EVT_MENU(wxID_NEW, MainWindow::OnNewWindow)
  EVT_MENU(wxID_CLOSE, MainWindow::OnClose)
  wxEND_EVENT_TABLE()
  
  MainWindow::MainWindow()
  : wxFrame(NULL, wxID_ANY, wxT("OpenGL Project Test"),
  wxDefaultPosition,wxDefaultSize)
  {
      this-&gt;SetSizeHints( wxDefaultSize, wxDefaultSize );
  
      m_statusBar1 = this-&gt;CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
      m_menubar1 = new wxMenuBar( 0 );
      m_menu1 = new wxMenu();
      m_menubar1-&gt;Append( m_menu1, wxT("MyMenu") ); 
  
      m_menu2 = new wxMenu();
      m_menubar1-&gt;Append( m_menu2, wxT("MyMenu") ); 
  
      m_menu3 = new wxMenu();
      m_menubar1-&gt;Append( m_menu3, wxT("MyMenu") ); 
  
      m_menu4 = new wxMenu();
      m_menubar1-&gt;Append( m_menu4, wxT("MyMenu") ); 
  
      this-&gt;SetMenuBar( m_menubar1 );
  
      m_toolBar4 = this-&gt;CreateToolBar( wxTB_HORIZONTAL, wxID_ANY ); 
      m_tool1 = m_toolBar4-&gt;AddTool( wxID_ANY, wxT("tool"), wxNullBitmap, wxNullBitmap,   wxITEM_NORMAL,  wxEmptyString, wxEmptyString, NULL ); 
  
      m_toolBar4-&gt;Realize(); 
  
      wxBoxSizer* bSizer1;
      bSizer1 = new wxBoxSizer( wxHORIZONTAL );
  
      // ######### Here is where I try to set the panel as a parent of MyGLCanvas ##########
      m_panel2 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,          wxFULL_REPAINT_ON_RESIZE );
      bSizer1-&gt;Add( m_panel2, 1, wxEXPAND | wxALL, 5 );
      MyGLCanvas * glCanvas = new MyGLCanvas(m_panel2);
  
  
      m_ribbonBar2 = new wxRibbonBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRIBBON_BAR_FLOW_VERTICAL );
      m_ribbonBar2-&gt;SetArtProvider(new wxRibbonDefaultArtProvider); 
      m_ribbonPage8 = new wxRibbonPage( m_ribbonBar2, wxID_ANY, wxT("MyRibbonPage") , wxNullBitmap , 0 );
      m_ribbonPage8-&gt;SetMinSize( wxSize( 400,400 ) );
  
      m_ribbonPanel16 = new wxRibbonPanel( m_ribbonPage8, wxID_ANY, wxT("MyRibbonPanel") ,wxBitmap() , wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE );
      m_ribbonButtonBar7 = new wxRibbonButtonBar( m_ribbonPanel16, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
      m_ribbonButtonBar7-&gt;AddButton( wxID_ANY, wxT("MyRibbonButton"), wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonButtonBar7-&gt;AddButton( wxID_ANY, wxT("MyRibbonButton"), wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonButtonBar7-&gt;AddButton( wxID_ANY, wxT("MyRibbonButton"), wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonButtonBar7-&gt;AddButton( wxID_ANY, wxT("MyRibbonButton"), wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonButtonBar7-&gt;AddButton( wxID_ANY, wxT("MyRibbonButton"), wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonButtonBar7-&gt;AddButton( wxID_ANY, wxT("MyRibbonButton"), wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonPanel17 = new wxRibbonPanel( m_ribbonPage8, wxID_ANY, wxT("MyRibbonPanel") , wxNullBitmap , wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE );
      m_ribbonToolBar2 = new wxRibbonToolBar( m_ribbonPanel17, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar2-&gt;AddTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonPanel18 = new wxRibbonPanel( m_ribbonPage8, wxID_ANY, wxT("MyRibbonPanel") , wxNullBitmap , wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE );
      m_ribbonToolBar3 = new wxRibbonToolBar( m_ribbonPanel18, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
      m_ribbonToolBar3-&gt;AddDropdownTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar3-&gt;AddHybridTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar3-&gt;AddHybridTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar3-&gt;AddHybridTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonToolBar3-&gt;AddDropdownTool( wxID_ANY, wxArtProvider::GetBitmap(wxART_QUESTION, wxART_OTHER, wxSize(32, 32)), wxEmptyString);
      m_ribbonBar2-&gt;Realize();
  
      bSizer1-&gt;Add( m_ribbonBar2, 0, wxALL, 5 );
  
  
      this-&gt;SetSizer( bSizer1 );
      this-&gt;Layout();
  
      this-&gt;Centre( wxBOTH );
  
      Show();
  </code></pre>
  
  <p>}</p>
  
  <p>This is the bit thats puzzling me</p>
  
  <pre><code>m_panel2 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE );
  bSizer1-&gt;Add( m_panel2, 1, wxEXPAND | wxALL, 5 );
  MyGLCanvas * glCanvas = new MyGLCanvas(m_panel2);
  </code></pre>