problem with wxGLCanvas

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

problem with wxGLCanvas

Post by gtafan »

My code looks like this:

Code: Select all

GLFrame::GLFrame(wxWindow* parent,wxWindowID id)
{
    
    Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
    int GLCanvasAttributes_1[] = {
    	WX_GL_RGBA,
    	WX_GL_DOUBLEBUFFER,
    	WX_GL_DEPTH_SIZE,      16,
    	WX_GL_STENCIL_SIZE,    0,
    	0, 0 };
    GLCanvas1 = new wxGLCanvas(this, ID_GLCANVAS1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_GLCANVAS1"), GLCanvasAttributes_1);
    BoxSizer1->Add(GLCanvas1, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    SetSizer(BoxSizer1);
    BoxSizer1->Fit(this);
    BoxSizer1->SetSizeHints(this);
}
But when try to compile, geting this error mesage:

undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&, int const*, wxPalette const&)

I cheked the wxwidgets folder and _gl.a file is there, but posibly some other .a file is necesary?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax »

I cheked the wxwidgets folder and _gl.a file is there, but posibly some other .a file is necesary?
The file being there is not enough. Do you also link it to your application?
Use the source, Luke!
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan »

doublemax wrote: Mon Oct 21, 2019 1:49 pm
I cheked the wxwidgets folder and _gl.a file is there, but posibly some other .a file is necesary?
The file being there is not enough. Do you also link it to your application?
OK, you right, it was not linked, but linking it manually doesn´t make it beter, it bekome even worth:

C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglDeleteContext@4'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglGetProcAddress@4'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglGetCurrentDC@0'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglGetProcAddress@4'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglMakeCurrent@8'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglCreateContext@4'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglShareLists@8'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglGetProcAddress@4'|
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax »

These are inside the native Windows OpenGL library. Add Opengl32.lib to the input libraries. (The name is probably libopengl32.a for you).
Use the source, Luke!
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan »

doublemax wrote: Tue Oct 22, 2019 12:11 pm These are inside the native Windows OpenGL library. Add Opengl32.lib to the input libraries. (The name is probably libopengl32.a for you).
OK, thanks it works. Do I also need to add some other .a files if using glu or glut?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax »

gtafan wrote: Thu Oct 24, 2019 10:46 am
doublemax wrote: Tue Oct 22, 2019 12:11 pm These are inside the native Windows OpenGL library. Add Opengl32.lib to the input libraries. (The name is probably libopengl32.a for you).
Do I also need to add some other .a files if using glu or glut?
Only if you need it for your code. AFAIK wxWidgets itself has no dependency to them.
Use the source, Luke!
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan »

doublemax wrote: Thu Oct 24, 2019 11:34 am
gtafan wrote: Thu Oct 24, 2019 10:46 am
doublemax wrote: Tue Oct 22, 2019 12:11 pm These are inside the native Windows OpenGL library. Add Opengl32.lib to the input libraries. (The name is probably libopengl32.a for you).
Do I also need to add some other .a files if using glu or glut?
Only if you need it for your code. AFAIK wxWidgets itself has no dependency to them.
Yes need glut for doblebuffering, unfortunatelly MingW has glut not included.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax »

Yes need glut for doublebuffering...
I'm not an OpenGL expert, but i find that very hard to believe.
Use the source, Luke!
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: problem with wxGLCanvas

Post by Manolo »

As @doublemax told, the "double buffer" feature is provided by the OS, not glut needed. wxWidgtes allows you to set it, please read every class doc from this grup: https://docs.wxwidgets.org/trunk/group_ ... s__gl.html

Some more info in this post: viewtopic.php?f=27&t=45552

Glut is a (old) library providing a basic GUI for its usage with OGL. Don't mix it with wxWidgets or you'll have a hard headache.
Glu (without "t") is another library, not a GUI one, providing some OGL features. Available in all compilers (I think). Can't be used with modern OGL "Core Profile Context" without compatibility flag enabled.
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan »

doublemax wrote: Fri Oct 25, 2019 1:51 pm
Yes need glut for doublebuffering...
I'm not an OpenGL expert, but i find that very hard to believe.
My fault sorry, I meaned using doublebuffering for OpenGL rendering. Normally after all the gl comands in the display func, which is more or less an aqivalent of OnPaint in my WxWidgets application, I am calling glutSwapBuffers. Without glut I can´t call glutSwapBuffers, that what I was tallking about.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax »

gtafan wrote: Mon Oct 28, 2019 1:45 pmWithout glut I can´t call glutSwapBuffers, that what I was tallking about.
wxGLCanvas::SwapBuffers()?
https://docs.wxwidgets.org/trunk/classw ... 92cb3a8a18
Use the source, Luke!
gtafan
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 201
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan »

doublemax wrote: Mon Oct 28, 2019 2:36 pm
gtafan wrote: Mon Oct 28, 2019 1:45 pmWithout glut I can´t call glutSwapBuffers, that what I was tallking about.
wxGLCanvas::SwapBuffers()?
https://docs.wxwidgets.org/trunk/classw ... 92cb3a8a18
OK, thanks.
Post Reply