Using OpenGL and C++
- OpenGL 4.2 (minimum)
- GLUT
Open the BD Flag OpenGL.xcodeproj
, add OpenGL and GLUT libraries from project properties. Build and Run.
Use -framework GLUT -framework OpenGL
flag while compiling from command line (macOS only).
cd "BD Flag OpenGL"
# compile
clang++ main.cpp -o main -framework GLUT -framework OpenGL
# run
./main
Ignore the warnings since OpenGL has been deprecated in latest versions of macOS.
Use the flags provided by the opengl and glut libs built for your distro.
On Windows, install GLUT and add headers and linkers to your project in Visual Studio.
If you're using CLion and/or building using CMAKE
, then use the following config for your cmake.txt
file
cmake_minimum_required(VERSION 3.6)
project(project_name)
set(CMAKE_CXX_STANDARD 11)
if(APPLE)
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -framework GLUT -framework OpenGL")
else()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -lGL -lGLU -lglut")
endif()
add_executable(project_name ${SOURCE_FILES})