From 342403a02f8063903d0f38327430721d4d0ae331 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 20 Sep 2021 18:15:14 -0500 Subject: do ass1 --- dev/snowman/.gitignore | 4 +- dev/snowman/CMakeLists.txt | 364 ++++++++++----------- dev/snowman/README.md | 2 +- dev/snowman/cmake/DownloadHelper.txt.in | 52 +-- .../ExternalProjectDownloadBuildInstall.cmake | 196 +++++------ dev/snowman/cmake/MessageMacros.cmake | 34 +- dev/snowman/cmake/UseOpenGL.cmake | 104 +++--- dev/snowman/main.cc | 18 +- dev/snowman/snowman.cc | 96 +++--- dev/snowman/snowman.h | 102 +++--- 10 files changed, 486 insertions(+), 486 deletions(-) (limited to 'dev/snowman') diff --git a/dev/snowman/.gitignore b/dev/snowman/.gitignore index dd1a9a8..2fcd5ce 100644 --- a/dev/snowman/.gitignore +++ b/dev/snowman/.gitignore @@ -1,2 +1,2 @@ -config.h -build +config.h +build diff --git a/dev/snowman/CMakeLists.txt b/dev/snowman/CMakeLists.txt index 8d4319a..10bfde5 100644 --- a/dev/snowman/CMakeLists.txt +++ b/dev/snowman/CMakeLists.txt @@ -1,182 +1,182 @@ -# Original Author(s) of this File: -# Daniel Keefe, 2017, University of Minnesota -# -# Author(s) of Significant Updates/Modifications to the File: -# ... - - - -# You are encouraged to copy this example, move it outside of the MinGfx directory, and use -# it as a starting point for your project. When you do this, you'll have to edit the -# following line as needed to point to the MinGfx install prefix used on your system. - -# !!!!!!!!!!!!! EDIT THE FOLLOWING LINE AS NEEDED !!!!!!!!!!!!! -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../build/install ../..) - - - - - -#### BASIC PROJECT SETUP #### - -project(snowman) - -# Using 3.9 to get a modern version of FindOpenGL.cmake -cmake_minimum_required (VERSION 3.9) - -# Dependencies that are auto-downloaded, built, and installed for you will go in the -# directory pointed to by the CMAKE_INSTALL_PREFIX. It defaults to a location inside -# the build directory. -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") - set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE ) -endif() - -# Add to paths cmake uses to search for scripts, modules, and config packages -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_INSTALL_PREFIX}) -list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_INSTALL_PREFIX}) - -include(MessageMacros) -h1("Building ${PROJECT_NAME}") -h2("Configuring paths") - -message(STATUS "Module path: ${CMAKE_MODULE_PATH}") -message(STATUS "Prefix path: ${CMAKE_PREFIX_PATH}") -message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") - -set(DATA_DIR_BUILD ${CMAKE_CURRENT_SOURCE_DIR}/data) -set(DATA_DIR_INSTALL ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/data) - -message(STATUS "Data dir (in build tree): ${DATA_DIR_BUILD}") -message(STATUS "Data dir (in install tree): ${DATA_DIR_INSTALL}") - -set(SHADERS_DIR_BUILD ${CMAKE_CURRENT_SOURCE_DIR}/shaders) -set(SHADERS_DIR_INSTALL ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/shaders) - -message(STATUS "Shaders dir (in build tree): ${SHADERS_DIR_BUILD}") -message(STATUS "Shaders dir (in install tree): ${SHADERS_DIR_INSTALL}") - - -#### SOURCE FOR THIS PROJECT #### -h2("Configuring source files") - -set(SOURCEFILES - snowman.cc - main.cc -) - -set(HEADERFILES - snowman.h -) - -set(EXTRAFILES - README.md -) - -set(SHADERFILES -) - -set_source_files_properties(${EXTRAFILES} PROPERTIES HEADER_FILE_ONLY TRUE) -set_source_files_properties(${SHADERFILES} PROPERTIES HEADER_FILE_ONLY TRUE) - -source_group("Shaders" FILES ${SHADERFILES}) - - -#### COMPILE OPTIONS #### - -h2("Configuring Compiler Options") - - - -message(STATUS "Building for " ${CMAKE_SYSTEM_NAME} ".") - -# Linux specific -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - add_definitions(-DLINUX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") -endif() - - -# Apple specific -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_definitions(-DOSX) - - # RPATH settings, see https://cmake.org/Wiki/CMake_RPATH_handling - set(CMAKE_MACOSX_RPATH ON) - - # use, i.e. don't skip the full RPATH for the build tree - SET(CMAKE_SKIP_BUILD_RPATH FALSE) - - # when building, don't use the install RPATH already - # (but later on when installing) - SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - - # add the automatically determined parts of the RPATH - # which point to directories outside the build tree to the install RPATH - SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - # the RPATH to be used when installing, but only if it's not a system directory - LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) - IF("${isSystemDir}" STREQUAL "-1") - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - ENDIF("${isSystemDir}" STREQUAL "-1") - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") -endif() - - -# Windows specific -if (WIN32) - add_definitions(-DWIN32) -endif() - - - - -#### DEFINE TARGET(S) #### - -h2("Defining Target(s)") - -add_executable(${PROJECT_NAME} ${SOURCEFILES} ${HEADERFILES} ${EXTRAFILES} ${SHADERFILES}) - - - -#### FIND AND ADD DEPENDENCIES #### - -h2("Adding Dependencies") -set(EXTERNAL_DIR external) - - -# MinGfx (linked with an imported cmake target so no need to specify include dirs) -# This will try to find MinGfxConfig.cmake, which should have been installed under -# CMAKE_INSTALL_PREFIX/lib/cmake/MinGfx when you installed the MinGfx Toolkit. -find_package(MinGfx REQUIRED) -target_link_libraries(${PROJECT_NAME} PUBLIC MinGfx::MinGfx) - - -# Add dependency on OpenGL -include(UseOpenGL) -UseOpenGL(${PROJECT_NAME} PUBLIC ${EXTERNAL_DIR}) - - - -#### INSTALL TARGET(S) #### - -h2("Configuring Install Target") - -# The install locations are relative to the CMAKE_INSTALL_PREFIX variable -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) - -install( - DIRECTORY data/ - DESTINATION ${DATA_DIR_INSTALL} - OPTIONAL -) - -install( - DIRECTORY shaders/ - DESTINATION ${SHADERS_DIR_INSTALL} - OPTIONAL -) +# Original Author(s) of this File: +# Daniel Keefe, 2017, University of Minnesota +# +# Author(s) of Significant Updates/Modifications to the File: +# ... + + + +# You are encouraged to copy this example, move it outside of the MinGfx directory, and use +# it as a starting point for your project. When you do this, you'll have to edit the +# following line as needed to point to the MinGfx install prefix used on your system. + +# !!!!!!!!!!!!! EDIT THE FOLLOWING LINE AS NEEDED !!!!!!!!!!!!! +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../build/install ../..) + + + + + +#### BASIC PROJECT SETUP #### + +project(snowman) + +# Using 3.9 to get a modern version of FindOpenGL.cmake +cmake_minimum_required (VERSION 3.9) + +# Dependencies that are auto-downloaded, built, and installed for you will go in the +# directory pointed to by the CMAKE_INSTALL_PREFIX. It defaults to a location inside +# the build directory. +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "") + set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE ) +endif() + +# Add to paths cmake uses to search for scripts, modules, and config packages +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_INSTALL_PREFIX}) +list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_INSTALL_PREFIX}) + +include(MessageMacros) +h1("Building ${PROJECT_NAME}") +h2("Configuring paths") + +message(STATUS "Module path: ${CMAKE_MODULE_PATH}") +message(STATUS "Prefix path: ${CMAKE_PREFIX_PATH}") +message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") + +set(DATA_DIR_BUILD ${CMAKE_CURRENT_SOURCE_DIR}/data) +set(DATA_DIR_INSTALL ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/data) + +message(STATUS "Data dir (in build tree): ${DATA_DIR_BUILD}") +message(STATUS "Data dir (in install tree): ${DATA_DIR_INSTALL}") + +set(SHADERS_DIR_BUILD ${CMAKE_CURRENT_SOURCE_DIR}/shaders) +set(SHADERS_DIR_INSTALL ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/shaders) + +message(STATUS "Shaders dir (in build tree): ${SHADERS_DIR_BUILD}") +message(STATUS "Shaders dir (in install tree): ${SHADERS_DIR_INSTALL}") + + +#### SOURCE FOR THIS PROJECT #### +h2("Configuring source files") + +set(SOURCEFILES + snowman.cc + main.cc +) + +set(HEADERFILES + snowman.h +) + +set(EXTRAFILES + README.md +) + +set(SHADERFILES +) + +set_source_files_properties(${EXTRAFILES} PROPERTIES HEADER_FILE_ONLY TRUE) +set_source_files_properties(${SHADERFILES} PROPERTIES HEADER_FILE_ONLY TRUE) + +source_group("Shaders" FILES ${SHADERFILES}) + + +#### COMPILE OPTIONS #### + +h2("Configuring Compiler Options") + + + +message(STATUS "Building for " ${CMAKE_SYSTEM_NAME} ".") + +# Linux specific +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + add_definitions(-DLINUX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") +endif() + + +# Apple specific +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + add_definitions(-DOSX) + + # RPATH settings, see https://cmake.org/Wiki/CMake_RPATH_handling + set(CMAKE_MACOSX_RPATH ON) + + # use, i.e. don't skip the full RPATH for the build tree + SET(CMAKE_SKIP_BUILD_RPATH FALSE) + + # when building, don't use the install RPATH already + # (but later on when installing) + SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + + # add the automatically determined parts of the RPATH + # which point to directories outside the build tree to the install RPATH + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + # the RPATH to be used when installing, but only if it's not a system directory + LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + IF("${isSystemDir}" STREQUAL "-1") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + ENDIF("${isSystemDir}" STREQUAL "-1") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") +endif() + + +# Windows specific +if (WIN32) + add_definitions(-DWIN32) +endif() + + + + +#### DEFINE TARGET(S) #### + +h2("Defining Target(s)") + +add_executable(${PROJECT_NAME} ${SOURCEFILES} ${HEADERFILES} ${EXTRAFILES} ${SHADERFILES}) + + + +#### FIND AND ADD DEPENDENCIES #### + +h2("Adding Dependencies") +set(EXTERNAL_DIR external) + + +# MinGfx (linked with an imported cmake target so no need to specify include dirs) +# This will try to find MinGfxConfig.cmake, which should have been installed under +# CMAKE_INSTALL_PREFIX/lib/cmake/MinGfx when you installed the MinGfx Toolkit. +find_package(MinGfx REQUIRED) +target_link_libraries(${PROJECT_NAME} PUBLIC MinGfx::MinGfx) + + +# Add dependency on OpenGL +include(UseOpenGL) +UseOpenGL(${PROJECT_NAME} PUBLIC ${EXTERNAL_DIR}) + + + +#### INSTALL TARGET(S) #### + +h2("Configuring Install Target") + +# The install locations are relative to the CMAKE_INSTALL_PREFIX variable +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) + +install( + DIRECTORY data/ + DESTINATION ${DATA_DIR_INSTALL} + OPTIONAL +) + +install( + DIRECTORY shaders/ + DESTINATION ${SHADERS_DIR_INSTALL} + OPTIONAL +) diff --git a/dev/snowman/README.md b/dev/snowman/README.md index ee42984..6b0e8df 100644 --- a/dev/snowman/README.md +++ b/dev/snowman/README.md @@ -1 +1 @@ -# Angry Vectors CSci-4611 In-Class Example of Visual Debugging +# Angry Vectors CSci-4611 In-Class Example of Visual Debugging diff --git a/dev/snowman/cmake/DownloadHelper.txt.in b/dev/snowman/cmake/DownloadHelper.txt.in index fb29bff..69f3039 100644 --- a/dev/snowman/cmake/DownloadHelper.txt.in +++ b/dev/snowman/cmake/DownloadHelper.txt.in @@ -1,26 +1,26 @@ -# This file is part of the MinGfx cmake build system. -# See the main MinGfx/CMakeLists.txt file for authors, copyright, and license info. - -# This is a "helper" cmake project -- the only thing this project does is download -# the external project. So, the configure, build, install, and test commands for -# ExternalProject_Add() are intentionally set as NOPs. - -cmake_minimum_required (VERSION 3.9) - -project(@EXT_PROJECT_NAME@-download) - -include(ExternalProject) -ExternalProject_Add( - @EXT_PROJECT_NAME@ - SOURCE_DIR "@DOWNLOAD_DIR@/@EXT_PROJECT_NAME@/src" - BINARY_DIR "@DOWNLOAD_DIR@/@EXT_PROJECT_NAME@/download-helper" - @DOWNLOAD_OPTIONS@ - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - LOG_DOWNLOAD ON - GIT_PROGRESS 1 -) - - +# This file is part of the MinGfx cmake build system. +# See the main MinGfx/CMakeLists.txt file for authors, copyright, and license info. + +# This is a "helper" cmake project -- the only thing this project does is download +# the external project. So, the configure, build, install, and test commands for +# ExternalProject_Add() are intentionally set as NOPs. + +cmake_minimum_required (VERSION 3.9) + +project(@EXT_PROJECT_NAME@-download) + +include(ExternalProject) +ExternalProject_Add( + @EXT_PROJECT_NAME@ + SOURCE_DIR "@DOWNLOAD_DIR@/@EXT_PROJECT_NAME@/src" + BINARY_DIR "@DOWNLOAD_DIR@/@EXT_PROJECT_NAME@/download-helper" + @DOWNLOAD_OPTIONS@ + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + LOG_DOWNLOAD ON + GIT_PROGRESS 1 +) + + diff --git a/dev/snowman/cmake/ExternalProjectDownloadBuildInstall.cmake b/dev/snowman/cmake/ExternalProjectDownloadBuildInstall.cmake index ce12d1d..4585dd3 100644 --- a/dev/snowman/cmake/ExternalProjectDownloadBuildInstall.cmake +++ b/dev/snowman/cmake/ExternalProjectDownloadBuildInstall.cmake @@ -1,98 +1,98 @@ -# This file is part of the MinGfx cmake build system. -# See the main MinGfx/CMakeLists.txt file for authors, copyright, and license info. - - -# Calling CMAKE_CURRENT_LIST_DIR inside a function returns the list dir of the calling script -# but we want the list dir of this file in order to find the DownloadHelper.txt.in file, which -# should be stored right next to this one. So, defining this variable outside the scope of the -# functions below. -set(DIR_OF_THIS_FILE ${CMAKE_CURRENT_LIST_DIR}) - - - -# Usage: -# ExternalProject_Download( -# # This first argument is the name of the project to download. It is required: -# glm -# -# # Additional arguments specify how to download the project using GIT, SVN, CVS, or URL. -# # These can be any of the arguments used for the downloading step of the cmake builtin -# # ExternalProject_Add command. -# GIT_REPOSITORY "https://github.com/g-truc/glm.git" -# GIT_TAG master -# etc.. -# ) -function(ExternalProject_Download EXT_PROJECT_NAME DOWNLOAD_DIR) - - include(MessageMacros) - h1("BEGIN EXTERNAL PROJECT DOWNLOAD (${EXT_PROJECT_NAME}).") - - h2("Creating a download helper project for ${EXT_PROJECT_NAME}.") - - set(DOWNLOAD_OPTIONS ${ARGN}) - string (REGEX REPLACE "(^|[^\\\\]);" "\\1 " DOWNLOAD_OPTIONS "${DOWNLOAD_OPTIONS}") - - - file(MAKE_DIRECTORY ${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}) - configure_file( - ${DIR_OF_THIS_FILE}/DownloadHelper.txt.in - ${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper/CMakeLists.txt - ) - - h2("Generating build files for the ${EXT_PROJECT_NAME} download helper project.") - execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY "${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper") - - h2("Building the ${EXT_PROJECT_NAME} download helper project. (This actually performs the download and may take some time...)") - execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper") - - h2("Completed download of external project ${EXT_PROJECT_NAME}.") - -endfunction() - - -# Usage: -# ExternalProject_BuildAndInstallNow( -# # This first argument is the name of the external project to download. It is required: -# VRPN -# # This second argument is the relative path from ${EXTERNAL_DIR_NAME}/projectname/ to the project's -# # main CMakeLists.txt file: -# src -# -# # Additional arguments are passed on as options to the cmake build file generator -# -DVRPN_BUILD_DIRECTSHOW_VIDEO_SERVER=OFF -# -DVRPN_BUILD_HID_GUI=OFF -# etc.. -# ) -function(ExternalProject_BuildAndInstallNow EXT_PROJECT_NAME DOWNLOAD_DIR RELPATH_TO_CMAKELISTS) - - include(MessageMacros) - h1("BEGIN EXTERNAL PROJECT BUILD AND INSTALL (${EXT_PROJECT_NAME}).") - - # any extra args to the function are interpreted as arguments for the cmake config process - set(CMAKE_CONFIG_OPTIONS ${ARGN}) - - # always set the install prefix to be the same as for the main project - list(APPEND CMAKE_CONFIG_OPTIONS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) - - #string (REGEX REPLACE "(^|[^\\\\]);" "\\1 " CMAKE_CONFIG_OPTIONS "${CMAKE_CONFIG_OPTIONS}") - - - set(SRC_DIR "${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/${RELPATH_TO_CMAKELISTS}") - set(BUILD_DIR "${CMAKE_BINARY_DIR}/external/${EXT_PROJECT_NAME}") - - file(MAKE_DIRECTORY ${BUILD_DIR}) - - h2("Generating build files for external project ${EXT_PROJECT_NAME}.") - message(STATUS "Using source dir: ${SRC_DIR}") - message(STATUS "Using build dir: ${BUILD_DIR}") - message(STATUS "Config options: ${CMAKE_CONFIG_OPTIONS}") - - execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" ${SRC_DIR} ${CMAKE_CONFIG_OPTIONS} WORKING_DIRECTORY ${BUILD_DIR}) - - h2("Building external project ${EXT_PROJECT_NAME}. (This may take some time...)") - execute_process(COMMAND "${CMAKE_COMMAND}" --build ${BUILD_DIR} --target install) - - h2("Completed external build of ${EXT_PROJECT_NAME}.") - -endfunction() - +# This file is part of the MinGfx cmake build system. +# See the main MinGfx/CMakeLists.txt file for authors, copyright, and license info. + + +# Calling CMAKE_CURRENT_LIST_DIR inside a function returns the list dir of the calling script +# but we want the list dir of this file in order to find the DownloadHelper.txt.in file, which +# should be stored right next to this one. So, defining this variable outside the scope of the +# functions below. +set(DIR_OF_THIS_FILE ${CMAKE_CURRENT_LIST_DIR}) + + + +# Usage: +# ExternalProject_Download( +# # This first argument is the name of the project to download. It is required: +# glm +# +# # Additional arguments specify how to download the project using GIT, SVN, CVS, or URL. +# # These can be any of the arguments used for the downloading step of the cmake builtin +# # ExternalProject_Add command. +# GIT_REPOSITORY "https://github.com/g-truc/glm.git" +# GIT_TAG master +# etc.. +# ) +function(ExternalProject_Download EXT_PROJECT_NAME DOWNLOAD_DIR) + + include(MessageMacros) + h1("BEGIN EXTERNAL PROJECT DOWNLOAD (${EXT_PROJECT_NAME}).") + + h2("Creating a download helper project for ${EXT_PROJECT_NAME}.") + + set(DOWNLOAD_OPTIONS ${ARGN}) + string (REGEX REPLACE "(^|[^\\\\]);" "\\1 " DOWNLOAD_OPTIONS "${DOWNLOAD_OPTIONS}") + + + file(MAKE_DIRECTORY ${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}) + configure_file( + ${DIR_OF_THIS_FILE}/DownloadHelper.txt.in + ${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper/CMakeLists.txt + ) + + h2("Generating build files for the ${EXT_PROJECT_NAME} download helper project.") + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY "${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper") + + h2("Building the ${EXT_PROJECT_NAME} download helper project. (This actually performs the download and may take some time...)") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/download-helper") + + h2("Completed download of external project ${EXT_PROJECT_NAME}.") + +endfunction() + + +# Usage: +# ExternalProject_BuildAndInstallNow( +# # This first argument is the name of the external project to download. It is required: +# VRPN +# # This second argument is the relative path from ${EXTERNAL_DIR_NAME}/projectname/ to the project's +# # main CMakeLists.txt file: +# src +# +# # Additional arguments are passed on as options to the cmake build file generator +# -DVRPN_BUILD_DIRECTSHOW_VIDEO_SERVER=OFF +# -DVRPN_BUILD_HID_GUI=OFF +# etc.. +# ) +function(ExternalProject_BuildAndInstallNow EXT_PROJECT_NAME DOWNLOAD_DIR RELPATH_TO_CMAKELISTS) + + include(MessageMacros) + h1("BEGIN EXTERNAL PROJECT BUILD AND INSTALL (${EXT_PROJECT_NAME}).") + + # any extra args to the function are interpreted as arguments for the cmake config process + set(CMAKE_CONFIG_OPTIONS ${ARGN}) + + # always set the install prefix to be the same as for the main project + list(APPEND CMAKE_CONFIG_OPTIONS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) + + #string (REGEX REPLACE "(^|[^\\\\]);" "\\1 " CMAKE_CONFIG_OPTIONS "${CMAKE_CONFIG_OPTIONS}") + + + set(SRC_DIR "${DOWNLOAD_DIR}/${EXT_PROJECT_NAME}/${RELPATH_TO_CMAKELISTS}") + set(BUILD_DIR "${CMAKE_BINARY_DIR}/external/${EXT_PROJECT_NAME}") + + file(MAKE_DIRECTORY ${BUILD_DIR}) + + h2("Generating build files for external project ${EXT_PROJECT_NAME}.") + message(STATUS "Using source dir: ${SRC_DIR}") + message(STATUS "Using build dir: ${BUILD_DIR}") + message(STATUS "Config options: ${CMAKE_CONFIG_OPTIONS}") + + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" ${SRC_DIR} ${CMAKE_CONFIG_OPTIONS} WORKING_DIRECTORY ${BUILD_DIR}) + + h2("Building external project ${EXT_PROJECT_NAME}. (This may take some time...)") + execute_process(COMMAND "${CMAKE_COMMAND}" --build ${BUILD_DIR} --target install) + + h2("Completed external build of ${EXT_PROJECT_NAME}.") + +endfunction() + diff --git a/dev/snowman/cmake/MessageMacros.cmake b/dev/snowman/cmake/MessageMacros.cmake index 4628e5c..b2d08ee 100644 --- a/dev/snowman/cmake/MessageMacros.cmake +++ b/dev/snowman/cmake/MessageMacros.cmake @@ -1,17 +1,17 @@ -# This file is part of the MinVR cmake build system. -# See the main MinVR/CMakeLists.txt file for authors, copyright, and license info. - - -macro(h1 TITLE) - string(TOUPPER ${TITLE} TITLE) - message(STATUS "\n\n==== ${TITLE} ====") -endmacro() - -macro(h2 TITLE) - message(STATUS "\n* ${TITLE}") -endmacro() - -macro(h3 TITLE) - message(STATUS "- ${TITLE}") -endmacro() - +# This file is part of the MinVR cmake build system. +# See the main MinVR/CMakeLists.txt file for authors, copyright, and license info. + + +macro(h1 TITLE) + string(TOUPPER ${TITLE} TITLE) + message(STATUS "\n\n==== ${TITLE} ====") +endmacro() + +macro(h2 TITLE) + message(STATUS "\n* ${TITLE}") +endmacro() + +macro(h3 TITLE) + message(STATUS "- ${TITLE}") +endmacro() + diff --git a/dev/snowman/cmake/UseOpenGL.cmake b/dev/snowman/cmake/UseOpenGL.cmake index 2ec5ffb..ac5f55c 100644 --- a/dev/snowman/cmake/UseOpenGL.cmake +++ b/dev/snowman/cmake/UseOpenGL.cmake @@ -1,52 +1,52 @@ -# This file is part of the MinGfx cmake build system. -# See the main MinGfx/CMakeLists.txt file for authors, copyright, and license info. - -# Either finds a pre-installed version or complains. - -# Usage: In your CMakeLists.txt, somewhere after you define the target that depends -# on the OpenGL library (typical with something like add_executable(${PROJECT_NAME} ...) -# or add_library(${PROJECT_NAME} ...)), add the following two lines: - -# include(UseOpenGL) -# UseOpenGL(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/external) - -# The second argument can be either PUBLIC, PRIVATE, or INTERFACE, following the keyword -# usage described here: -# https://cmake.org/cmake/help/latest/command/target_include_directories.html - -# The third argument is the directory to use for downloading the external project if -# autobuild is used. - - - -macro(UseOpenGL YOUR_TARGET INTERFACE_PUBLIC_OR_PRIVATE DOWNLOAD_DIR) - - message(STATUS "Searching for OpenGL...") - - # Check to see if the library is already installed on the system - # CMake ships with FindOpenGL.cmake and in CMake 3.9+ it defines - # the imported targets OpenGL::GL and OpenGL::GLU. Using these is - # now the preferred way to link with OpenGL and all of its dependencies. - # See https://cmake.org/cmake/help/v3.9/module/FindOpenGL.html - find_package(OpenGL) - - if (NOT ${OPENGL_FOUND}) - message(FATAL_ERROR "OpenGL was not found on the system. MinGfx can auto-download and build many dependencies for you, but not OpenGL. It should come pre-installed on your system.") - endif() - - message(STATUS "Ok: OpenGL Found.") - message(STATUS "OpenGL headers: ${OPENGL_INCLUDE_DIR}") - message(STATUS "OpenGL libs: ${OPENGL_LIBRARIES}") - - - message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency OpenGL::GL.") - target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} OpenGL::GL) - - if (${OPENGL_GLU_FOUND}) - message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency OpenGL::GLU.") - target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} OpenGL::GLU) - endif() - - target_compile_definitions(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} -DUSE_OPENGL) - -endmacro() +# This file is part of the MinGfx cmake build system. +# See the main MinGfx/CMakeLists.txt file for authors, copyright, and license info. + +# Either finds a pre-installed version or complains. + +# Usage: In your CMakeLists.txt, somewhere after you define the target that depends +# on the OpenGL library (typical with something like add_executable(${PROJECT_NAME} ...) +# or add_library(${PROJECT_NAME} ...)), add the following two lines: + +# include(UseOpenGL) +# UseOpenGL(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/external) + +# The second argument can be either PUBLIC, PRIVATE, or INTERFACE, following the keyword +# usage described here: +# https://cmake.org/cmake/help/latest/command/target_include_directories.html + +# The third argument is the directory to use for downloading the external project if +# autobuild is used. + + + +macro(UseOpenGL YOUR_TARGET INTERFACE_PUBLIC_OR_PRIVATE DOWNLOAD_DIR) + + message(STATUS "Searching for OpenGL...") + + # Check to see if the library is already installed on the system + # CMake ships with FindOpenGL.cmake and in CMake 3.9+ it defines + # the imported targets OpenGL::GL and OpenGL::GLU. Using these is + # now the preferred way to link with OpenGL and all of its dependencies. + # See https://cmake.org/cmake/help/v3.9/module/FindOpenGL.html + find_package(OpenGL) + + if (NOT ${OPENGL_FOUND}) + message(FATAL_ERROR "OpenGL was not found on the system. MinGfx can auto-download and build many dependencies for you, but not OpenGL. It should come pre-installed on your system.") + endif() + + message(STATUS "Ok: OpenGL Found.") + message(STATUS "OpenGL headers: ${OPENGL_INCLUDE_DIR}") + message(STATUS "OpenGL libs: ${OPENGL_LIBRARIES}") + + + message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency OpenGL::GL.") + target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} OpenGL::GL) + + if (${OPENGL_GLU_FOUND}) + message(STATUS "Linking target ${YOUR_TARGET} with ${INTERFACE_PUBLIC_OR_PRIVATE} dependency OpenGL::GLU.") + target_link_libraries(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} OpenGL::GLU) + endif() + + target_compile_definitions(${YOUR_TARGET} ${INTERFACE_PUBLIC_OR_PRIVATE} -DUSE_OPENGL) + +endmacro() diff --git a/dev/snowman/main.cc b/dev/snowman/main.cc index 20e2ea3..0fc79a8 100644 --- a/dev/snowman/main.cc +++ b/dev/snowman/main.cc @@ -1,9 +1,9 @@ -/** CSci-4611 In-Class Example */ - -#include "snowman.h" - -int main(int argc, const char *argv[]) { - Snowman app; - app.Run(); - return 0; -} +/** CSci-4611 In-Class Example */ + +#include "snowman.h" + +int main(int argc, const char *argv[]) { + Snowman app; + app.Run(); + return 0; +} diff --git a/dev/snowman/snowman.cc b/dev/snowman/snowman.cc index 77ffa4d..0b6ab5e 100644 --- a/dev/snowman/snowman.cc +++ b/dev/snowman/snowman.cc @@ -1,48 +1,48 @@ -/** CSci-4611 In-Class Example */ - -#include "snowman.h" - -#include -#include - - - -Snowman::Snowman() : GraphicsApp(1024,768, "Do You Want to Build a Snowman?") { -} - - -Snowman::~Snowman() { -} - - -void Snowman::UpdateSimulation(double dt) { -} - - -void Snowman::InitOpenGL() { - // Set up the camera in a good position to see the entire scene - proj_matrix_ = Matrix4::Perspective(60.0f, aspect_ratio(), 0.01f, 100.0f); - view_matrix_ = Matrix4::LookAt(Point3(0,2,10), Point3(0,0,0), Vector3(0,1,0)); - glClearColor(0.2f, 0.6f, 1.0f, 1.0f); -} - - -void Snowman::DrawUsingOpenGL() { - Matrix4 identity; - - // draws a set of axes at the world origin, since we are passing the identity - // matrix for the "model" matrix. - quick_shapes_.DrawAxes(identity, view_matrix_, proj_matrix_); - - - Matrix4 S_ground = Matrix4::Scale(Vector3(40.0f, 0.2f, 40.0f)); - Matrix4 T_ground = Matrix4::Translation(Vector3(0.0f, -0.2f, 0.0f)); - Matrix4 ground_combo = T_ground * S_ground; - quick_shapes_.DrawCube(ground_combo, view_matrix_, proj_matrix_, Color(0.8f, 0.8f, 0.8f)); - -} - - - - - +/** CSci-4611 In-Class Example */ + +#include "snowman.h" + +#include +#include + + + +Snowman::Snowman() : GraphicsApp(1024,768, "Do You Want to Build a Snowman?") { +} + + +Snowman::~Snowman() { +} + + +void Snowman::UpdateSimulation(double dt) { +} + + +void Snowman::InitOpenGL() { + // Set up the camera in a good position to see the entire scene + proj_matrix_ = Matrix4::Perspective(60.0f, aspect_ratio(), 0.01f, 100.0f); + view_matrix_ = Matrix4::LookAt(Point3(0,2,10), Point3(0,0,0), Vector3(0,1,0)); + glClearColor(0.2f, 0.6f, 1.0f, 1.0f); +} + + +void Snowman::DrawUsingOpenGL() { + Matrix4 identity; + + // draws a set of axes at the world origin, since we are passing the identity + // matrix for the "model" matrix. + quick_shapes_.DrawAxes(identity, view_matrix_, proj_matrix_); + + + Matrix4 S_ground = Matrix4::Scale(Vector3(40.0f, 0.2f, 40.0f)); + Matrix4 T_ground = Matrix4::Translation(Vector3(0.0f, -0.2f, 0.0f)); + Matrix4 ground_combo = T_ground * S_ground; + quick_shapes_.DrawCube(ground_combo, view_matrix_, proj_matrix_, Color(0.8f, 0.8f, 0.8f)); + +} + + + + + diff --git a/dev/snowman/snowman.h b/dev/snowman/snowman.h index fea3dc8..fc85d84 100644 --- a/dev/snowman/snowman.h +++ b/dev/snowman/snowman.h @@ -1,52 +1,52 @@ -/** CSci-4611 In-Class Example */ - -#ifndef SNOWMAN_H_ -#define SNOWMAN_H_ - -#include -using namespace mingfx; - -#include -#include - -class Snowman : public GraphicsApp { -public: - - // Creates the App - Snowman(); - - // Cleans up when the App shuts down - virtual ~Snowman(); - - // Note a Run() function is inherited from GraphicsApp, that's what - // actually starts up the App. - - // This is a callback, a function that gets called when the user presses - // the Pause button in the GUI. - void OnPauseBtnPressed(); - - // This gets called once each frame. Note that dt (a.k.a., "delta time") is - // the amount of time (in seconds) that has passed since the last frame. - void UpdateSimulation(double dt); - - // This is where we initialize any OpenGL data, like textures or meshes that - // need to be loaded from files and setup in OpenGL. It gets called once - // when the program starts up. - void InitOpenGL(); - - // This gets called once each frame, and this is where you draw the latest - // version of your 3D graphics scene. - void DrawUsingOpenGL(); - - -private: - - // Sets up the computer graphics camera - Matrix4 view_matrix_; - Matrix4 proj_matrix_; - - // A helper class for drawing some simple shapes (cubes, spheres, 3D arrows) - QuickShapes quick_shapes_; -}; - +/** CSci-4611 In-Class Example */ + +#ifndef SNOWMAN_H_ +#define SNOWMAN_H_ + +#include +using namespace mingfx; + +#include +#include + +class Snowman : public GraphicsApp { +public: + + // Creates the App + Snowman(); + + // Cleans up when the App shuts down + virtual ~Snowman(); + + // Note a Run() function is inherited from GraphicsApp, that's what + // actually starts up the App. + + // This is a callback, a function that gets called when the user presses + // the Pause button in the GUI. + void OnPauseBtnPressed(); + + // This gets called once each frame. Note that dt (a.k.a., "delta time") is + // the amount of time (in seconds) that has passed since the last frame. + void UpdateSimulation(double dt); + + // This is where we initialize any OpenGL data, like textures or meshes that + // need to be loaded from files and setup in OpenGL. It gets called once + // when the program starts up. + void InitOpenGL(); + + // This gets called once each frame, and this is where you draw the latest + // version of your 3D graphics scene. + void DrawUsingOpenGL(); + + +private: + + // Sets up the computer graphics camera + Matrix4 view_matrix_; + Matrix4 proj_matrix_; + + // A helper class for drawing some simple shapes (cubes, spheres, 3D arrows) + QuickShapes quick_shapes_; +}; + #endif \ No newline at end of file -- cgit v1.2.3