Update OpenGL standalone example

+ Remove unused directories
+ Update cpp/README.txt to include new directories
This commit is contained in:
Shaun Reed 2021-05-24 13:12:14 -04:00
parent b2bdd62fb2
commit 16ac2046fa
4 changed files with 115 additions and 240 deletions

View File

@ -2,12 +2,14 @@
```
shaunrd0/klips/cpp/
├── algorithms # Examples of various algorithms written in C++
├── cmake # Example of using cmake to build and organize larger projects
├── datastructs # Collection of useful datastructures written in C++
├── opengl # Barebones opengl application written in C++ built with make
├── opengl # Barebones opengl application written in C++ built with gcc
├── patterns # Examples of various design patterns written in C++
├── README.md
├── sdl # Barebones sdl application written in C++ built with make
└── sdl-cmake # Barebones sdl application written in C++ built with cmake
├── sdl-cmake # Barebones sdl application written in C++ built with cmake
└── sdl # Barebones sdl application written in C++ built with gcc
```
This directory contains a `CMakeLists.txt`, which can be selected to open as a

View File

@ -1,58 +0,0 @@
###############################################################################
## Author: Shaun Reed ##
## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ##
## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
###############################################################################
# Define CMake version
cmake_minimum_required(VERSION 3.16)
project( # Define project
invaders # Project name
DESCRIPTION "Space invaders remake using OpenGL and CPP"
LANGUAGES CXX
)
# Pass this to program to control debug output
option (EXE_BUILD "Should we build the executable?" ON)
add_library( # Add Library
lib-invaders # Library Name
"src/lib-invaders.cpp" # Sources..
"src/lib-invaders.h"
)
target_include_directories( # When calling library, include a directory
lib-invaders # Library name
PUBLIC #
"${CMAKE_CURRENT_SOURCE_DIR}" # Source directory of exe including our library
)
if (EXE_BUILD)
set(BUILD_STATUS "Building default executable")
include(FindOpenGL)
include(FindGLUT)
include_directories(${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIR})
add_executable( # Creating executable
invaders # Exe name
"app/invaders.cpp" # Exe Source(s)
)
# Link the executable with OpenGL libraries
target_link_libraries( # Linking the exe to library
invaders # Executable to link
PUBLIC #
lib-invaders # Library to link
${OPENGL_LIBRARIES}
)
# Link the executable with OpenGL Utility Toolkit
target_link_libraries( # Linking the exe to library
invaders # Executable to link
PUBLIC #
lib-invaders # Library to link
${GLUT_LIBRARIES}
)
endif()

View File

@ -8,6 +8,7 @@
##############################################################################
## test-gl.cpp
*/
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glu.h>

View File

@ -1,70 +0,0 @@
###############################################################################
## Author: Shaun Reed ##
## Legal: All Content (c) 2019 Shaun Reed, all rights reserved ##
## ##
## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ##
##############################################################################
# Root CMakeLists.txt of cpp practice 4-inheritance
# Define CMake version
cmake_minimum_required(VERSION 3.15)
project( # Define project
inheritance # Project name
DESCRIPTION "Example project for class inheritance"
LANGUAGES CXX
)
# Pass this to program to control debug output
option (DB_CONF "Should we debug and configure files with cmake values?" ON)
option (DB_BUILD "Should we run the build in debug mode?" OFF)
option (EXE_BUILD "Should we build the executable?" ON)
add_library( # Add Library
lib-inherit # Library Name
"src/lib-inherit.cpp" # Sources..
"src/lib-inherit.h"
)
target_include_directories( # When calling library, include a directory
lib-inherit # Library name
PUBLIC #
"${CMAKE_CURRENT_SOURCE_DIR}" # Source directory of exe including our library
)
if (EXE_BUILD)
set(BUILD_STATUS "Building default executable")
include(FindPkgConfig)
pkg_search_module(SDL2 REQUIRED sdl2)
include_directories(${SDL2_INCLUDE_DIRS})
add_executable( # Creating executable
inherited # Exe name
"apps/inherited.cpp" # Exe Source(s)
)
target_link_libraries( # Linking the exe to library
inherited # Executable to link
PRIVATE #
lib-inherit # Library to link
${SDL2_LIBRARIES}
)
elseif(DB_BUILD)
set(BUILD_STATUS "Building in debug mode")
# Create compile_commands.json for linter
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
target_compile_definitions(inherited PRIVATE BUILD_STATUS=${BUILD_STATUS})
elseif(DB_CONF)
set(BUILD_STATUS "Building in debug mode, configuring files")
# Configure header file with CMake variables defined in src/lib-inherit.h.in
# @ONLY is specified, only variables of the form @VAR@ will be replaced and ${VAR} will be ignored.
# configure_file(src/lib-inherit.h src/lib-inherit.h @ONLY)
configure_file(apps/inherited.cpp apps/inherited.cpp @ONLY)
# Create compile_commands.json for linter
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
#target_compile_definitions(inherited PRIVATE BUILD_STATUS=${BUILD_STATUS})