Arch Linux 中没有 OpenGL 3 头文件 [英] No OpenGL 3 headers in Arch Linux

查看:19
本文介绍了Arch Linux 中没有 OpenGL 3 头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 FreeGLUT 编译一个非常简单的Hello world"OpenGL 3.3 程序.在我找到的所有教程中,它们都包含一个标题gl3.h".问题是,我没有这样的头文件.

I’m trying to compile a very simple "Hello world" OpenGL 3.3 program using FreeGLUT. In all the tutorials I found, they include an header "gl3.h". The problem is, I don’t have such header file.

$ ls -l /usr/include/GL/
total 2164
-rw-r--r-- 1 root root   8797 20 janv. 17:44 freeglut_ext.h
-rw-r--r-- 1 root root    681 20 janv. 17:44 freeglut.h
-rw-r--r-- 1 root root  26181 20 janv. 17:44 freeglut_std.h
-rw-r--r-- 1 root root 837247 27 janv. 12:55 glew.h
-rw-r--r-- 1 root root 656589 21 mars  18:07 glext.h
-rw-r--r-- 1 root root  84468 21 mars  18:07 gl.h
-rw-r--r-- 1 root root 128943 21 mars  18:07 gl_mangle.h
-rw-r--r-- 1 root root  17255 21 mars  18:07 glu.h
-rw-r--r-- 1 root root   3315 21 mars  18:07 glu_mangle.h
-rw-r--r-- 1 root root    639 20 janv. 17:44 glut.h
-rw-r--r-- 1 root root  62741 27 janv. 12:55 glxew.h
-rw-r--r-- 1 root root  43887 21 mars  18:07 glxext.h
-rw-r--r-- 1 root root  17170 21 mars  18:07 glx.h
-rw-r--r-- 1 root root   4706  3 févr. 13:33 glxint.h
-rw-r--r-- 1 root root   3463 21 mars  18:07 glx_mangle.h
-rw-r--r-- 1 root root   2086  3 févr. 13:33 glxmd.h
-rw-r--r-- 1 root root  80979  3 févr. 13:33 glxproto.h
-rw-r--r-- 1 root root  11246  3 févr. 13:33 glxtokens.h
drwxr-xr-x 2 root root   4096 14 avril 14:03 internal
-rw-r--r-- 1 root root   8497 21 mars  18:07 osmesa.h
-rw-r--r-- 1 root root  51274 21 mars  18:07 vms_x_fix.h
-rw-r--r-- 1 root root  59403 27 janv. 12:55 wglew.h
-rw-r--r-- 1 root root  41377 21 mars  18:07 wglext.h
-rw-r--r-- 1 root root   4468 21 mars  18:07 wmesa.h

/usr/include/ 我只有 GLGLESGLES2.我在一些教程中发现没有 GL3.

In /usr/include/ I only have GL, GLES and GLES2. There is no GL3 as I found in some tutorials.

我使用 NVIDIA 显卡(nvidia 闭源驱动程序)在 Arch Linux x86_64 上运行.

I’m running on Arch Linux x86_64 with a NVIDIA graphic card (nvidia closed-source driver).

以下是我在程序中包含 OpenGL 和 FreeGLUT API 的方式:

Here is how I included OpenGL and FreeGLUT APIs in my program:

#define GL3_PROTOTYPES 1
#include <GL/gl.h>
#include <GL/freeglut.h>

但代码无法编译:

$ g++ -pipe -g -Wall -Wextra -pedantic -I. -IHeaders -c Sources/Main.cpp -o Temp/Objects/Main.o 
Sources/Main.cpp: In function ‘int main(int, char**)’:
Sources/Main.cpp:107:59: error: ‘glVertexAttribPointer’ was not declared in this scope
Sources/Main.cpp:108:30: error: ‘glEnableVertexAttribArray’ was not declared in this scope
Sources/Main.cpp:114:35: error: ‘glUseProgram’ was not declared in this scope
Sources/Main.cpp:138:31: error: ‘glDisableVertexAttribArray’ was not declared in this scope

似乎我包含了 OpenGL 2 头文件!但是,我再次在我的系统上没有找到任何 OpenGL 3 头文件,我查看了 Arch 存储库和 AUR,但没有成功.

It seems I included the OpenGL 2 headers! But, again, I didn’t find any OpenGL 3 headers on my system, I looked at the Arch repository and AUR, unsuccessfully.

感谢您的帮助!

推荐答案

您不需要 GL3.h,GL3.h 刚刚摆脱了所有不推荐使用的功能.所以只包含 gl.h 而不是 gl3.h.下载并手动复制到 /usr/include/GL/ 不是一个真正的解决方案,它可以工作,但是如果将 添加到 mesa 包会发生什么gl3.h?你的包管理器会发现冲突.最好将 gl3.h 添加到项目或主目录中,然后将其添加到 $PATH 或使用 -I 标志.

You don't need a GL3.h, the GL3.h just got rid of all deprecated features. So just include gl.h instead of gl3.h. Downloading and manually copyieng into /usr/include/GL/ is not a real solution, it works yes, but what happens if the add to the mesa package the gl3.h? You're package manager will find conflicts. Better you add the gl3.h to your project or into your home directory and add it to the $PATh or use the -I flag.

这篇关于Arch Linux 中没有 OpenGL 3 头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆