Creating OpenGL 4.3 window fails with GLFW3
I set up a minimal application to open a blank window with GLFW3: #include #include #include
void glfwErrorCallback(int error, const { 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 } It results in the following error: GLFW error 65540: Context profiles only exist for OpenGL version 3.2 and above 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的更多相关文章
- CSharpGL(31)[译]OpenGL渲染管道那些事
CSharpGL(31)[译]OpenGL渲染管道那些事 +BIT祝威+悄悄在此留下版了个权的信息说: 开始 自认为对OpenGL的掌握到了一个小瓶颈,现在回头细细地捋一遍OpenGL渲染管道应当是一 ...
- OpenGL 学习笔记 01 环境配置
以下教程仅适用于Mac下的Xcode编程环境!其他的我也不会搞. 推荐教程:opengl-tutorial 本项目Github网址 OpenGL太可怕了...必需得把学的记下来,不然绝壁 ...
- openGL learning
1,basic env in linux : cmake_minimum_required(VERSION 2.8) project(CP_01) set(GLFW_HOME /home/gearsl ...
- OpenGL.Tutorial03_Matrices_测试
1. 2. // ZC: 工程-->右键-->属性--> 配置属性: // ZC: C/C++ -->常规-->附加包含目录,里面添加: // ZC: E:\OpenGL ...
- OpenGL ES之GLFW窗口搭建
概述 本章节主要总结如何使用GLFW来创建Opengl窗口.主要包括如下内容: OpenGl窗口创建介绍 GLFW Window版编译介绍 GLFW简单工程源码介绍 OpenGL窗口创建介绍 能用于O ...
- OpenGL学习--03--矩阵
Model--View--Projection 1.tutorial03.cpp // Include standard headers #include <stdio.h> #inclu ...
- some OpenGL constants
some OpenGL constants This is from (https://github.com/peterderivaz/pyopengles/blob/master/gl2.py) G ...
- 利用JNI技术在Android中调用C++形式的OpenGL ES 2.0函数
1. 打开Eclipse,File-->New-->Project…-->Android-->AndroidApplication Projec ...
- 如何在C++ Builder中使用OpenGL
作者:太乙散数 摘要:用一个简单的例子,阐述了bcb中使用opengl的简单方法,包括初始化框架.旋转和平移图形.清除图像.初始化背景色以及在刷新时保持图像. 关键词:bcb6 opengl 旋转 清 ...
随机推荐
- IAR EWARM 字体设置
如果只想简单的设置,可进行如下设置 Tools->IDE Options->Editor->Colors and Fonts->Editor Font->Font 但是这 ...
- [Go] 反射 - reflect.ValueOf()
类型 和 接口 由于反射是基于类型系统(type system)的,所以先简单了解一下类型系统. 首先 Golang 是一种静态类型的语言,在编译时每一个变量都有一个类型对应,例如:int, floa ...
- Cocos2d-x3.1TestCpp之NewRenderTest Demo分析
1.代码构成 VisibleRect.h VisibleRect.cpp AppDelegate.h AppDelegate.cpp HelloWorldScene.h HelloWorldScene ...
- git 自动转换行符的坑爹案例
本人写的脚本都是在unix上运行的,但是编写有时候喜欢使用Git拉去到windows的ide进行编写,毕竟我的unix只有命令行的没有ide, 殊不知有一天我的sh执行时出现错误 -bash: ./d ...
- 使用jQuery和Bootstrap实现多层、自适应模态窗口
本篇实践一个多层模态窗口,而且是自适应的. 点击页面上的一个按钮,弹出第一层自适应模态窗口. 在第一层模态窗口内包含一个按钮,点击该按钮弹出第二层模态窗口,弹出的第二层模态窗口会挡住第一层模态窗口,即 ...
- javascript中的回调函数(callback)
代码如下: app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; ...
- mysql 筛选重复项(单列或者多列同时重复)
原文:https://blog.csdn.net/luyaran/article/details/80929026 -------------单列----------------------- SEL ...
- sqlite 截取字符串函数substr
函数:substr(string string,num start,num length) 用法: string为字符串: start为起始位置:字符串的第一个字符的位置为1,不是从0开始计算 len ...
- SharePoint 压缩打包文件代码分享
前言 最近碰到这样一个需求,用户需要批量打包下载sharepoint文档库中的文档,所以,就需要开发一个打包下载的服务. 然后,把打包的代码分享给大家,也许会有需要的人. static void Ma ...
- Java生成8位随机邀请码,不重复
public static String[] chars = new String[] { "a", "b", "c", "d&q ...