3

我无法使用 Derelict3 和 GLFW 3 在 Lion (osx 10.7.4) 上运行 OpenGL 3.2。

这是我的测试程序:

module glfw3Test;

import std.stdio, std.conv;
import derelict.glfw3.glfw3;
import derelict.opengl3.gl3;

string programName = "glfw3Test";
int width = 640;
int height = 480;

GLFWwindow window;

void main() {
    // load opengl
    DerelictGL3.load();
    // load GLFW
    DerelictGLFW3.load();

    if(!glfwInit()) {
        glfwTerminate();
        throw new Exception("Failed to create glcontext");
    }

    writefln("GLFW:     %s", to!string(glfwGetVersionString()));

    window = glfwOpenWindow(width, height, GLFW_WINDOWED, programName.ptr, null);
    if(!window) {
        glfwTerminate();
        throw new Exception("Failed to create window");
    }

    // Request opengl 3.2 context
    // based off the GLFW FAQ: http://www.glfw.org/faq.html#4_2
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
    glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    DerelictGL3.reload();

    // Print OpenGL and GLSL version
    writefln("Vendor:   %s",   to!string(glGetString(GL_VENDOR)));
    writefln("Renderer: %s",   to!string(glGetString(GL_RENDERER)));
    writefln("Version:  %s",   to!string(glGetString(GL_VERSION)));
    writefln("GLSL:     %s\n", to!string(glGetString(GL_SHADING_LANGUAGE_VERSION)));
}

我得到这个输出:

GLFW:     3.0.0 dynamic
Vendor:   NVIDIA Corporation
Renderer: NVIDIA GeForce 9400M OpenGL Engine
Version:  2.1 NVIDIA-7.18.18
GLSL:     1.20

我已经检查过了,看来我的显卡应该支持 OpenGL 3.3

4

3 回答 3

5

我所要做的就是在调用之前glfwOpenWindow指定一些窗口提示:

...

glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

window = glfwOpenWindow(width, height, GLFW_WINDOWED, programName.ptr, null);

...
于 2012-06-24T08:38:30.477 回答
3

Lion 支持 OpenGL 3.2。您需要在代码中指定 OpenGL 3.2 核心支持

请参阅OpenGL 配置文件 (Mac OS X v10.7)

更新应用程序以支持 OpenGL 3.2 核心规范

于 2012-06-17T14:50:20.707 回答
-7

问题不在于您的显卡,而在于 OSX 视频驱动程序。OS X 仅支持 OpenGL 2.1 和 OpenGL ES 2。您可以查阅此表了解详细信息

于 2012-06-03T10:50:29.700 回答