I set up a minimal application to open a blank window with GLFW3:

#include
<iostream>

#include
<GL/glew.h>

#include
<GLFW/glfw3.h>

 

void glfwErrorCallback(int error, const
char *description)

{

std::cerr << "GLFW error " << error << ": " << description << std::endl;

}

 

int main(int argc, char **argv)

{

GLFWwindow* window;

glfwSetErrorCallback(glfwErrorCallback);

 

if(!glfwInit())

{

std::cerr << "Failed to initialize GLFW...\n";

return -1;

}

 

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

 

window = glfwCreateWindow(1024, 768, "GLFW window", NULL, NULL);

if(!window)

{

std::cerr << "Failed to open GLFW window...\n";

glfwTerminate();

return -1;

}

 

glewExperimental = GL_TRUE;

if (glewInit())

{

std::cerr << "Failed to initialize GLEW...\n";

glfwTerminate();

return -1;

}

 

glfwMakeContextCurrent(window);

 

while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && !glfwWindowShouldClose(window))

{

glfwSwapBuffers(window);

glfwPollEvents();

}

 

glfwTerminate();

return
0;

}

It results in the following error:

GLFW error 65540: Context profiles only exist for OpenGL version 3.2 and above
Failed to open GLFW window...

The application is run on Linux with Bumblebee's optirun. The code works when using freeglut instead of GLFW. What is wrong with the code that results in the error?

 

[解决方法]

This is pretty simple:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // Major = 4

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Major was 4, now it is 3.

 

// Minor = ??? [Something < 2]

You need to use glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3); instead for the second hint.

 

答案来源于: http://stackoverflow.com/questions/21395249/creating-opengl-4-3-window-fails-with-glfw3

 

我的机器是OpenGL4.2, 运行sb7code, 用这个方法也解决了。

Creating OpenGL 4.3 window fails with GLFW3的更多相关文章

  1. CSharpGL(31)[译]OpenGL渲染管道那些事

    CSharpGL(31)[译]OpenGL渲染管道那些事 +BIT祝威+悄悄在此留下版了个权的信息说: 开始 自认为对OpenGL的掌握到了一个小瓶颈,现在回头细细地捋一遍OpenGL渲染管道应当是一 ...

  2. OpenGL 学习笔记 01 环境配置

    以下教程仅适用于Mac下的Xcode编程环境!其他的我也不会搞. 推荐教程:opengl-tutorial  本项目Github网址       OpenGL太可怕了...必需得把学的记下来,不然绝壁 ...

  3. openGL learning

    1,basic env in linux : cmake_minimum_required(VERSION 2.8) project(CP_01) set(GLFW_HOME /home/gearsl ...

  4. OpenGL.Tutorial03_Matrices_测试

    1. 2. // ZC: 工程-->右键-->属性--> 配置属性: // ZC: C/C++ -->常规-->附加包含目录,里面添加: // ZC: E:\OpenGL ...

  5. OpenGL ES之GLFW窗口搭建

    概述 本章节主要总结如何使用GLFW来创建Opengl窗口.主要包括如下内容: OpenGl窗口创建介绍 GLFW Window版编译介绍 GLFW简单工程源码介绍 OpenGL窗口创建介绍 能用于O ...

  6. OpenGL学习--03--矩阵

    Model--View--Projection 1.tutorial03.cpp // Include standard headers #include <stdio.h> #inclu ...

  7. some OpenGL constants

    some OpenGL constants This is from (https://github.com/peterderivaz/pyopengles/blob/master/gl2.py) G ...

  8. 利用JNI技术在Android中调用C++形式的OpenGL ES 2.0函数

    1.                 打开Eclipse,File-->New-->Project…-->Android-->AndroidApplication Projec ...

  9. 如何在C++ Builder中使用OpenGL

    作者:太乙散数 摘要:用一个简单的例子,阐述了bcb中使用opengl的简单方法,包括初始化框架.旋转和平移图形.清除图像.初始化背景色以及在刷新时保持图像. 关键词:bcb6 opengl 旋转 清 ...

随机推荐

  1. js获取鼠标点击事件的相对位置

    <html><head><title>位置</title><script language="javascript" type ...

  2. HDU 4498 Function Curve (自适应simpson)

    Function Curve Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)To ...

  3. ARM Cortex Design Considerations for Debug

    JTAG was the traditional mechanism for debug connections for ARM7/9 parts, but with the Cortex-M fam ...

  4. USB with NXP Microcontrollers

    USB with NXP Microcontrollers NXP Advantages NXP's microcontroller portfolio features the latest USB ...

  5. A brief CRC tutorial

    https://www.kernel.org/doc/Documentation/crc32.txt A brief CRC tutorial. A CRC is a long-division re ...

  6. OAuth2.0网页授权 提示未关注该测试号

    用无高级接口权限的公众号使用别人的appid和appsecret在网页中获取用户信息时,提示未关注该测试号. 搜集各种资料才发现是因为 测试帐号只能对关注者网页授权,正式帐号可以对未关注者授权

  7. Java学习笔记八(反射)

    1.介绍 反射为Java程序在执行时提供了动态的能力.利用反射能够在执行时对程序进行动态的控制.本篇博客着重解说一下Java中的反射. 2.Class类的使用 在Java执行过程中,每一个类被载入后都 ...

  8. 教程:如何手动安装Xamarin与Xamarin for VisualStudio

    [2016/4/17更新:如果你下载后发现仍然需要付费才能编译Android/iOS APP,请到文章最下面更新Xamarin for VS和Xamarin Studio到最新的版本.Build201 ...

  9. delphi版本修改PE头源码

    //VC++6外衣 1 OEPCODEFIVE: THEAD = ($55, $8B, $EC, $6A, $FF, $68, $00, $00, $00, $00, $68, $00, $00, $ ...

  10. C#编程(六十六)----------表达式树总结

    表达式树总结 基础 表达式树提供了一个将可执行代码转换成数据的方法.如果你要在执行代码之前修改或转换此代码,那么它是很有用的.有其是当你要将C#代码----如LINQ查询表达式转换成其他代码在另一个程 ...