feat: include glew on windows

chore: update window title
build: link correct lib path
build: copy dll to artifacts
fix: remove redundant include
docs: remove duplicate lines
This commit is contained in:
Cat Flynn 2023-07-26 23:29:51 +02:00
parent 3944a76d6d
commit 8eface137b
2 changed files with 13 additions and 6 deletions

View File

@ -11,7 +11,7 @@ if(WIN32)
# GLEW # GLEW
set(GLEW_PATH "C:/libs/glew-2.2.0") set(GLEW_PATH "C:/libs/glew-2.2.0")
include_directories(${GLEW_PATH}/include) include_directories(${GLEW_PATH}/include)
link_directories(${GLEW_PATH}/lib) link_directories(${GLEW_PATH}/lib/Release/x64)
# OpenGL # OpenGL
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
@ -27,8 +27,14 @@ endif()
add_executable(${PROJECT_NAME} hello.cpp) add_executable(${PROJECT_NAME} hello.cpp)
if(WIN32) if(WIN32)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${GLEW_PATH}/bin/Release/x64/glew32.dll"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
target_link_libraries(${PROJECT_NAME} glfw3) target_link_libraries(${PROJECT_NAME} glfw3)
target_link_libraries(${PROJECT_NAME} glew) target_link_libraries(${PROJECT_NAME} glew32)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_INCLUDE_DIRS}) target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} OpenGL::GL) target_link_libraries(${PROJECT_NAME} OpenGL::GL)
elseif(UNIX) elseif(UNIX)

View File

@ -2,8 +2,10 @@
// Install GLFW 3.3.8 // Install GLFW 3.3.8
// https://www.glfw.org/download.html // https://www.glfw.org/download.html
// On Windows: // Install GLEW 2.2.0
// extract the downloaded .zip file to "C:/libs"; this is currently expected // https://github.com/nigels-com/glew/releases/tag/glew-2.2.0
//
// extract the downloaded .zip files to "C:/libs"; this is currently expected
// by our CMakeLists.txt. // by our CMakeLists.txt.
// Install CMake // Install CMake
@ -32,7 +34,6 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <GL/gl.h>
#include <iostream> #include <iostream>
@ -41,7 +42,7 @@ int main()
if (!glfwInit()) if (!glfwInit())
return -1; return -1;
GLFWwindow* window = glfwCreateWindow(640, 480, "Hello GL", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "Hello GLEW", NULL, NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();