使用 GLUT/FreeGLUT 创建核心上下文? [英] Create Core context with GLUT/FreeGLUT?

查看:38
本文介绍了使用 GLUT/FreeGLUT 创建核心上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 freeglutGLEW 的项目.为了在我的程序中使用顶点和片段着色器,我需要使用的最低 OpenGL 版本是 3.3.我检查了 OpenGL 版本和 GLSL 版本,this 是结果:

I'm working on a project that utilizes freeglut and GLEW. In order to use the vertex and fragment shaders in my program, the minimum OpenGL version I need to use is 3.3. I have checked the OpenGL version and GLSL version and this is the result:

[cyclonite@localhost ~]$ glxinfo | grep OpenGL 
OpenGL vendor string: Intel Open Source Technology Center 
OpenGL renderer string: Mesa DRI Intel (R) HD Graphics 620 (Kaby Lake GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.3.3 
OpenGL core profile shading language version string: 4.50 
OpenGL core profile context flags: (none) 
OpenGL core profile profile mask: core profile 
OpenGL core profile extensions: 
OpenGL version string: 3.0 mesa 17.3.3 
OpenGL shading language version string: 1.30 
OpenGL context flags: (none) 
OpenGL extensions : 
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 17.3.3 
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20 
OpenGL ES profile extensions:

核心配置文件的 OpenGL 版本字符串和 GLSL 版本字符串都是 4.5.但是,它也显示 OpenGL 版本字符串是 3.0,GLSL 版本字符串是 1.3. 为了使用我自己的着色器,版本必须是 3.3 最小.我尝试在着色器的开头使用 #version 330 core 但是当我运行我的程序时,以下 错误信息出现:

The OpenGL version string as well as GLSL version string for core profile is both 4.5. However, it also shows that OpenGL version string is 3.0 and the GLSL version string is 1.3. In order to use my own shaders, the version has to be 3.3 minimum. I tried to use #version 330 core at the beginning of my shader but when I run my program the following error message appeared:

Cannot compile vertex shader. 
ERROR: Cannot compile shader. 
OpenGL Version: 3.0 Mesa 17.3.3 
0:4(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES 

似乎该程序使用的是 OpenGL 3.0 而不是 4.5,我在网上查了一下,有人说 OpenGL 4.5 只有在创建上下文时才可用,因为不支持兼容性上下文Mesa 的发行说明,根据 这篇文章.

It seems that the program is using OpenGL 3.0 instead of 4.5, I have looked up online and someone said that OpenGL 4.5 is only available if requested at context creation because compatibility contexts are not supported was in the release note of Mesa, according to this post.

如何在创建上下文时创建核心配置文件或请求,以便在我的程序中使用 OpenGL 4.5?

How can I create a core profile or request at context creation so I can use OpenGL 4.5 in my program?

我在 Linux 操作系统上使用 Eclipse 作为我的 C++ 开发 IDE(我使用的这个特定发行版是 PCLinuxOS).

I'm using Eclipse as my C++ development IDE on Linux operating system (This specific distro I'm using is PCLinuxOS).

推荐答案

使用 glutInitContextVersion()glutInitContextProfile() 选择你想要的上下文版本和上下文配置文件:

Use glutInitContextVersion() and glutInitContextProfile() select the context version and context profile you want:

...
glutInit( ... );
glutInitContextVersion( 3, 3 );
glutInitContextProfile( GLUT_CORE_PROFILE );
glutInitDisplayMode( ... );
glutCreateWindow( ... );
...

文档?什么文件?

这篇关于使用 GLUT/FreeGLUT 创建核心上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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