首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用框架中的wxWidgets上下文编写简单的OpenGL应用程序

使用框架中的wxWidgets上下文编写简单的OpenGL应用程序
EN

Stack Overflow用户
提问于 2014-05-29 14:39:01
回答 3查看 3.9K关注 0票数 0

我想知道如何在OpenGL应用程序中使用wxWidgets。为此,我尝试使用来自"OpenGL立方体“示例的代码,该示例来自wxWidgets库示例(wxWidget/主干/ samples /openg-多维数据集)。我在Windows7 CodeBlocks机器上使用x64 13.12。

在用wxWidgets创建了一个新的CodeBlocks 3.0应用程序项目之后,复制了教程中的代码,并添加了带有标题的"GL“文件夹,我得到了许多构建错误(大部分是未定义的引用)。在此之前,我一直在编写简单的wxWidgets应用程序,并使用OpenGL (单独),没有任何重大问题。

首先,我希望看到一个简单的应用程序,它可以在wxWidgets框架内创建GL上下文,并且为了简单起见,只需画一个正方形即可。我认为这比解决我遇到的构建问题所花费的精力要少得多,所以如果有人愿意提供一个简单的示例代码,我会非常高兴。

编辑:

以下是在CodeBlocks中生成失败后的生成消息:

代码语言:javascript
复制
||=== Build: Debug in cubePrimercek (compiler: GNU GCC Compiler) ===|
cube.cpp|37|warning: "wxUSE_GLCANVAS" redefined [enabled by default]|
O:\SourceCode\Libraries\wxWidgets3.0\include\wx\setup.h|1318|note: this is the location of the previous definition|    obj\Debug\cube.o||In function `ZN13TestGLContextC2EP10wxGLCanvas':|
cube.cpp|146|undefined reference to `wxGLContext::wxGLContext(wxGLCanvas*, wxGLContext const*)'|
cube.cpp|148|undefined reference to `wxGLContext::SetCurrent(wxGLCanvas const&) const'|
cube.cpp|146|undefined reference to `wxGLContext::~wxGLContext()'|obj\Debug\cube.o||In function `ZN12TestGLCanvasC2EP8wxWindowPi':|
cube.cpp|338|undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, int const*, wxPoint const&, wxSize const&, long, wxString const&, wxPalette const&)'|
cube.cpp|338|undefined reference to `wxGLCanvas::~wxGLCanvas()'|obj\Debug\cube.o||In function `ZN7MyFrameC2Eb':|
cube.cpp|500|undefined reference to `wxGLCanvasBase::IsDisplaySupported(int const*)'|obj\Debug\cube.o:cube.cpp:(.rdata+0x248)||undefined reference to `wxGLCanvas::sm_eventTable'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x8)||undefined reference to `wxGLCanvas::GetClassInfo() const'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x368)||undefined reference to `wxGLCanvas::SwapBuffers()'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV12TestGLCanvas[__ZTV12TestGLCanvas]+0x370)||undefined reference to `wxGLCanvas::CreateDefaultPalette()'|obj\Debug\cube.o||In function `ZN12TestGLCanvasD1Ev':|
cube.h|66|undefined reference to `wxGLCanvas::~wxGLCanvas()'|
cube.h|66|undefined reference to `wxGLCanvas::~wxGLCanvas()'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV13TestGLContext[__ZTV13TestGLContext]+0x8)||undefined reference to `wxGLContext::GetClassInfo() const'|obj\Debug\cube.o:cube.cpp:(.rdata$_ZTV13TestGLContext[__ZTV13TestGLContext]+0x1c)||undefined reference to `wxGLContext::SetCurrent(wxGLCanvas const&) const'|obj\Debug\cube.o||In function `ZN13TestGLContextD1Ev':|    
cube.h|18|undefined reference to `wxGLContext::~wxGLContext()'|
||=== Build failed: 15 error(s), 1 warning(s) (0 minute(s), 9 second(s)) ===|

我添加了一行(Re)将wxUSE_GLCANVAS定义为1。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-05-30 13:09:34

您需要显式地链接到wxmsw30u[d]_gl.lib,确保它列在项目链接器选项中。

票数 3
EN

Stack Overflow用户

发布于 2014-06-13 15:47:07

不确定这个问题中的CodeBlocks元素,但是如果您的链接命令使用wx检索编译器参数列表,那么您所需要做的就是添加--gl-libs,如下所示:

代码语言:javascript
复制
g++ `wx-config --libs --gl-libs` -lGL -lGLU mycode.o -o myprogram

至少这在UNIX中是可行的,当然在Windows中应该有一种类似的方法。

票数 3
EN

Stack Overflow用户

发布于 2014-05-30 10:17:27

我认为问题在于,为wxWidgets构建的默认二进制文件没有编译iwth opengL支持。

您可能必须使用wxWidgets标志重新构建--with-opengl

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23936012

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档