Using OpenGL 3.2 with Derelict3 and GLFW 3 on OSX Lion

£可爱£侵袭症+ 提交于 2019-12-10 19:23:45

问题


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

Here's my test program:

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

I get this output:

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

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


回答1:


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

...



回答2:


Lion supports OpenGL 3.2. You need to specify OpenGL 3.2 core support at your code

See OpenGL Profiles (Mac OS X v10.7)

and Updating an Application to Support the OpenGL 3.2 Core Specification




回答3:


The problem is not with your videocard, but with OSX video drivers. OS X only supports OpenGL 2.1 and OpenGL ES 2. You can consult this table for details



来源:https://stackoverflow.com/questions/10869647/using-opengl-3-2-with-derelict3-and-glfw-3-on-osx-lion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!