From 590f456efff5335f04560984da7d9936296e9859 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sat, 30 Mar 2024 15:43:05 -0400 Subject: [PATCH] Add the OpenGL example CMake --- .gitignore | 1 + CMakeLists.txt | 19 +++++++++++++++++++ compile.sh | 9 +++++++++ main.cpp | 28 ++++++++++++++++++++++++++++ opengl_example | Bin 0 -> 16440 bytes 5 files changed, 57 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 compile.sh create mode 100644 main.cpp create mode 100755 opengl_example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c795b05 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6faec16 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.9) + +project(OpengGL_Example) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_VERBOSE_MAKEFILE ON) + +add_executable(opengl_example main.cpp) + +# Set executable dependency libraries +# Equivalent to pass flags -lGL, -lGLU and -lglut +target_link_libraries(opengl_example GL GLU glut) + +# Add target to run executable +add_custom_target(run-ex1 + COMMAND opengl_example + DEPENDS opengl_example + WORKING_DIRECTORY ${CMAKE_PROJECT_DIR} +) \ No newline at end of file diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..d22d9b6 --- /dev/null +++ b/compile.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +#gcc -o opengl_example main.cpp -lGL -lGLU -lglut -lm + +rm -rf build +mkdir -p build +cd build +cmake .. +make -j4 \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..d32fe61 --- /dev/null +++ b/main.cpp @@ -0,0 +1,28 @@ +// http://www.codebind.com/linux-tutorials/install-opengl-ubuntu-linux/ +#include +#include + +void displayMe(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glBegin(GL_POLYGON); + glVertex3f(0.5, 0.0, 0.5); + glVertex3f(0.5, 0.0, 0.0); + glVertex3f(0.0, 0.5, 0.0); + glVertex3f(0.0, 0.0, 0.5); + glEnd(); + glFlush(); +} + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE); + glutInitWindowSize(1920, 1080); + glutInitWindowPosition(0, 0); + glutCreateWindow("Hello world!"); + glutFullScreen(); + glutDisplayFunc(displayMe); + glutMainLoop(); + return 0; +} \ No newline at end of file diff --git a/opengl_example b/opengl_example new file mode 100755 index 0000000000000000000000000000000000000000..8e750cd1b76c66015a21578dbabfc49a42c3c7d8 GIT binary patch literal 16440 zcmeHOZE&1b6~0MH3DP!OXrUC^E?QKCY?C&P;UlnZKDuF&(vJjM6ka#kO|mna-LU&E zO%X6o0h=kEDU2Wd@CW!q9Ko47IEv0lgXOC;>a>nJRel(Rj){YkZUKu**XP`O&f7Pa z-Rdy@nT~(!|%u_chlBO0LCd!Jj7OnuIszoit?<%!Y z&4+xR=8QgS09sRySI@;-=H~&)Zy8m};1z~ef-*uv@~c#yyTE7!RmjNXS3^~nZ9Ku_ z5EQ-FUznUx!ur?4)ntGo==Y=8wA5?0YH6K|5|=5CkNA;Delhlov7caw?FA*C6cgH7 zcpf%3Ku1N;_8VqD8{3VW5~Mz;Y(L>9K1zRE*zbz4ZbsR7qoI|c^tTm$6qo|y=I4#`R+9~ln|#QI3bn^W^yG_B zBO8jx-sqE5ttDM&A=pWxBK3QLl~mRDLua-`$f< zBt6cnn0B_O?ln5L?JQ&lFsp&FxHFi_#M7j99Gv0atKFFec-w=MB`P!&ay_B-o$Lsq%D-QU0 znwylzeLVFof`y5%%=^i zK?H&b1Q7@#5JcdkMc`E3%74c8yj2_9S94?yUOOL}bgN58V|!k#J**ont-l_0v2@i9 zfVx$R?1xEHoO!)eDjm==-MEW0$2^&C*u|L_Jegi%iZeg-WV&$|XP)$Ax?vY*9`$6p zQ5R>v>dAD2F3#NT$#i2b&cr>L9!!ceTRoW`NQyHXJeh9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