opengl helloworld vscode 调用glfw 绘制三角形


打开 glfw.org, 我下的64


目录构成如下 include 和lib-mingw 提出来:


ctrl + shift + p 打开编辑配置

{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/depends/include" //include path
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "I:\\VSProject\\MinGW32\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x64" // x86
}
],
"version": 4
}

tasks.json

{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "I:\\VSProject\\MinGW32\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"${fileDirname}\\depends\\lib-mingw-w64\\libglfw3.a",
"-lopengl32", //
"-lgdi32", // 这两依赖也要带上,否则 undefined xxx
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"--include-directory=${fileDirname}\\depends\\include"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}

跳至 Documentation ctrl v 样例


编写主函数F5运行

#include <GLFW/glfw3.h>

int main(void)
{
GLFWwindow* window; /* Initialize the library */
if (!glfwInit())
return -1; /* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
} /* Make the window's context current */
glfwMakeContextCurrent(window); /* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT); /* Swap front and back buffers */
glfwSwapBuffers(window); /* Poll for and process events */
glfwPollEvents();
} glfwTerminate();
return 0;
}

一个空窗口:


画个三角形:

#include <GLFW/glfw3.h>

int main(void)
{
GLFWwindow* window; /* Initialize the library */
if (!glfwInit())
return -1; /* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
} /* Make the window's context current */
glfwMakeContextCurrent(window); /* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT); // Draw triangles begin
glBegin(GL_TRIANGLES); glVertex2f(-0.5f, -0.5f);
glVertex2f(0.0f, 0.5f);
glVertex2f(0.5f, -0.5f); glEnd();
// Draw triangles end /* Swap front and back buffers */
glfwSwapBuffers(window); /* Poll for and process events */
glfwPollEvents();
} glfwTerminate();
return 0;
}

opengl helloworld vscode 通过glfw 绘制三角形的更多相关文章

  1. OpenGL学习(2)——绘制三角形

    在创建窗口的基础上,添加代码实现三角形的绘制. 声明和定义变量 在屏幕上绘制一个三角形需要的变量有: 三角形的三个顶点坐标: Vertex Buffer Object 将顶点数据存储在GPU的内存中: ...

  2. Android OpenGL ES(十)绘制三角形Triangle .

    三角形为OpenGL ES支持的面,同样创建一个DrawTriangle Activity,定义6个顶点使用三种不同模式来绘制三角形: float vertexArray[] = { -0.8f, - ...

  3. OpenGL学习(2)——绘制三角形(补)

    对上一篇的补充,通过绘制三角形来完成矩形的绘制.此外,完成章节后练习. 绘制矩形 一个矩形由两个三角形组成,因此绘制矩形需要绘制两个三角形,一共6个顶点,其中2个顶点重复画了两次. 为了减小开销,仅储 ...

  4. OpenGL笔记(一) 绘制三角形

    GLTools: 一些有用且可复用的函数 GLEW: OpenGL API的一些扩展机制 GLUT: OpenGL Utility toolkit, OpenGL跨平台相关,隐藏平台相关细节 RC代表 ...

  5. opengl绘制三角形

    顶点数组对象:Vertex Array Object,VAO 顶点缓冲对象:Vertex Buffer Object,VBO 索引缓冲对象:Element Buffer Object,EBO或Inde ...

  6. 1.opengl绘制三角形

    顶点数组对象:Vertex Array Object,VAO,用于存储顶点状态配置信息,每当界面刷新时,则通过VAO进行绘制. 顶点缓冲对象:Vertex Buffer Object,VBO,通过VB ...

  7. Android OpenGL 入门示例----绘制三角形和正方形

    Android上对OpenGl的支持是无缝的,所以才有众多3D效果如此逼真的游戏,在Camera的一些流程中也有用到GLSurfaceView的情况.本文记录OpenGL在Android上的入门级示例 ...

  8. Linux OpenGL 实践篇-3 绘制三角形

    本次实践是绘制两个三角形,重点理解顶点数组对象和OpenGL缓存的使用. 顶点数组对象 顶点数组对象负责管理一组顶点属性,顶点属性包括位置.法线.纹理坐标等. OpenGL缓存 OpenGL缓存实质上 ...

  9. iOS OpenGL ES简单绘制三角形

    OpenGL 是用于2D/3D图形编程的一套基于C语言的统一接口. windows,Linux,Unix上均可兼容. OpenGL ES 是在OpenGL嵌入式设备上的版本, android/iOS ...

  10. opengl es中不同的绘制方式

    opengl es中不同的绘制方式 转载请保留出处:http://xiaxveliang.blog.163.com/blog/static/297080342013467344263/ 1. GL_P ...

随机推荐

  1. 【python基础笔记-3】decimal模块解决浮点数计算精度问题

    通过Decimal('123.456')对象实例化后做 + - * / 等运算符操作计算结果不会出现精度问题. Tips:值得注意的2点是 1.Decimal接收的入参是str,所以如果原本操作的数据 ...

  2. AX2012 查询用户在线操作记录

    1 static void ExportSysClientAccessLog(Args _args) 2 { 3 SysClientAccessLog sysClientAccessLog; 4 5 ...

  3. Linux模拟手动输入指令

    当执行一个命令,其中会询问你的选择的时候,在脚本上,可以如此模拟手动输入: 运行的命令 <<EOF 键盘输入 EOF 例如挂载硬盘: DISK=/dev/sdb /sbin/fdisk $ ...

  4. 排查占用cpu最高线程

  5. opened by another process write access was denied sourceinsight

    Ubuntu 16.04 安装Samba 和 windows 安装Source Insight weixin_43764544 2021-01-07 15:23:03 23 收藏 文章标签: linu ...

  6. js 实现全屏预览(F11功能)--转

    参考文档   http://t.zoukankan.com/ghfjj-p-6322415.html HTML代码 <body> <div id="content" ...

  7. redis每天生成自增流水号(001、002...)

    原理:利用redis的RedisAtomicLong类实现该功能:让其每天第一次放置一个新的自增的值(一天过期)然后和每天的日期相加就可以了例子: 20180901 + 001 ;当天就是 20180 ...

  8. python3GUI--仿做一个网易云音乐By:PyQt5(附下载地址)

    @ 目录 一.前言 二.展示-主界面 1.静图1 2.静图2 3.静图3 3.静图3 4.动图1 三.展示-登录界面 1.静图1 2.静图2 5.动图2 四.展示-系统托盘 五.UI设计记录 1.UI ...

  9. 记安装MySQL数据库

    记录一次自己动手安装MySQL数据库所踩的坑   MySQL安装包与操作系统匹配 安装包有amd和Intel,32位.64位多种组合需要确认仔细使用者操作系统和CPU型号 例如我使用的是CentOS ...

  10. (一).JavaScript的简介,变量,数据类型,运算符和表达式

    1. JavaScript的简介 1.1 JavaScript概念 JavaScript是一门:动态的 弱类型的 解释型 的脚本语言 1. 动态: 程序执行的时候才确定数据类型 2. 弱类型:数据类型 ...