Skip to content

Commit 1d26433

Browse files
mardyWinterMute
authored andcommitted
examples: add OPenGL 2.0 example with SDL2
Taken from https://gist.github.com/DavidLudwig/d0307b81aab7f84b24e3
1 parent cfc987c commit 1d26433

File tree

5 files changed

+854
-0
lines changed

5 files changed

+854
-0
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ project(OpenGX VERSION 0.1)
33

44
option(BUILD_OPENGX "Build the opengx library" ON)
55
option(BUILD_DOCS "Build the documentation" OFF)
6+
option(BUILD_EXAMPLES "Build the examples" OFF)
67

78
set(CMAKE_C_STANDARD 11)
89
set(CMAKE_CXX_STANDARD 17)
@@ -95,3 +96,7 @@ if(BUILD_DOCS)
9596
include(UseLATEX)
9697
add_subdirectory(doc/src)
9798
endif()
99+
100+
if(BUILD_EXAMPLES)
101+
add_subdirectory(examples)
102+
endif()

examples/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
find_package(PkgConfig REQUIRED)
2+
pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
3+
pkg_check_modules(OPENGL IMPORTED_TARGET opengl)
4+
if(SDL2_FOUND)
5+
add_subdirectory(sdl2)
6+
endif()

examples/sdl2/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(opengl20)

examples/sdl2/opengl20/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set(EXTRA_FILES)
2+
set(EXTRA_LIBS)
3+
if(CMAKE_SYSTEM_NAME MATCHES "NintendoWii|NintendoGameCube")
4+
list(APPEND EXTRA_LIBS opengx)
5+
else()
6+
list(APPEND EXTRA_LIBS PkgConfig::OPENGL)
7+
endif()
8+
9+
macro(add_example name)
10+
add_executable(${name} ${EXTRA_FILES} ${ARGN})
11+
target_link_libraries(${name} ${EXTRA_LIBS} m PkgConfig::SDL2)
12+
endmacro()
13+
14+
add_example(gl2gears gl2gears.c)

0 commit comments

Comments
 (0)