XCode C++ (Part 3)

OpenGL GLEW


This is the logo owned by Apple Inc. for Xcode. Taken from the picture's app bundle. Fair use

Building an OpenGL application using C++ and XCode

I compiled an OpenGL Triangle app on my M1 MacBook Air.

The OpenGL Extension Wrangler Library (GLEW) is a cross-platform loading library.

GLEW provides a way to determine (at runtime) which OpenGL implementations are available.

The "4.1 Metal - 76.3" OpenGL implementation is available on my M1 MacBook Air.

Running application

Overview

The GLFW library is used to create an application window with a given width and height and the title "LearnOpenGL".

The GLEW library state is initialized.

A GLEW library call is used to define a viewport.

In this example vertex shader and fragment shader code (written in the C-like language GLSL) is copied, compiled and executed on the computer's graphics processing unit (GPU).

In a loop the shaders are used to draw and redraw a triangle defined by a set of positions/vertices. Each position includes an x value between -1 (far left) and 1 (far right), a y value between -1 (bottom) and 1 (top) and a z value (always 0 in this example).

main.cpp

brew install glew

Add include folder to header search

Add library

updated library references

build and run application