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

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

问题描述

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

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 is only available if requested at context creation because compatibility contexts are not supportedMesa的发行说明中,根据

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?

我正在使用Eclipse作为Linux操作系统上的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天全站免登陆