Overview
This lab sets up the complete development environment needed for all subsequent graphics programming work. You will install the vcpkg package manager, use it to acquire and build the four core libraries the project depends on, integrate them with Visual Studio, and confirm that a minimal C++ program including all four library headers compiles cleanly. No graphical output is produced yet!
Learning Objectives
By the end of this lab you will be able to:
- Install and bootstrap vcpkg as a C/C++ package manager on Windows.
- Use vcpkg to install GLFW, GLEW, GLM, ImGui, stb, and Assimp targeting the
x64-windowstriplet. - Apply vcpkg's user-wide Visual Studio integration so library headers and
.libfiles resolve automatically. - Create a Visual Studio 2022 Console Application configured for the x64 platform.
- Verify that all library headers compile without errors or linker warnings.
Concept
OpenGL is not a standalone library - it is a specification implemented by your graphics driver. Writing a windowed OpenGL application therefore requires several additional libraries: one to create the window and context, one to load function pointers at runtime, and one providing mathematical types that match GLSL's built-in vector and matrix types. Managing these manually (downloading source, building, then configuring Visual Studio Include and Library paths by hand) is error-prone and produces project files that break on any machine with a different directory layout.
vcpkg is a C/C++ package manager maintained by Microsoft. It keeps a
catalogue of ports - recipes for downloading and compiling third-party
libraries from source in a reproducible way. After a one-time bootstrap step you install
packages by name, specifying a triplet (e.g. x64-windows)
that controls the target architecture and linkage. The vcpkg integrate install
command injects every installed package's headers and import libraries into all MSBuild
projects on the machine automatically, removing the need to touch project properties at all.
Packages
| Package | Description | Docs |
|---|---|---|
| GLFW | Cross-platform library for creating windows with an OpenGL context and handling keyboard, mouse, and joystick input. Abstracts Win32, X11, and Cocoa behind a single C API. | glfw.org |
| GLEW | The OpenGL Extension Wrangler. Loads all modern OpenGL function pointers (e.g. glGenBuffers, glCreateShader) from the driver at runtime via a single glewInit() call. |
glew.sourceforge.net |
| GLM | Header-only OpenGL Mathematics library. Provides vec2, vec3, mat4 and utility functions such as perspective, lookAt, translate, and rotate that mirror GLSL built-ins. |
github.com/g-truc/glm |
| ImGui |
Dear ImGui is an immediate-mode C++ GUI library. Unlike retained-mode
toolkits (Qt, Win32 controls) that create persistent widget objects and store their state,
Dear ImGui rebuilds the entire interface every frame. A call to
ImGui::SliderFloat() reads the current value, draws the widget, and writes
back any change the user made - all in one function call with no widget tree to manage.
This makes it well-suited to renderer debug overlays: exposing a float as a slider takes
two lines of code and removing it later is equally trivial.
Because ImGui renders into your OpenGL context it needs adapter code that bridges it to your windowing library and graphics API. The vcpkg port exposes these as optional features - installing imgui[glfw-binding,opengl3-binding] adds
imgui_impl_glfw and imgui_impl_opengl3 alongside the core
headers. Without those features the library cannot render anything.
|
GitHub |
| stb_image | Single-header image loader. stbi_load() decodes PNG, JPEG, BMP, TGA, and more into a raw pixel buffer ready for glTexImage2D. No build system integration needed beyond the header. |
GitHub |
| Assimp | The Open Asset Import Library. Reads .obj, .fbx, .gltf, .dae, and many other 3D formats through a unified scene graph API covering meshes, materials, and bone hierarchies. |
readthedocs.io |
Tasks
Task 1 - Install Prerequisites
-
Download and install Git for Windows from
https://git-scm.com. Accept all defaults. Verify withgit --versionin a new terminal. -
Download Visual Studio 2022 Community from
https://visualstudio.microsoft.com. - In the installer select the Desktop development with C++ workload. Confirm MSVC v143 and the Windows 10/11 SDK are checked, then click Install.
Task 2 - Install and Bootstrap vcpkg
- Open PowerShell as Administrator (right-click Start -> Terminal (Admin)).
- Navigate to
C:\and clone vcpkg:cd C:\ git clone https://github.com/microsoft/vcpkg .\vcpkg\bootstrap-vcpkg.bat - Confirm:
C:\vcpkg\vcpkg.exe --versionshould print a version string.
Task 3 - Install Libraries
-
Install all six packages (expect 10-20 minutes; Assimp takes the longest):
TheC:\vcpkg\vcpkg.exe install glfw3:x64-windows C:\vcpkg\vcpkg.exe install glew:x64-windows C:\vcpkg\vcpkg.exe install glm:x64-windows C:\vcpkg\vcpkg.exe install "imgui[glfw-binding,opengl3-binding]:x64-windows" C:\vcpkg\vcpkg.exe install stb:x64-windows C:\vcpkg\vcpkg.exe install assimp:x64-windows[glfw-binding,opengl3-binding]part selects two optional features of the ImGui port. These add the backend adapter files (imgui_impl_glfwandimgui_impl_opengl3) that let ImGui draw into a GLFW window using OpenGL 3. If you install ImGui without these flags the core headers are present but ImGui cannot render. -
Verify:
C:\vcpkg\vcpkg.exe listshould list all six packages.
Task 4 - Integrate with Visual Studio
-
C:\vcpkg\vcpkg.exe integrate install -
The output should read:
Applied user-wide integration for this vcpkg root.All MSBuild projects on this machine will now resolve vcpkg headers and libraries automatically.
Task 5 - Create the Project and Verify Compilation
- Open Visual Studio 2022. Create a new Console App (C++) named
Renderer. - Set Solution Configuration to
Debugand Solution Platform tox64. -
Replace the contents of
Renderer.cppwith:#include <GL/glew.h> #include <GLFW/glfw3.h> #include <glm/glm.hpp> #include <imgui.h> int main() { return 0; } -
Press Ctrl+Shift+B. The Output window should report:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Task 1 - Install Build Tools
-
macOS: Install Xcode Command Line Tools, then Homebrew:
xcode-select --install /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Ubuntu / Debian:
sudo apt update sudo apt install build-essential cmake git -
Arch:
sudo pacman -S base-devel cmake git
Task 2 - Install Libraries
-
macOS (Homebrew):
brew install cmake glfw glew glm assimp -
Ubuntu / Debian (apt):
sudo apt install cmake libglfw3-dev libglew-dev libglm-dev libassimp-dev -
Arch (pacman):
sudo pacman -S cmake glfw-x11 glew glm assimp -
ImGui and stb_image are vendored directly in
src/vendor/and do not require a system install.
Task 3 - Create a CMakeLists.txt
-
In the project root, create
CMakeLists.txt:cmake_minimum_required(VERSION 3.16) project(Renderer) set(CMAKE_CXX_STANDARD 17) find_package(glfw3 REQUIRED) find_package(GLEW REQUIRED) find_package(glm REQUIRED) find_package(assimp REQUIRED) add_executable(Renderer main.cpp) target_link_libraries(Renderer PRIVATE glfw GLEW::GLEW glm::glm assimp::assimp ) -
Create
main.cppwith the same include check used on Windows:#include <GL/glew.h> #include <GLFW/glfw3.h> #include <glm/glm.hpp> #include <imgui.h> int main() { return 0; }
Task 4 - Configure and Build
-
From the project root, configure and build:
cmake -B build -DCMAKE_BUILD_TYPE=Debug cmake --build build -
A successful build produces
build/Renderer(orbuild/Renderer.appon macOS) with no errors. -
Run it to confirm it exits cleanly:
./build/Renderer
Expected Result
Windows: The Visual Studio Output window reports Build: 1 succeeded, 0 failed with zero errors. No application window appears - the program compiles and exits immediately. IntelliSense squiggles may take a few seconds to resolve after the first build.
Mac / Linux: cmake --build build completes with no
errors and produces an executable in the build/ directory.
Running it exits immediately with no output.
Renderer.cpp, add a comment block
that briefly describes the purpose of each library in one sentence each.