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 旋转 清 ...
随机推荐
- WebClient 通过get和post请求api
//get 请求 string url = string.Format("http://localhost:28450/api/values?str1=a&str2=b ...
- systemtap 调试postgrel
http://blog.163.com/digoal@126/blog/static/16387704020137140265557/ dtrace http://blog.163.com/dig ...
- datagrid在MVC中的运用01-基本属性并实现分页
本文体验jQuery EasyUI的datagrid在MVC中的应用.主要涉及到: ※ datagrid的基本属性和方法 ※ datagrid分页在前后台的实现 最终效果: 与视图显示对应的view ...
- 关于电商ERP的想法
原文地址: http://www.chinaodoo.net/thread-465-1-1.html 试用了下odoo的淘宝订单处理模块,从整个业务流程上已经打通,如果要求不是很高的话,现有的功能基本 ...
- iOS webservice 接口使用方法
1.没有参数的webservice 接口,如下: 接口名:获取服务器时间 方法名: getServerTime() 参数:空 返回值:服务器当前时间: yyyy/MM/dd HH:mm:ss 使用方法 ...
- 【IntelliJ IDEA】idea或者JetBrains公司所有编辑器,设置其软件的字体样式
操作如下: 修改完成后的效果: 可以看到修改以后的ide的效果:
- 自定义兼容多种Protobuf协议的编解码器
<从零开始搭建游戏服务器>自定义兼容多种Protobuf协议的编解码器 直接在protobuf序列化数据的前面,加上一个自定义的协议头,协议头里包含序列数据的长度和对应的数据类型,在数据解 ...
- mysql处理特殊字符
修改表 alter table USER convert to charset utf8mb4, character set utf8mb4; 修改列 ALTER TABLE USER DEFAULT ...
- CCLabelAtlas的宽度为奇数时的显示bug
遇到一个很郁闷的bug,CCLabelAtlas设置文字内容在ipad上和android上正常,就只有iphone怎么显示都不正常.后来把它宽度 + 1,然后就正常了.发现以前宽度设置为21px.23 ...
- 图片通过Base64Coder编码、解码
通过这个编码类我们可以将图片转换为这个编码的字符串,上传到服务器. 这个编码是来自小马的一个范例,我看了下挺有用的.所以就放上来以备不时之需. 先说下用法: /** * 下面注释的方法是将裁剪之后的图 ...