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
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

problem with wxGLCanvas

Post by gtafan » Mon Oct 21, 2019 11:22 am

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: 14281
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax » 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?
Use the source, Luke!

gtafan
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan » Tue Oct 22, 2019 10:20 am

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 `[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `wglShare[email protected]'|
C:\wxWidgets-3.0.2\lib\gcc_lib\libwxmsw30u_gl.a(gllib_glcanvas.o):glcanvas.cpp|| undefined reference to `[email protected]'|

User avatar
doublemax
Moderator
Moderator
Posts: 14281
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax » 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).
Use the source, Luke!

gtafan
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan » 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).
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: 14281
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax » 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.
Use the source, Luke!

gtafan
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan » Fri Oct 25, 2019 10:19 am

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: 14281
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax » 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.
Use the source, Luke!

Manolo
Can't get richer than this
Can't get richer than this
Posts: 704
Joined: Mon Apr 30, 2012 11:07 pm

Re: problem with wxGLCanvas

Post by Manolo » Fri Oct 25, 2019 3:41 pm

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
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan » Mon Oct 28, 2019 1:45 pm

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: 14281
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: problem with wxGLCanvas

Post by doublemax » Mon Oct 28, 2019 2:36 pm

gtafan wrote:
Mon Oct 28, 2019 1:45 pm
Without 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
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Wed Mar 29, 2017 9:52 am

Re: problem with wxGLCanvas

Post by gtafan » Tue Oct 29, 2019 11:52 am

doublemax wrote:
Mon Oct 28, 2019 2:36 pm
gtafan wrote:
Mon Oct 28, 2019 1:45 pm
Without 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