卞正冠 P76094703@gs.ncku.edu.tw
姚勝翊 ND8081018@gs.ncku.edu.tw
Learn
OpenGL
Introduction
Introduction
Introduction
Linux
Windows
etc.
C & C++
Java
Python
etc.
Environment
(Windows, C++)
Requirement
OpenGL version 3.3 or above.
Visual Studio - Integrated development environment (IDE)
GLFW - OpenGL utility library
GLEW - OpenGL Extension Wrangler Library
GLFW
GLEW
GLFW & GLEW
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Visual Studio
Creating
a window
Include
Init GLFW
Create a window object
Init GLEW
Viewport
Render loop
End of the main function
Input
Create a window
Render pipeline
Pipeline
The graphics pipeline can be divided into two large parts: the first transforms your 3D coordinates into 2D coordinates and the second part transforms the 2D coordinates into actual colored pixels.
Shader
Pipeline
Normalized Device Coordinate(NDC)
Once your vertex coordinates have been processed in the vertex shader, they should be in normalized device coordinates which is a small space where the x, y and z values vary from -1.0 to 1.0.
Vertex Specification
VBO
VAO
EBO
An EBO is a buffer, just like a vertex buffer object, that stores indices that OpenGL uses to decide what vertices to draw.
Vertex Shader
Fragment Shader
Render
Code
Vertex data
An array containing 3d position data belonging to 3 vertices:
{ {-0.5, -0.5, 0}, {0.5, -0.5, 0}, {0, 0.5, 0} }
Generate the OpenGL object
Bind
Shader
Vertex Shader
Fragment Shader
Shader
Compile Shader
Create Shader Program
Create a shader program object to link the shader.
Vertex attribute array
Render the mesh in render loop
Draw a triangle
Draw more triangle
Draw more triangle
Draw more triangle
As you can see, there is some overlap on the vertices specified. We specify bottom right and top left twice!
Vertex & index data
Generate the OpenGL object
Bind
Render the mesh in render loop
Draw more triangle (EBO)