在OSX Lion上将OpenGL 3.2与Derelict3和GLFW 3一起使用 [英] Using OpenGL 3.2 with Derelict3 and GLFW 3 on OSX Lion

查看:133
本文介绍了在OSX Lion上将OpenGL 3.2与Derelict3和GLFW 3一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having trouble getting OpenGL 3.2 to run on Lion (osx 10.7.4) using Derelict3 and GLFW 3.

这是我的测试程序:

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 .

I've checked, and it seems my graphics card should support up to OpenGL 3.3.

推荐答案

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

All I had to do was specify some window hints before calling 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);

...

这篇关于在OSX Lion上将OpenGL 3.2与Derelict3和GLFW 3一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆