使用 GLUT/FreeGLUT 创建核心上下文?

编程入门 行业动态 更新时间:2024-10-20 03:23:58
本文介绍了使用 GLUT/FreeGLUT 创建核心上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个使用 freeglut 和 GLEW 的项目.为了在我的程序中使用顶点和片段着色器,我需要使用的最低 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 创建核心上下文?

本文发布于:2023-11-17 08:34:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609473.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上下文   核心   GLUT   FreeGLUT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!