OpenGL学习--01--打开一个窗口
2024-08-24 21:47:14
// Include standard headers
#include <stdio.h>
#include <stdlib.h> // Include GLEW
#include <GL/glew.h> // Include GLFW
#include <glfw3.h>
GLFWwindow* window; // Include GLM
#include <glm/glm.hpp>
using namespace glm; int main( void )
{
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
getchar();
return -;
} glfwWindowHint(GLFW_SAMPLES, );
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, );
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, );
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Open a window and create its OpenGL context
window = glfwCreateWindow( , , "Tutorial 01", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
getchar();
glfwTerminate();
return -;
}
glfwMakeContextCurrent(window); // Initialize GLEW
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
getchar();
glfwTerminate();
return -;
} // Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); // Dark blue background
glClearColor(0.0f, 0.0f, 0.4f, 0.0f); do{
// Clear the screen. It's not mentioned before Tutorial 02, but it can cause flickering, so it's there nonetheless.
glClear( GL_COLOR_BUFFER_BIT ); // Draw nothing, see you in tutorial 2 ! // Swap buffers
glfwSwapBuffers(window);
glfwPollEvents(); } // Check if the ESC key was pressed or the window was closed
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == ); // Close OpenGL window and terminate GLFW
glfwTerminate(); return ;
}
最新文章
- mysql基础用法
- Yii Model中添加默认搜索条件
- c# select标签绑定枚举,并以Description做Text显示
- x square x cube
- vue.js入门(3)——组件通信
- RMI、Hessian、Burlap、Httpinvoker、WebService的比较
- android 单独编译某个模块
- React-Native的基本控件属性方法
- 介绍4款json的java类库 及 其性能测试
- Hadoop学习-HDFS篇
- Spring Boot学习总结二
- JavaScript 作用域、命名空间及闭包
- face recognition[Euclidean-distance-based loss][Center Face]
- Kali proxychains
- sort、sorted高级排序-Python3.7 And 算法<;七>;
- Docker(四)-Dcoker镜像
- css笔记 - 张鑫旭css课程笔记之 float 篇
- CTO详细讲解海量日志处理ELK
- 如何快速将文本中的tab更换成逗号(图文详解)
- <;input>;type类型
热门文章
- 关于editplus设置java和c#
- 【转】如何选择Html.RenderPartial和Html.RenderAction
- 2017年Android百大框架排行榜
- surgemq 添加ssl
- iOS 使用UI控件的外观协议UIAppearance进行设置默认UI控件样式
- android开发学习笔记系列(2)-android应用界面编程
- 转载:哈希加密算法 MD5,SHA-1,SHA-2,SHA-256,SHA-512,SHA-3,RIPEMD-160 - aTool
- java Html 转 PDF
- Java对象的强、软、弱和虚引用+ReferenceQueue
- c#基础学习(0724)之可变参数、ref和out