OS X OpenGL 3.2不包括glBindFragDataLocation?

时间:2022-12-14 02:41:09

I'm trying to create a simple OpenGL 3.2 core profile application on OS X. I'm using SDL2 via Macports, but I doubt that matters. My understanding is that I should be using GLSL #version 150 and my trivial fragment shader currently looks like this:

我尝试在OS x上创建一个简单的OpenGL 3.2核心概要文件应用程序,我使用的是SDL2,但我怀疑这一点。我的理解是,我应该使用GLSL # 150,我的平凡片段着色器现在看起来是这样的:

#version 150

out vec4 outputF;

void main() {
    outputF = vec4(1.0, 0.0, 0.0, 1.0);
}

Now I believe I need to tell OpenGL that the fragment color is being set in outputF via the glBindFragDataLocation function. The problem is that it doesn't seem to be declared anywhere. Is this function not available in the 3.2 core profile (contrary to my searching), or am I missing a header file, or what?

现在我认为我需要告诉OpenGL,通过glBindFragDataLocation函数在outputF中设置片段颜色。问题是它似乎没有在任何地方声明。这个函数是否在3.2核心配置文件中不可用(与我的搜索相反),或者我丢失了一个头文件,或者什么?

1 个解决方案

#1


4  

If you're on OS X, you include the <OpenGL/gl3.h> header for the GL 3.2 (core) profile. As part of the OpenGL framework, it is to be found in:

如果你在OS X上,包括 标题为GL 3.2(核心)配置文件。作为OpenGL框架的一部分,它将在:

/System/Library/Frameworks/OpenGL.framework/Headers/gl3.h

/系统/图书馆/框架/ OpenGL.framework /头/ gl3.h

If you are writing the fragment to the default framebuffer, you don't need this call. That is, outputF will be bound to the 'color number' (0) by default. IIRC, you can call this out variable anything you please, so long as it doesn't begin with the reserved gl_ prefix.

如果将片段写入默认的framebuffer,则不需要调用这个调用。也就是说,outputF默认将绑定到“color number”(0)。IIRC,你可以把这个变量命名为变量,只要它不以预留的gl_前缀开始。

I'm haven't tried out SDL2 yet - but you might want to add #define GL3_PROTOTYPES first, e.g.,

我还没有尝试SDL2——但是您可能想要先添加#define gl3_原型,例如,

#define GL3_PROTOTYPES

#if defined (__APPLE_CC__)
#include <OpenGL/gl3.h>
#else
#include <GL/glcorearb.h> // assert GL 3.2 core profile available...
#endif

#1


4  

If you're on OS X, you include the <OpenGL/gl3.h> header for the GL 3.2 (core) profile. As part of the OpenGL framework, it is to be found in:

如果你在OS X上,包括 标题为GL 3.2(核心)配置文件。作为OpenGL框架的一部分,它将在:

/System/Library/Frameworks/OpenGL.framework/Headers/gl3.h

/系统/图书馆/框架/ OpenGL.framework /头/ gl3.h

If you are writing the fragment to the default framebuffer, you don't need this call. That is, outputF will be bound to the 'color number' (0) by default. IIRC, you can call this out variable anything you please, so long as it doesn't begin with the reserved gl_ prefix.

如果将片段写入默认的framebuffer,则不需要调用这个调用。也就是说,outputF默认将绑定到“color number”(0)。IIRC,你可以把这个变量命名为变量,只要它不以预留的gl_前缀开始。

I'm haven't tried out SDL2 yet - but you might want to add #define GL3_PROTOTYPES first, e.g.,

我还没有尝试SDL2——但是您可能想要先添加#define gl3_原型,例如,

#define GL3_PROTOTYPES

#if defined (__APPLE_CC__)
#include <OpenGL/gl3.h>
#else
#include <GL/glcorearb.h> // assert GL 3.2 core profile available...
#endif