Skip to content

Instantly share code, notes, and snippets.

@keea
Created October 19, 2023 13:45
Show Gist options
  • Save keea/0f4fea0d2f00e3114e8424b7bddb3fe4 to your computer and use it in GitHub Desktop.
Save keea/0f4fea0d2f00e3114e8424b7bddb3fe4 to your computer and use it in GitHub Desktop.
GLM 행렬(mat) 또는 벡터(vec) 출력하기
cmake_minimum_required(VERSION 3.10)
project(GLMExample)
include(FetchContent)
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 0.9.9.8
)
FetchContent_GetProperties(glm)
if(NOT glm_POPULATED)
FetchContent_Populate(glm)
set(GLM_TEST_ENABLE OFF CACHE BOOL "" FORCE)
add_subdirectory(${glm_SOURCE_DIR} ${glm_BINARY_DIR})
endif()
add_executable(GLMExample main.cpp)
target_include_directories(GLMExample PRIVATE ${glm_SOURCE_DIR})
#include <iostream>
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
int main() {
glm::vec3 vector1(1.0f, 2.0f, 3.0f);
glm::vec3 vector2(4.0f, 5.0f, 6.0f);
glm::vec3 result_vec = vector1 + vector2;
std::cout << glm::to_string(result_vec) << std::endl;
glm::mat4 result_mat = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f, 2.0f, 3.0f));
std::cout << glm::to_string(result_mat) << std::endl;
return 0;
}
@keea
Copy link
Author

keea commented Oct 19, 2023

Run cmake a build:

$ cd [Project Path]
$ cmake -B ./build
$ cmake --build ./build --config Release

Run Program

$ ./build/GLMExample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment