Kirix Support Forums

wxGLCanvas and wxAUI under Linux

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

wxGLCanvas and wxAUI under Linux

Postby lello1776 on Sat Oct 14, 2006 1:19 pm

Hi,
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.
lello1776
Registered User
 
Posts: 1
Joined: Sat Oct 14, 2006 1:05 pm
Location: Italy

Postby Ben on Sat Oct 21, 2006 3:10 am

Hi,

This isn't the first time somebody has had problems with wxGLCanvas with wxAUI. I must admit I haven't tried it yet myself. I don't know exactly what the issue is. Thanks for your example code, I'll try it out while preparing for the wxWidgets 2.8 release.

Thanks,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Postby Peek on Mon Oct 30, 2006 4:13 pm

I think the code you're using should work fine under MSW, but Linux GTK+ doesn't create an openGL context until the window is actually shown, so you may need to wait until after your main window gets a wxShowEvent before you can draw. Note that wxShowEvent isn't implemented under MSW, so you won't be able to do the exact same thing if you're targeting both MSW and Linux GTK+. (I don't know if that's the way GTK works under Windows, which is why I refer to 'Linux GTK' and not just GTK). Good luck.
Peek
Registered User
 
Posts: 10
Joined: Thu Mar 30, 2006 12:56 pm

Return to wxAUI Questions, Thoughts & Feedback