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. HDU 4815 Little Tiger vs. Deep Monkey(2013长春现场赛C题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4815 简单的DP题. #include <stdio.h> #include <st ...

  2. 【图像处理】基于OpenCV底层实现的直方图匹配

    image processing 系列: [图像处理]图片旋转 [图像处理]高斯滤波.中值滤波.均值滤波 直方图匹配算法.又称直方图规定化.简单说.就是依据某函数.或者另外一张图片的引导,使得原图改变 ...

  3. STM32的PWM输入模式设置并用DMA接收数据

    参考 :STM32输入捕获模式设置并用DMA接收数据 PWM input mode This mode is a particular case of input capture mode. The ...

  4. 《Go语言实战》摘录:6.5 并发 - 通道

    6.5 通道

  5. C - 项目收藏

    Web框架 [荐]Kore:开源 C 语言 Web 框架 Raphters:A web framework for C ulfius:Web Framework for REST API in C, ...

  6. 《Go学习笔记 . 雨痕》类型

    一.基本类型 清晰完备的预定义基础类型,使得开发跨平台应用时无须过多考虑符合和长度差异. 类型 长度 默认值 说明 bool 1 false   byte 1 0 uint8 int, uint 4, ...

  7. 查询并发程序是否启动跟踪功能-trc文件对数据库性能有影响

    /* Formatted on 2018/3/14 23:38:51 (QP5 v5.256.13226.35538) */ SELECT icon_name , row_id , user_conc ...

  8. 无线通信中FEC 编码原理及评价

    转自:http://blog.csdn.net/wiznet2012/article/details/7492146 大家好,前面我们给大家介绍了无线通信中FEC编码原理(1)和(2),今天继续献上F ...

  9. Golang 使用Map构建Set类型的实现方法

    前言 本篇主要给大家讲述了如何利用Go语言的语法特性实现Set类型的数据结构,分享出来供大家参考学习,话不多说了,来一起看看详细的介绍吧. 需求 对于Set类型的数据结构,其实本质上跟List没什么多 ...

  10. Android在Gallery中每次滑动只显示一页

    import android.content.Context; import android.util.AttributeSet; import android.view.KeyEvent; impo ...