University of Wales Trinity Saint David
ACCA6014 - Graphics Programming

Environment Setup

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:

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

  1. Download and install Git for Windows from https://git-scm.com. Accept all defaults. Verify with git --version in a new terminal.
  2. Download Visual Studio 2022 Community from https://visualstudio.microsoft.com.
  3. 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

  1. Open PowerShell as Administrator (right-click Start -> Terminal (Admin)).
  2. Navigate to C:\ and clone vcpkg:
    cd C:\
    git clone https://github.com/microsoft/vcpkg
    .\vcpkg\bootstrap-vcpkg.bat
  3. Confirm: C:\vcpkg\vcpkg.exe --version should print a version string.

Task 3 - Install Libraries

  1. Install all six packages (expect 10-20 minutes; Assimp takes the longest):
    C:\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
    The [glfw-binding,opengl3-binding] part selects two optional features of the ImGui port. These add the backend adapter files (imgui_impl_glfw and imgui_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.
  2. Verify: C:\vcpkg\vcpkg.exe list should list all six packages.

Task 4 - Integrate with Visual Studio

  1. C:\vcpkg\vcpkg.exe integrate install
  2. 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

  1. Open Visual Studio 2022. Create a new Console App (C++) named Renderer.
  2. Set Solution Configuration to Debug and Solution Platform to x64.
  3. Replace the contents of Renderer.cpp with:
    #include <GL/glew.h>
    #include <GLFW/glfw3.h>
    #include <glm/glm.hpp>
    #include <imgui.h>
    
    int main()
    {
        return 0;
    }
  4. 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

  1. 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)"
  2. Ubuntu / Debian:
    sudo apt update
    sudo apt install build-essential cmake git
  3. Arch:
    sudo pacman -S base-devel cmake git

Task 2 - Install Libraries

  1. macOS (Homebrew):
    brew install cmake glfw glew glm assimp
  2. Ubuntu / Debian (apt):
    sudo apt install cmake libglfw3-dev libglew-dev libglm-dev libassimp-dev
  3. Arch (pacman):
    sudo pacman -S cmake glfw-x11 glew glm assimp
  4. ImGui and stb_image are vendored directly in src/vendor/ and do not require a system install.

Task 3 - Create a CMakeLists.txt

  1. 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
    )
  2. Create main.cpp with 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

  1. From the project root, configure and build:
    cmake -B build -DCMAKE_BUILD_TYPE=Debug
    cmake --build build
  2. A successful build produces build/Renderer (or build/Renderer.app on macOS) with no errors.
  3. 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.

Optional: At the top of Renderer.cpp, add a comment block that briefly describes the purpose of each library in one sentence each.