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. Java 线程第三版 第四章 Thread Notification 读书笔记

    一.等待与通知 public final void wait() throws InterruptedException      等待条件的发生. public final void wait(lo ...

  2. 内存映射函数remap_pfn_range学习——示例分析(2)

    li {list-style-type:decimal;}ol.wiz-list-level2 > li {list-style-type:lower-latin;}ol.wiz-list-le ...

  3. Unity3D实践系列03,使用Visual Studio编写脚本与调试

    在Unity3D中,只有把脚本赋予Scene中的GameObject,脚本才会得以执行. 添加Camera类型的GameObject. Unity3D默认使用"MonoDevelop&quo ...

  4. Java集合框架顶层接口collectiion接口

    如何使用迭代器 通常情况下,你会希望遍历一个集合中的元素.例如,显示集合中的每个元素. 一般遍历数组都是采用for循环或者增强for,这两个方法也可以用在集合框架,但是还有一种方法是采用迭代器遍历集合 ...

  5. Tomcat 负载均衡 及Session共享

    原文:https://www.sunjianhua.cn/archives/tomcat-high-availability.html 一.安装java环境 二.安装tomcat(apache-tom ...

  6. EBS查询默认应用用户,比如是否需要锁定、修改这些用户

    /* Formatted on 2018/3/15 13:05:39 (QP5 v5.256.13226.35538) */ --查询默认应用用户,比如是否需要锁定.修改这些用户 SELECT ROW ...

  7. c++ #ifdef的用法

    http://www.tuicool.com/articles/mIJnumB #ifdef的用法 灵活使用#ifdef指示符,我们可以区隔一些与特定头文件.程序库和其他文件版本有关的代码.代码举例: ...

  8. python测试开发django-20.添加创建时间DateTimeField

    前言 我们在admin后台发布一篇文章的时候,一般会有创建时间和最后更新时间这2个字段,创建时间就是第一次编辑文章的时候自动添加的,最后更新时间就是每次修改文章的内容后自动更新 在models.py建 ...

  9. SpringBoot下的Job定时任务

    编写Job定时执行任务十分有用,能解决很多问题,这次实习的项目里做了一下系统定时更新三方系统订单状态的功能,这里用到了Spring的定时任务使用的非常方便,下面总结一下如何使用: 一,@schedul ...

  10. Windows下LuaJIT的编译和使用

    1.下载LuaJIT,download>> 2.编译 开始 –> 程序 –> Microsoft Visual Studio xx –> Visual Studio To ...