LabA01 Drawing 2D Triangles
Lab Tutorial: Drawing Triangles with OpenGL, GLEW, and GLFW
Objective
This tutorial guides you through rendering triangles using OpenGL, Direct3D, WebGL or Vulkan
Prerequisites
C++ development environment (e.g., Visual Studio, Code::Blocks, or GCC)
OpenGL, GLEW, and GLFW installed
Tutorial
Step 1: Setting Up the Environment
Step 2: Drawing Raw Triangles
Step 3: Drawing Indexed Triangles
Step 4: Drawing Indexed Triangles with Vertex Colours
Exercises
Basic Exercises
Modify the Triangle Colour – Change the colours of the triangle vertices to create a gradient effect.
Change Triangle Positions – Adjust the vertex coordinates to move the triangle around the screen.
Add More Triangles – Extend the program to render multiple triangles instead of just one.
Resize the Window – Modify the viewport and projection settings to maintain the correct aspect ratio when resizing.
Intermediate Exercises
Revise the code to draw a 3D pyramid (no need to touch projections)
Revise the code to draw a 3D cube (no need to touch projections)
Last updated