diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3f8aada..8d71069 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -20,5 +20,5 @@ project( add_subdirectory(algorithms) add_subdirectory(cmake) add_subdirectory(datastructs) +add_subdirectory(graphics) add_subdirectory(patterns) -add_subdirectory(sdl-cmake) diff --git a/cpp/README.md b/cpp/README.md index db1c83e..60aa95d 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -5,11 +5,9 @@ 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 gcc +├── graphics # Examples of graphics projects written in C++ ├── patterns # Examples of various design patterns written in C++ -├── README.md -├── sdl-cmake # Barebones sdl application written in C++ built with cmake -└── sdl # Barebones sdl application written in C++ built with gcc +└── README.md ``` This directory contains a `CMakeLists.txt`, which can be selected to open as a diff --git a/cpp/algorithms/sorting/radix/CMakeLists.txt b/cpp/algorithms/sorting/radix/CMakeLists.txt index ba4612f..5206fb8 100644 --- a/cpp/algorithms/sorting/radix/CMakeLists.txt +++ b/cpp/algorithms/sorting/radix/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) add_executable(radix-sort "radix-sort.cpp") -add_library(lib-counting "lib-counting.cpp") +add_library(lib-radix-counting "lib-counting.cpp") add_library(lib-radix "lib-radix.cpp") -target_link_libraries(radix-sort lib-radix lib-counting) +target_link_libraries(radix-sort lib-radix lib-radix-counting) diff --git a/cpp/graphics/CMakeLists.txt b/cpp/graphics/CMakeLists.txt new file mode 100644 index 0000000..4b85960 --- /dev/null +++ b/cpp/graphics/CMakeLists.txt @@ -0,0 +1,21 @@ +############################################################################### +## Author: Shaun Reed ## +## Legal: All Content (c) 2021 Shaun Reed, all rights reserved ## +## About: A root project for practicing C++ ## +## This project can be built to debug and run all nested projects ## +## Or, any subdirectory with a project() statement can be selected ## +## ## +## Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0 ## +############################################################################## +# +cmake_minimum_required(VERSION 3.15) + +project( + #[[NAME]] Graphics + VERSION 1.0 + DESCRIPTION "A root project for practicing graphics programming in C++" + LANGUAGES CXX +) + +add_subdirectory(opengl-cmake) +add_subdirectory(sdl-cmake) diff --git a/cpp/graphics/README.md b/cpp/graphics/README.md new file mode 100644 index 0000000..d3d6dfb --- /dev/null +++ b/cpp/graphics/README.md @@ -0,0 +1,12 @@ +# Graphics + +Example graphics programming projects written in C++ + +``` +klips/cpp/graphics +. +├── opengl # Barebones opengl application written in C++ built with gcc +├── opengl-cmake# Barebones opengl 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 +``` diff --git a/cpp/opengl-cmake/CMakeLists.txt b/cpp/graphics/opengl-cmake/CMakeLists.txt similarity index 100% rename from cpp/opengl-cmake/CMakeLists.txt rename to cpp/graphics/opengl-cmake/CMakeLists.txt diff --git a/cpp/opengl-cmake/apps/test-gl.cpp b/cpp/graphics/opengl-cmake/apps/test-gl.cpp similarity index 94% rename from cpp/opengl-cmake/apps/test-gl.cpp rename to cpp/graphics/opengl-cmake/apps/test-gl.cpp index 678b647..80b928d 100644 --- a/cpp/opengl-cmake/apps/test-gl.cpp +++ b/cpp/graphics/opengl-cmake/apps/test-gl.cpp @@ -13,6 +13,7 @@ #include #include +#include //Screen constants const int SCREEN_WIDTH = 640; @@ -25,6 +26,9 @@ const int COLOR_MODE_MULTI = 1; int main( int argc, char* args[] ) { + std::cout << "Press Q to change color mode, E to adjust zoom\n"; + + //Initialize FreeGLUT glutInit( &argc, args ); diff --git a/cpp/opengl-cmake/src/lib-opengl-test.cpp b/cpp/graphics/opengl-cmake/src/lib-opengl-test.cpp similarity index 100% rename from cpp/opengl-cmake/src/lib-opengl-test.cpp rename to cpp/graphics/opengl-cmake/src/lib-opengl-test.cpp diff --git a/cpp/opengl-cmake/src/lib-opengl-test.hpp b/cpp/graphics/opengl-cmake/src/lib-opengl-test.hpp similarity index 100% rename from cpp/opengl-cmake/src/lib-opengl-test.hpp rename to cpp/graphics/opengl-cmake/src/lib-opengl-test.hpp diff --git a/cpp/opengl/test-gl.cpp b/cpp/graphics/opengl/test-gl.cpp similarity index 100% rename from cpp/opengl/test-gl.cpp rename to cpp/graphics/opengl/test-gl.cpp diff --git a/cpp/sdl-cmake/CMakeLists.txt b/cpp/graphics/sdl-cmake/CMakeLists.txt similarity index 100% rename from cpp/sdl-cmake/CMakeLists.txt rename to cpp/graphics/sdl-cmake/CMakeLists.txt diff --git a/cpp/sdl-cmake/apps/sdl-test.cpp b/cpp/graphics/sdl-cmake/apps/sdl-test.cpp similarity index 100% rename from cpp/sdl-cmake/apps/sdl-test.cpp rename to cpp/graphics/sdl-cmake/apps/sdl-test.cpp diff --git a/cpp/sdl-cmake/src/lib-sdl-test.cpp b/cpp/graphics/sdl-cmake/src/lib-sdl-test.cpp similarity index 100% rename from cpp/sdl-cmake/src/lib-sdl-test.cpp rename to cpp/graphics/sdl-cmake/src/lib-sdl-test.cpp diff --git a/cpp/sdl-cmake/src/lib-sdl-test.h b/cpp/graphics/sdl-cmake/src/lib-sdl-test.h similarity index 100% rename from cpp/sdl-cmake/src/lib-sdl-test.h rename to cpp/graphics/sdl-cmake/src/lib-sdl-test.h diff --git a/cpp/sdl/sdl-test-standalone.cpp b/cpp/graphics/sdl/sdl-test-standalone.cpp similarity index 100% rename from cpp/sdl/sdl-test-standalone.cpp rename to cpp/graphics/sdl/sdl-test-standalone.cpp diff --git a/cpp/opengl/.vscode/launch.json b/cpp/opengl/.vscode/launch.json deleted file mode 100644 index 5bdbc15..0000000 --- a/cpp/opengl/.vscode/launch.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) Launch", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/test-gl", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] - } - ] -} \ No newline at end of file diff --git a/cpp/opengl/.vscode/tasks.json b/cpp/opengl/.vscode/tasks.json deleted file mode 100644 index 4dbaa3a..0000000 --- a/cpp/opengl/.vscode/tasks.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "type": "shell", - "label": "cpp build active file", - "command": "/usr/bin/g++", - "args": [ - "${file}", - "-lGL", - "-lGLU", - "-lglut", - "-o", - "${fileDirname}/build/${fileBasenameNoExtension}" - ], - "options": { - "cwd": "/usr/bin" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file diff --git a/cpp/sdl-cmake/.vscode/launch.json b/cpp/sdl-cmake/.vscode/launch.json deleted file mode 100644 index 5a63ae7..0000000 --- a/cpp/sdl-cmake/.vscode/launch.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) Launch", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/inherited", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] - } - ] -} \ No newline at end of file diff --git a/cpp/sdl/.vscode/launch.json b/cpp/sdl/.vscode/launch.json deleted file mode 100644 index 0ccc785..0000000 --- a/cpp/sdl/.vscode/launch.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - - - { - "name": "(gdb) Launch", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/inherited", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] - } - ] -} \ No newline at end of file diff --git a/cpp/sdl/.vscode/tasks.json b/cpp/sdl/.vscode/tasks.json deleted file mode 100644 index a575756..0000000 --- a/cpp/sdl/.vscode/tasks.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "type": "shell", - "label": "cpp build active file", - "command": "g++", - "args": [ - "${workspaceFolder}/inherited.cpp", - "-lSDL2", - "-o", - "${workspaceFolder}/build/inherited", - ], - "options": { - "cwd": "/usr/bin" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file