Creating the OpenGL rendering window using GLFW

Let's go to our main.cpp file in Visual Studio or Xcode, and let's get started. Start typing the following code in your editor:

  1. Begin by adding some header files to our code:
#include <iostream> 
 
// GLEW 
#define GLEW_STATIC 
#include <GL/glew.h> 
 
// GLFW 
#include <GLFW/glfw3.h> 

iostream is just the input/output stream built into C++. Then, with GLEW_STATIC, we statically linked GLEW. If you don't want to statically link it, just omit the #define line.

  1. Next, we'll create some constants, and these will be used to store the width and height of our window:
// Window dimensions 
const GLint WIDTH = 800, HEIGHT = 600; 

You might be thinking, why are we using GLint instead of a regular int? The ...

Get Learn OpenGL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.