Author Topic: OpenGL wxSmith wxAui  (Read 9649 times)

Offline D_A_P

  • Single posting newcomer
  • *
  • Posts: 5
OpenGL wxSmith wxAui
« on: January 04, 2011, 06:48:33 pm »
I need some help, how to draw on wxGLCanvas(GLCanvas1) included as an wxAUI pane, created with code::blocks and wxSmith.

here some code:

Code

void Frame::OnGLCanvas1Paint(wxPaintEvent& event)
{
  wxPaintDC dc(GLCanvas1);

  int w, h;
  GetClientSize(&w, &h);
  if(GLCanvas1->GetContext())   {
        GLCanvas1->SetCurrent();
        glViewport(0, 0, (GLint)w, (GLint)h);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(45.0, (float)w/(float)h, 0.1, 100.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
  }
  else
  {
    return;
  }
  glClearColor(0.0, 0.0, 0.0, 0.0);
  glBegin(GL_POLYGON);
        glColor3f(1.0, 0.0, 0.0);
        glVertex2f(0.1, 0.1);
        glVertex2f(-0.1, 0.1);
        glVertex2f(-0.1, -0.1);
        glVertex2f(0.1, -0.1);
  glEnd();
  glFlush();
  GLCanvas2->SwapBuffers();
}

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: OpenGL wxSmith wxAui
« Reply #1 on: January 04, 2011, 07:17:58 pm »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline D_A_P

  • Single posting newcomer
  • *
  • Posts: 5
Re: OpenGL wxSmith wxAui
« Reply #2 on: January 04, 2011, 07:52:17 pm »

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: OpenGL wxSmith wxAui
« Reply #3 on: January 06, 2011, 09:27:51 pm »
To be honest, I do not have the time to look at your code.
You forgot to tell us one major thing: which version of wxWidgets you are using (2.8.11 or 2.9.x).
This has some importance because the API changed.
You forgot also to tell us what went wrong.

In any case, I attach an example (without wxAUI). It is a NeHe sample, that I have ported to wxWidgets 2.9.x

I am also using a patched version of the wxGLCanvas in wxSmith (due to the aboved mentioned changes in the API). I attach the Code::Blocks plugin to it. It works for me on Windows Vista, with the last nightly.

Good luck !

Sebastien


Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: OpenGL wxSmith wxAui
« Reply #4 on: January 06, 2011, 10:07:08 pm »
The same sample, with wxAUI + wxWidgets 2.9.1


Offline D_A_P

  • Single posting newcomer
  • *
  • Posts: 5
Re: OpenGL wxSmith wxAui
« Reply #5 on: January 06, 2011, 10:47:21 pm »

You forgot to tell us one major thing: which version of wxWidgets you are using (2.8.11 or 2.9.x).
I using version 2.8.11, but I will compile the version 2.9.1.

You forgot also to tell us what went wrong.
I can compile the code, but I can't see anny opengl-window (the pane is white).

Thanks for the NeHe sample, I will test it with the compiled 2.9.1. version of wxwidgets.

Thanks for the wxSmith plugin to.

Holger


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: OpenGL wxSmith wxAui
« Reply #6 on: January 07, 2011, 06:24:53 am »
I am also using a patched version of the wxGLCanvas in wxSmith [...]
What does this patch? Is that relevant generally for C::B?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline D_A_P

  • Single posting newcomer
  • *
  • Posts: 5
Re: OpenGL wxSmith wxAui
« Reply #7 on: January 07, 2011, 02:05:51 pm »
The Nehe Sample works with wxWidgets 2.9.1 very well, thanks.


I am also using a patched version of the wxGLCanvas in wxSmith (due to the aboved mentioned changes in the API). I attach the Code::Blocks plugin to it. It works for me on Windows Vista, with the last nightly.


How can I install the plugin wxGLCanvas to wxSmith?  :D

Can you post me a compiled dll?

Holger

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: OpenGL wxSmith wxAui
« Reply #8 on: January 07, 2011, 10:35:23 pm »
I am also using a patched version of the wxGLCanvas in wxSmith [...]
What does this patch? Is that relevant generally for C::B?

There is a difference in constructors for wxGLCanvas, between wx2.8.11 and wx2.9.1

The patch create a  "#if wxCHECK_VERSION"
example:
Code
#if wxCHECK_VERSION(2, 9, 0)
    GLCanvas1 = new wxGLCanvas(Panel1, ID_GLCANVAS1, GLCanvasAttributes2_1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_GLCANVAS1"));
    #else
    GLCanvas1 = new wxGLCanvas(Panel1, ID_GLCANVAS1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_GLCANVAS1"), GLCanvasAttributes2_1);
    #endif

That's all.
If you do not have the wxCHECK_VERSION, then compilation will fail with wxWidgets 2.9.1
I have posted here a plugin, not a patch: it is a wxSmith component, with the same name "wxGLCanvas"

I discourage to include it yet in the main source tree: it is not fully tested. It was a quick fix I have made for my personal usage. However, there are not a lot of risks to apply a patch: this plugin is mainly a copy of wxSmith files, with a few lines added.

Sebastien

Offline gd_on

  • Lives here!
  • ****
  • Posts: 797
Re: OpenGL wxSmith wxAui
« Reply #9 on: January 18, 2011, 04:20:25 pm »
Hi,
I'm trying to use NeHe and NeHeAUI projects (in the zip files above given by seb_seb0) but I meet some problems with wxwidgets.
I have wxWidgets 2.8.11 version and I work with Win XP SP3. My compiler is gcc 4.5.1, TDM version sjlj. I use a self compiled C::B, svn 6820.
I need some adaptations in the cbp projects but they compile and link.
Problems happens at execution :
The File/Quit menu does nothing, a click on the cross at the right top of the window does nothing too. The only way to stop the program is to kill it with the task manager (or within Code::Blocks with the taskbar stop button). An other (bad) solution, is to add exit(0); after the Close() instruction in onQuit : this works for the Quit menu but not for the standard cross exit icon.
If I click on the menu Help/About, I ear a beep but the message box is not displayed. It appears if I press the Alt key.

So, I tried to install and use wxWidgets 2.9.1, but first I had problems when building the library : I have found through this forum and some others that it seems necessary to add a USE_STC=0 on the make line, and set explicitly wxUSE_STC = 0 in setup.h. But is it all I need to do ?
Obviously not, because the problems are not all solved.
With this new lib, the Quit menu and the cross icon to stop the program now work (without this ugly exit(0);). Nevertheless, the help/About has always the same reaction : program seems to hang (waiting an event ?) unless I press the Alt key.

With NeHeAUI version (but not with NeHe version), I obtain also an error message at Quit, telling me that "GetEventHandler() == this" failed because some event handlers have not been removed.

Probably, my wxWidgets build command is not the right one (for 2.9.1 but may be also for 2.8.11).
I use for 2.8.11 :
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release USE_OPENGL=1
I have tried SHARED=0 to obtain only static libs, (now in gcc_lib sub folders instead of gcc_dll) but this does not really change the behavior of the programs.
for 2.9.1, as told before, I add USE_STC=0.

I can also add that the different samples or wxWidgets examples work normally, and particularly the opengl penguin example, which I want to use as a start base for a future work. So, is it also a problem with wxsmith ?

If someone can give me some more information... (if someone as already adapted the opengl penguin sample to wxsmith ...  :P)

thanks

gd_on

Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: OpenGL wxSmith wxAui
« Reply #10 on: January 18, 2011, 05:11:20 pm »
So, I tried to install and use wxWidgets 2.9.1, but first I had problems when building the library : I have found through this forum and some others that it seems necessary to add a USE_STC=0 on the make line, and set explicitly wxUSE_STC = 0 in setup.h.

The above is needed if you wish to build Code::Blocks from source using wxWidgets 2.9.x as the wxWidgets used inside Code::Blocks. To use wxWidgets with your application you need to build it as needed by your app NOT by what the Code::Blocks app needs.

If you wish to use wxWidgets opengl you need to build wxWidgets with the option enabled.
Like was mentioned in
http://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.8.9_Monolithic_Build_with_openGL_for_Windows


Tim S.
« Last Edit: January 18, 2011, 05:14:46 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline gd_on

  • Lives here!
  • ****
  • Posts: 797
Re: OpenGL wxSmith wxAui
« Reply #11 on: January 18, 2011, 06:06:43 pm »
I know that (and this wiki page too : I think I have correctly followed instructions because wxWidgets opengl specific samples work as expected).
If I don't enter wxUSE_STC=0, wxWidgets 2.9.1 compilation itself fails at link time, when building the library (.a and/or .dll file) : a problem with wxTheAssertHandler.
I have also verified that wxUSE_GLCANVAS is correctly set in setup.h.
The OpenGL window works as expected in NeHe/seb_seb0 examples. It's an other problem with some events not correctly set, I think. Certainly because I do something wrong, but what ?

gd_on
« Last Edit: January 18, 2011, 06:09:36 pm by gd_on »
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: OpenGL wxSmith wxAui
« Reply #12 on: January 18, 2011, 08:41:02 pm »
Opps, my mistake. I really have no idea what to suggest. wxSmith is not really something I use.
I am OK on Compiler/Linker error fixing; but, not the good on wxWidgets runtime issues.

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org