Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 我的macbook上的GLSL版本与人们预期的不一样_Macos_Opengl_Glsl - Fatal编程技术网

Macos 我的macbook上的GLSL版本与人们预期的不一样

Macos 我的macbook上的GLSL版本与人们预期的不一样,macos,opengl,glsl,Macos,Opengl,Glsl,我有带Radeon HD6750、MacOS 10.7.5的MacBook pro,我发现它应该支持OpenGL 3.2和GLSL 1.5。不幸的是,当我尝试使用着色器(OpenVDB viewer)构建一个第三方应用程序时,它返回我的硬件不支持#version 130。代码如下: mShader.setVertShader( "#version 130\n "in vec3 vertex;\n" "in vec3 color;\n" "out vec4 f_co

我有带Radeon HD6750、MacOS 10.7.5的MacBook pro,我发现它应该支持OpenGL 3.2和GLSL 1.5。不幸的是,当我尝试使用着色器(OpenVDB viewer)构建一个第三方应用程序时,它返回我的硬件不支持
#version 130
。代码如下:

mShader.setVertShader(
    "#version 130\n
    "in vec3 vertex;\n"
    "in vec3 color;\n"
    "out vec4 f_color;\n"
    "void main() {\n"
    "f_color = vec4(color, 1.0);\n"
    "gl_Position =  gl_ModelViewProjectionMatrix * vec4(vertex, 1.0);}\n");
//check that it is shader and add source
glCompileShader(mVertShader);

char buffer[256];
int l = 0;
glGetShaderInfoLog(mVertShader, 256, &l, buffer);
if(GL_NO_ERROR != glGetError()) throw "Error: Unable to compile vertex shader.";
我安装了OpenGL Extension viewer,它告诉我着色语言版本是1.20,OpenGL版本是2.1(完全支持,3.2中的一些功能可用)。 如果我的硬件能够支持更新的版本,我不想使用GLSL 1.2。
你知道我的驱动程序/硬件有什么问题吗?我如何解决这个问题?

你必须告诉像素格式使用OpenGL 3.2(或核心OpenGL)

编辑:
旁注,我非常确定OpenGL Extension Viewer允许您在某个地方使用核心OpenGL,它将使用OpenGL 3.2。

当您创建正在使用的gl渲染器时,是否?
#版本130
指定着色器用于OpenGL 3.0,如果与其他版本一起使用,将导致错误。您可以将着色器中的版本号修改为150,但仍可能会遇到错误,并且此着色器使用兼容配置文件功能(即
gl\u ModelViewProjectionMatrix
),Mac OS X仅支持OpenGL 3.2核心配置文件。现在,这个着色器没有做太多的高级工作,所以您可以使用1.20版(
#version 120
),但您还需要更改关键字:“in”->“attribute”、“out”->“variang”,这将获得3.2核心概要文件上下文,但OP中的着色器可能仍然无法工作,由于它使用兼容配置文件功能。@radical7 OP想要使用OpenGL 3.2和GLSL 1.5,我只是回答了您如何使用它来代替OpenGL 2.1。您做得很好。(对不起,我不是说它有问题)。相反,OP着色器使用与核心配置文件上下文不兼容的功能。我使用glfw,所以我必须使用glfwOpenWindowHint指定OpenGL版本。唯一的问题是如何处理gl_ModelViewProjectionMatrix。它不受支持。你知道它的替代品吗?你必须使用第三方矩阵库或制作你自己的矩阵库。我用的是GLM,你可以看看。
NSOpenGLPixelFormatAttribute attribute[] = 
{
    NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
    //You can add other attributes here
    0
};

NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribute];
[self setPixelFormat:pixelFormat];