Giter Site home page Giter Site logo

learn-opengl's Introduction

学习OpenGL

名词解释

名词 释义 详细
VAO 顶点数组对象 管理VBO
VBO 顶点缓冲对象 在显卡中存储了顶点数据
EBO 索引缓冲对象

显卡管理数据方式

枚举 含义
GL_STATIC_DRAW 数据不会或几乎不会改变
GL_DYNAMIC_DRAW 数据会被改变很多
GL_STREAM_DRAW 数据每次绘制时都会改变

图元类型

图元类型 含义
GL_POINTS
GL_TRIANGLES 三角形
GL_LINE_STRIP 直线

渲染管线

  1. 顶点着色器 *
  2. 图元装配
  3. 几何着色器 *
  4. 光栅化
  5. 片段着色器 *
  6. 测试与混合

注:带 * 为可编程,使用 GLSL (OpenGL Shading Language) 语言

Transform

构造变换矩阵

正确的变换顺序是:缩放 -> 旋转 -> 位移,如果不按照这个顺序,比如先位移,再缩放,那么位移的距离也会被缩放

// 使用glm库要反着写,位移 -> 旋转 -> 缩放
glm::mat4 trans = glm::mat4(1.0f);  // 单位矩阵
trans = glm::translate(trans, glm::vec3(1.0f, 1.0f, 0.0f)); // 位移 x + 1, y + 1
trans = glm::rotate(trans, glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f)); // 逆时针旋转90°
trans = glm::scale(trans, glm::vec3(0.5f, 0.5f, 0.5f)); // 整体缩放到1/2

常用函数

设置绘制模式

// 线框 GL_LINE
// 填充 GL_FILL
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.