首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在OSX上使用带有Derelict3和OpenGL 3的GLFW3.2

在OSX上使用带有Derelict3和OpenGL 3的GLFW3.2
EN

Stack Overflow用户
提问于 2012-06-03 18:43:23
回答 3查看 2.2K关注 0票数 3

我在使用Derelict3和GLFW3的Lion (osx10.7.4)上运行OpenGL 3.2时遇到了问题。

下面是我的测试程序:

代码语言:javascript
复制
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)));
}

我得到以下输出:

代码语言:javascript
复制
GLFW:     3.0.0 dynamic
Vendor:   NVIDIA Corporation
Renderer: NVIDIA GeForce 9400M OpenGL Engine
Version:  2.1 NVIDIA-7.18.18
GLSL:     1.20

我检查过了,我的显卡应该是support up to OpenGL 3.3的。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-06-24 16:38:30

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

代码语言:javascript
复制
...

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);

...
票数 5
EN

Stack Overflow用户

发布于 2012-06-17 22:50:21

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

请参阅OpenGL Profiles (Mac OS X v10.7)

Updating an Application to Support the OpenGL 3.2 Core Specification

票数 3
EN

Stack Overflow用户

发布于 2012-06-03 18:50:30

问题不在于显卡,而在于OSX显卡驱动程序。OS X仅支持OpenGL 2.1和OpenGL ES 2。有关详细信息,请咨询this table

票数 -7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10869647

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档