简体   繁体   English

带有LWJGL的Mac OSX El Capitan上的OpenGL 3.3

[英]OpenGL 3.3 on Mac OSX El Capitan with LWJGL

I am currently trying to create an OpenGL 3.3 context in LWJGL 3 on my Macbook Pro mid 2014. My sourcecode to initialize the window looks like this: 我目前正在尝试在2014年中的Macbook Pro上的LWJGL 3中创建OpenGL 3.3上下文。用于初始化窗口的源代码如下:

if (!glfwInit()) {
    Logger.addError("GLFW", "init failed");
}

glfwDefaultWindowHints();

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);           
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_CORE_PROFILE, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

// glfwWindowHint(GLFW_SAMPLES, 2);

ID = glfwCreateWindow(width, height, title, 0, 0);
if (ID == 0) {
    Logger.addError("GLFW", "window creation failed");
}

Sadly GLFW fails to create the window for any version higher than 2.1, the version glGetString(GL_VERSION) returns when leaving out the window hints ... 遗憾的是,GLFW无法为任何高于2.1的版本创建窗口,而glGetString(GL_VERSION)窗口提示时,版本glGetString(GL_VERSION)返回...
I read through all of the "duplicate" questions, but as you can see I already request core profile and forward compatibility. 我通读了所有“重复”问题,但是正如您所看到的,我已经请求核心配置文件和前向兼容性。 Moreover I installed XCode and have the newest version of the operating system. 此外,我安装了XCode并拥有最新版本的操作系统。 Do you guys have any other suggestions or did I understand anything horribly wrong? 你们还有其他建议吗,或者我了解严重错误吗? Thanks in advance... 提前致谢...

Note that there is no "GLFW_OPENGL_PROFILE" flag in LWJGL 3 afaik, so I can't copy the code from the official GLFW getting started page 1:1. 请注意,LWJGL 3 afaik中没有"GLFW_OPENGL_PROFILE"标志,因此我无法从官方GLFW入门第1:1页复制代码。 Setting the "GLFW_OPENGL_CORE_PROFILE" flag to true worked on windows though thus this cant be the error making trouble... "GLFW_OPENGL_CORE_PROFILE"标志设置为true可以在Windows上运行,尽管这不能成为导致麻烦的错误...

The way you are setting the core profile window hint is incorrect. 您设置核心配置文件窗口提示的方式不正确。 Instead use: 而是使用:

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

From the GLFW documentation : GLFW文档中

GLFW_OPENGL_PROFILE specifies which OpenGL profile to create the context for. GLFW_OPENGL_PROFILE指定要为其创建上下文的OpenGL配置文件。 Possible values are one of GLFW_OPENGL_CORE_PROFILE or GLFW_OPENGL_COMPAT_PROFILE , or GLFW_OPENGL_ANY_PROFILE to not request a specific profile. 可能的值是GLFW_OPENGL_CORE_PROFILEGLFW_OPENGL_COMPAT_PROFILEGLFW_OPENGL_ANY_PROFILE以不请求特定的配置文件。 If requesting an OpenGL version below 3.2, GLFW_OPENGL_ANY_PROFILE must be used. 如果请求低于3.2的OpenGL版本, GLFW_OPENGL_ANY_PROFILE必须使用GLFW_OPENGL_ANY_PROFILE If OpenGL ES is requested, this hint is ignored. 如果请求OpenGL ES,则忽略此提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM