在 Linux 上设置 OpenGL 以进行 gtkmm 和交叉编译

发布于 2024-08-14 11:25:11 字数 832 浏览 7 评论 0原文

我正在开始学习 OpenGL,但我不确定如何在 (Ubuntu) Linux 上设置它。

我认为这可能是一种方式:

OpenGL只是一种图形语言规范(或接口),要正确使用它,我必须下载一些实现<的库(针对特定操作系统)< OpenGL 规范。

经过长时间的搜索和多种来源的研究,我发现 Mesa 3D 图形库最适合我。

我还找到了 SDL(简单 DirectMedia Layer)库,但它似乎是一个除了图形之外的所有其他东西的库(例如 GUI、声音、键盘和鼠标输入,...)。我只需要一个图形库,这样它就能实现 OpenGL 规范。

作为图形用户界面,我使用 Gtkmm 库,到目前为止我对它“非常满意”,所以我想将 gtkmm 与 OpenGL“连接” - 为此,我找到了一个名为 gtkglextmm 的 gtkmm 库扩展gtkglextmmDrawingArea)(但我还没有尝试过,所以我希望它能工作:- ))。

最后一个问题是从Linux到Windows的交叉编译(使用MinGW交叉编译器)。到目前为止,我已经成功地交叉编译了我使用 Gtkmm 库完成的所有工作(从 Linux 到 Windows)。

当我将它与OpenGL结合起来时,交叉编译它不会有任何问题吗(例如,在使用Gcc编译器编译时我是否需要链接一些特殊的东西,或者我应该在我的应用程序中分发一些Windows OpenGL库)?

如果您确认我正朝着正确的方向前进,或者让我朝着正确的方向前进,我会非常高兴我可以以更简单或更好的方式做一些事情。

I am starting learning OpenGL and I am not sure, how to set it up on (Ubuntu) Linux.

I think that this could be a way:

OpenGL is only a graphics language specification (or interface) and to properly use it I have to download some library (for the specific OS) that implements the OpenGL specification.

After long searching and from multiple sources I found that the Mesa 3D Graphics Library would be the best for me.

I also found the SDL (Simple DirectMedia Layer) library but it seems to be a library for all other things beside graphics (e.g. GUI, sound, keyboard and mouse input, ...). I need ONLY a graphics library, so that it will implement the OpenGL specification.

As a graphical user interface I use the Gtkmm library and I am "very satisfied" with it so far, so I would like to "connect" gtkmm with OpenGL - for that I found an extension to gtkmm library called gtkglextmm by means of which I should be able to draw the OpenGL animation to a window (or DrawingArea in Gtkmm jargon) in GUI (but I have not tried it yet so I hope it will work :-) ).

And the last problem is the cross compilation from Linux to Windows (with the MinGW cross compiler). So far, I have successfully cross compiled (from Linux to Windows) all my work done with the Gtkmm library.

When I combine it with OpenGL, won't it be any problem to cross compile it (e.g. do I need to link something special when compiling with the Gcc compiler, or should I distribute some Windows OpenGL library with my application)?

I would be very pleased I you confirmed that I am in the right direction or turned me in the right direction that I could done something easier or better way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

舟遥客 2024-08-21 11:25:11

在某种程度上,其依赖于显卡,专有驱动程序包包括自己的 libGL.so,还包括 libGL.la(链接到 .so)和任何相关的头文件。

  • Nvidia - OpenGL 库和标头包含在专有驱动程序包中。
  • ATi FGLRX - OpenGL 库和标头包含在专有驱动程序包中。
  • 开源驱动程序 - OpenGL 库和标头作为 Mesa 的一部分提供。根据您的发行版,您可能需要安装 *-devel 软件包来获取您需要的标头和可链接库。

如果您使用的是 Intel 或 Matrox 卡,或者您正在运行带有 rage、radeon 或 radeonhd 驱动程序的 ATi 卡,那么您正在使用开源驱动程序。

GLUT 将是通向工作程序的最短路径。否则,您需要自己编写代码来创建 OpenGL 上下文(特定于操作系统)。

如果您仍然遇到问题,请告诉我们更多关于哪些内容不适合您的信息。

编辑以下是一些可能相关或有用的示例命令/代码。

GCC 编译:

gcc -lGL glprogram.c -o glprogram

包括:

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

To some extent its graphics card dependent, the proprietary driver packs include their own libGL.so and also include the libGL.la (to link against the .so) and any relevant header files.

  • Nvidia - OpenGL libraries and headers are included in the proprietary driver package.
  • ATi FGLRX - OpenGL libraries and headers are included in the proprietary driver package.
  • Open Source Drivers - OpenGL libraries and headers are provided as a part of Mesa. Depending on your distribution you may need to install the *-devel packages to get the headers and linkable libraries you'll need.

If you're using an Intel or Matrox card, or you're running an ATi card with the rage, radeon or radeonhd driver you're using the Open Source drivers.

GLUT will be the shortest path to a working program. Otherwise you'll need to write the code to create the OpenGL context (OS specific) yourself.

If you're still having issues, let us know more about whats not working for you.

EDIT Here's some sample commands/code that might be relevant or useful.

GCC Compiling:

gcc -lGL glprogram.c -o glprogram

Includes:

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
一刻暧昧 2024-08-21 11:25:11

如果有合适的软件包,它应该可以开箱即用。

也就是说,这里是 Build-Depends 的相关块:用于构建 rgl< /a> 包(在 OpenGL 设备上为 R 提供)位于 Debian。由于 Ubuntu 使用相同的设置来构建软件包,因此您应该真正设置:

libgl1-mesa-dev | libgl-dev, libglu1-mesa-dev | libglu-dev, \
libpng12-dev, libx11-dev, libxt-dev, x11proto-core-dev

| 表示替代,因此您可以使用基于台面的软件包或与您的显卡匹配的软件包(例如各种 nvidia-* 软件包)。

只需从某处获取一些 OpenGPl 示例并尝试一下即可。

It should all just work out of the box given the right packages.

That said, here is the relevant chunk of the Build-Depends: used to build the rgl package (which provides on OpenGL device for R) on Debian. As Ubuntu uses the same settings for their build of the package, you should really bet set:

libgl1-mesa-dev | libgl-dev, libglu1-mesa-dev | libglu-dev, \
libpng12-dev, libx11-dev, libxt-dev, x11proto-core-dev

The | means alternative, so you can use the mesa-based packages or ones matching your graphics card (like the various nvidia-* packages).

Just grab some OpenGPl examples from somewhere and try it.

一抹苦笑 2024-08-21 11:25:11

你正朝着正确的方向前进。我使用 Eclipse CDT+ SDL + openGL 在 Ubuntu Linux 下开发我的应用程序(我使用本教程进行设置: http://www.ferdychristant.com/blog/articles/DOMM-72MPPE),然后使用 Dev C++ 在 Windows 下成功编译我的应用程序

You are going right direction. I used Eclipse CDT+ SDL + openGL for developing my app under Ubuntu Linux (I used this tutorial for setup: http://www.ferdychristant.com/blog/articles/DOMM-72MPPE) and then successfully compiled my app under Windows with Dev C++

硪扪都還晓 2024-08-21 11:25:11

我在 Linux 领域没有多大帮助。而且在 OpenGL 方面我已经落后于时代了。然而,看起来 NeHe 有一套新的教程,他们正在将这些教程放在一起一些不错的基本代码。

正如他们在网站上所说:

在编写新教程时,我们有
几个目标:

  • 使用干净、简单且一致的编码标准进行编写
  • 使用现代 C++ 编写
  • 完全保持跨平台(这毕竟是 OpenGL 的优势)
  • 鼓励人们根据我们的基本代码提交自己的课程

所以我强烈建议至少尝试一下他们的代码。 NeHe 有着创建一些非常好的教程的悠久传统。

I'm not of much help in the Linux realm. And I'm behind the times when it comes to OpenGL. However, it looks like NeHe has a new set of tutorials where they're putting together some nice base code.

As they say on the site:

When writing the new tutorials we have
several goals:

  • Write using a clean, simple and consistent coding standard
  • Write using modern C++
  • Remain totally cross-platform (that is OpenGL's strength after all)
  • Inspire people to submit their own lessons based on our basecode

So I'd highly recommend at least giving their code a try. NeHe has a long standing tradition of creating some very nice tutorials.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文