diff --git a/OpenGL/playground/.gitignore b/OpenGL/playground/.gitignore index f921996..f2e2b26 100644 --- a/OpenGL/playground/.gitignore +++ b/OpenGL/playground/.gitignore @@ -1,2 +1,4 @@ build/ CMakeFiles/ +CMakeCache.txt +cmake_install.cmake diff --git a/OpenGL/playground/CMakeCache.txt b/OpenGL/playground/CMakeCache.txt index 9a1accc..6740fbd 100644 --- a/OpenGL/playground/CMakeCache.txt +++ b/OpenGL/playground/CMakeCache.txt @@ -1,5 +1,5 @@ # This is the CMakeCache file. -# For build in directory: /home/ben/Programming/examples/OpenGL/playground +# For build in directory: /home/ben/Programming/Languages/Examples/OpenGL/playground # It was generated by CMake: /usr/bin/cmake # You can edit this file to change values found and used by cmake. # If you do not want to change any of the values, simply exit the editor. @@ -29,11 +29,11 @@ CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ //A wrapper around 'ar' adding the appropriate '--plugin' option // for the GCC compiler -CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-8 +CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar //A wrapper around 'ranlib' adding the appropriate '--plugin' option // for the GCC compiler -CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-8 +CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib //Flags used by the CXX compiler during all build types. CMAKE_CXX_FLAGS:STRING= @@ -55,11 +55,11 @@ CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc //A wrapper around 'ar' adding the appropriate '--plugin' option // for the GCC compiler -CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-8 +CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar //A wrapper around 'ranlib' adding the appropriate '--plugin' option // for the GCC compiler -CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-8 +CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib //Flags used by the C compiler during all build types. CMAKE_C_FLAGS:STRING= @@ -132,6 +132,12 @@ CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy //Path to a program. CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump +//Value Computed by CMake +CMAKE_PROJECT_DESCRIPTION:STATIC= + +//Value Computed by CMake +CMAKE_PROJECT_HOMEPAGE_URL:STATIC= + //Value Computed by CMake CMAKE_PROJECT_NAME:STATIC=OpenGLPlayground @@ -204,31 +210,31 @@ OPENGL_GLX_INCLUDE_DIR:PATH=/usr/include OPENGL_INCLUDE_DIR:PATH=/usr/include //Path to a library. -OPENGL_egl_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libEGL.so +OPENGL_egl_LIBRARY:FILEPATH=/usr/lib/libEGL.so //Path to a library. -OPENGL_gl_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libGL.so +OPENGL_gl_LIBRARY:FILEPATH=/usr/lib/libGL.so //Path to a library. -OPENGL_glu_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libGLU.so +OPENGL_glu_LIBRARY:FILEPATH=/usr/lib/libGLU.so //Path to a library. -OPENGL_glx_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libGLX.so +OPENGL_glx_LIBRARY:FILEPATH=/usr/lib/libGLX.so //Path to a library. -OPENGL_opengl_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libOpenGL.so +OPENGL_opengl_LIBRARY:FILEPATH=/usr/lib/libOpenGL.so //Path to a file. OPENGL_xmesa_INCLUDE_DIR:PATH=OPENGL_xmesa_INCLUDE_DIR-NOTFOUND //Value Computed by CMake -OpenGLPlayground_BINARY_DIR:STATIC=/home/ben/Programming/examples/OpenGL/playground +OpenGLPlayground_BINARY_DIR:STATIC=/home/ben/Programming/Languages/Examples/OpenGL/playground //Value Computed by CMake -OpenGLPlayground_SOURCE_DIR:STATIC=/home/ben/Programming/examples/OpenGL/playground +OpenGLPlayground_SOURCE_DIR:STATIC=/home/ben/Programming/Languages/Examples/OpenGL/playground //The directory containing a CMake configuration file for SDL2. -SDL2_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/SDL2 +SDL2_DIR:PATH=/usr/lib64/cmake/SDL2 ######################## @@ -238,13 +244,13 @@ SDL2_DIR:PATH=/usr/lib/x86_64-linux-gnu/cmake/SDL2 //ADVANCED property for variable: CMAKE_AR CMAKE_AR-ADVANCED:INTERNAL=1 //This is the directory where this CMakeCache.txt was created -CMAKE_CACHEFILE_DIR:INTERNAL=/home/ben/Programming/examples/OpenGL/playground +CMAKE_CACHEFILE_DIR:INTERNAL=/home/ben/Programming/Languages/Examples/OpenGL/playground //Major version of cmake used to create the current loaded cache CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3 //Minor version of cmake used to create the current loaded cache -CMAKE_CACHE_MINOR_VERSION:INTERNAL=12 +CMAKE_CACHE_MINOR_VERSION:INTERNAL=13 //Patch version of cmake used to create the current loaded cache -CMAKE_CACHE_PATCH_VERSION:INTERNAL=3 +CMAKE_CACHE_PATCH_VERSION:INTERNAL=1 //ADVANCED property for variable: CMAKE_COLOR_MAKEFILE CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1 //Path to CMake executable. @@ -285,6 +291,8 @@ CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 //ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Path to cache edit program executable. +CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/ccmake //Executable file format CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF //ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS @@ -319,9 +327,9 @@ CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1 CMAKE_HAVE_PTHREAD_H:INTERNAL=1 //Source directory with the top level CMakeLists.txt file for this // project -CMAKE_HOME_DIRECTORY:INTERNAL=/home/ben/Programming/examples/OpenGL/playground +CMAKE_HOME_DIRECTORY:INTERNAL=/home/ben/Programming/Languages/Examples/OpenGL/playground //Install .so files without execute permission. -CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1 +CMAKE_INSTALL_SO_NO_EXE:INTERNAL=0 //ADVANCED property for variable: CMAKE_LINKER CMAKE_LINKER-ADVANCED:INTERNAL=1 //ADVANCED property for variable: CMAKE_MAKE_PROGRAM @@ -349,7 +357,7 @@ CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1 //ADVANCED property for variable: CMAKE_RANLIB CMAKE_RANLIB-ADVANCED:INTERNAL=1 //Path to CMake installation. -CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.12 +CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.13 //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 //ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG @@ -377,11 +385,11 @@ CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 //ADVANCED property for variable: CMAKE_STRIP CMAKE_STRIP-ADVANCED:INTERNAL=1 //uname command -CMAKE_UNAME:INTERNAL=/bin/uname +CMAKE_UNAME:INTERNAL=/usr/bin/uname //ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 //Details about finding OpenGL -FIND_PACKAGE_MESSAGE_DETAILS_OpenGL:INTERNAL=[/usr/lib/x86_64-linux-gnu/libOpenGL.so][/usr/lib/x86_64-linux-gnu/libGLX.so][/usr/include][c ][v()] +FIND_PACKAGE_MESSAGE_DETAILS_OpenGL:INTERNAL=[/usr/lib/libOpenGL.so][/usr/lib/libGLX.so][/usr/include][c ][v()] //Details about finding Threads FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()] //ADVANCED property for variable: OPENGL_EGL_INCLUDE_DIR diff --git a/OpenGL/playground/Makefile b/OpenGL/playground/Makefile index 2b6a2fb..5d7bba0 100644 --- a/OpenGL/playground/Makefile +++ b/OpenGL/playground/Makefile @@ -1,5 +1,5 @@ # CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.12 +# Generated by "Unix Makefiles" Generator, CMake Version 3.13 # Default target executed when no arguments are given to make. default_target: all @@ -48,10 +48,10 @@ RM = /usr/bin/cmake -E remove -f EQUALS = = # The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/ben/Programming/examples/OpenGL/playground +CMAKE_SOURCE_DIR = /home/ben/Programming/Languages/Examples/OpenGL/playground # The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/ben/Programming/examples/OpenGL/playground +CMAKE_BINARY_DIR = /home/ben/Programming/Languages/Examples/OpenGL/playground #============================================================================= # Targets provided globally by CMake. @@ -59,7 +59,7 @@ CMAKE_BINARY_DIR = /home/ben/Programming/examples/OpenGL/playground # Special rule for the target rebuild_cache rebuild_cache: @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) + /usr/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache # Special rule for the target rebuild_cache @@ -69,8 +69,8 @@ rebuild_cache/fast: rebuild_cache # Special rule for the target edit_cache edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." - /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." + /usr/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : edit_cache # Special rule for the target edit_cache @@ -80,9 +80,9 @@ edit_cache/fast: edit_cache # The main all target all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/ben/Programming/examples/OpenGL/playground/CMakeFiles /home/ben/Programming/examples/OpenGL/playground/CMakeFiles/progress.marks + $(CMAKE_COMMAND) -E cmake_progress_start /home/ben/Programming/Languages/Examples/OpenGL/playground/CMakeFiles /home/ben/Programming/Languages/Examples/OpenGL/playground/CMakeFiles/progress.marks $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /home/ben/Programming/examples/OpenGL/playground/CMakeFiles 0 + $(CMAKE_COMMAND) -E cmake_progress_start /home/ben/Programming/Languages/Examples/OpenGL/playground/CMakeFiles 0 .PHONY : all # The main clean target @@ -107,7 +107,7 @@ preinstall/fast: # clear depends depend: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 + $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend #============================================================================= @@ -263,6 +263,6 @@ help: # No rule that depends on this can have commands that come from listfiles # because they might be regenerated. cmake_check_build_system: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 + $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 .PHONY : cmake_check_build_system diff --git a/OpenGL/playground/cmake_install.cmake b/OpenGL/playground/cmake_install.cmake index 7179804..c7256c2 100644 --- a/OpenGL/playground/cmake_install.cmake +++ b/OpenGL/playground/cmake_install.cmake @@ -1,4 +1,4 @@ -# Install script for directory: /home/ben/Programming/examples/OpenGL/playground +# Install script for directory: /home/ben/Programming/Languages/Examples/OpenGL/playground # Set the install prefix if(NOT DEFINED CMAKE_INSTALL_PREFIX) @@ -29,7 +29,7 @@ endif() # Install shared libraries without execute permission? if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - set(CMAKE_INSTALL_SO_NO_EXE "1") + set(CMAKE_INSTALL_SO_NO_EXE "0") endif() # Is this installation the result of a crosscompile? @@ -45,5 +45,5 @@ endif() string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT "${CMAKE_INSTALL_MANIFEST_FILES}") -file(WRITE "/home/ben/Programming/examples/OpenGL/playground/${CMAKE_INSTALL_MANIFEST}" +file(WRITE "/home/ben/Programming/Languages/Examples/OpenGL/playground/${CMAKE_INSTALL_MANIFEST}" "${CMAKE_INSTALL_MANIFEST_CONTENT}") diff --git a/OpenGL/playground/output b/OpenGL/playground/output index fe61cb5..a668d1d 100755 Binary files a/OpenGL/playground/output and b/OpenGL/playground/output differ diff --git a/OpenGL/playground/src/main.cpp b/OpenGL/playground/src/main.cpp index cf459b1..6f8f676 100644 --- a/OpenGL/playground/src/main.cpp +++ b/OpenGL/playground/src/main.cpp @@ -25,6 +25,27 @@ #include "object.h" #include "shader.h" + +class Camera { +public: + Camera(const glm::vec3& position, const glm::vec3& rotation, float fov, float aspect, float zNear, float zFar) { + perspective = glm::perspective(glm::radians(fov), aspect, zNear, zFar); + Position = position; + Rotation = rotation; + aspect = aspect; + zNear = zNear; + zFar = zFar; + forward = glm::vec3(0.0f, 0.0f, 1.0f); + up = glm::vec3(0.0f, 1.0f, 0.0f); + } + + glm::mat4 perspective; + glm::vec3 Position, Rotation; + float fov, aspect, zNear, zFar; + glm::vec3 forward, up; +}; + + int main(int argc, char** argv) { std::cout << "-----------------------------" << std::endl; std::cout << "----- OpenGL Playground -----" << std::endl; @@ -110,6 +131,9 @@ int main(int argc, char** argv) { glEnableVertexAttribArray(normalAttrib); glVertexAttribPointer(normalAttrib, 3, GL_FLOAT, GL_FALSE, 0, (const void*)(vertices.size() * sizeof(glm::vec3))); + // Set up camera + Camera camera; + // Model matrice glm::mat4 model = glm::mat4(1.0f); @@ -148,6 +172,27 @@ int main(int argc, char** argv) { glm::vec4 result = model * glm::vec4(1.0f, 0.0f, 0.0f, 1.0f); glUniformMatrix4fv(uniTrans, 1, GL_FALSE, glm::value_ptr(model)); + + const Uint8 *state = SDL_GetKeyboardState(NULL); + + if (state[SDL_SCANCODE_W]) { + camera.Position.z += 0.01f * sin(glm::radians(camera.Rotation.y)); + camera.Position.x += 0.01f * cos(glm::radians(camera.Rotation.y)); + } + if (state[SDL_SCANCODE_S]) { + camera.Position.z -= 0.01f * sin(glm::radians(camera.Rotation.y)); + camera.Position.x -= 0.01f * cos(glm::radians(camera.Rotation.y)); + } + if (state[SDL_SCANCODE_A]) { + camera.Position.z -= 0.01f * cos(glm::radians(camera.Rotation.y)); + camera.Position.x += 0.01f * sin(glm::radians(camera.Rotation.y)); + } + if (state[SDL_SCANCODE_D]) { + camera.Position.z += 0.01f * cos(glm::radians(camera.Rotation.y)); + camera.Position.x -= 0.01f * sin(glm::radians(camera.Rotation.y)); + } + + UpdateClock = SDL_GetTicks(); }