This commit is contained in:
jie 2023-10-08 15:34:44 +08:00
commit 83c3ea0940
3 changed files with 71 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build/
/.idea/

51
CMakeLists.txt Normal file
View File

@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.26)
set(PROJECT_N LearnOpengl)
project(${PROJECT_N})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
IF(UNIX)
MESSAGE(STATUS "UNIX")
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
libavdevice
libavfilter
libavformat
libswresample
libswscale
libavutil
)
add_executable(${PROJECT_N} main.cpp)
target_link_libraries(${PROJECT_N}
PkgConfig::LIBAV
)
ELSE(WIN32)
MESSAGE(STATUS "WIN32")
set(CMAKE_PREFIX_PATH D:/document/lib/)
set(THIRD_LIB_DIR D:/document/lib/)
#glad
include_directories(${THIRD_LIB_DIR}/glad/glad3.3/include)
set(GLAD_SRCS ${THIRD_LIB_DIR}/glad/glad3.3/src/glad.c)
#glfw
include_directories(${THIRD_LIB_DIR}/glfw/glfw-3.3.8.bin.WIN64/glfw-3.3.8.bin.WIN64/include)
link_directories(${THIRD_LIB_DIR}/glfw/glfw-3.3.8.bin.WIN64/glfw-3.3.8.bin.WIN64/lib-vc2022)
set(Glfw_LIBS
glfw3.lib
)
#opengl
set(Opengl_LIBS
opengl32.lib
)
#link
add_executable(${PROJECT_N}
main.cpp
${GLAD_SRCS}
)
target_link_libraries(${PROJECT_N}
${Glfw_LIBS}
${Opengl_LIBS}
)
endif ()

18
main.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "glad/glad.h"
#include "GLFW/glfw3.h"
int main(int argc, char** const argv){
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
auto window = glfwCreateWindow(800, 600, "Window", nullptr, nullptr);
glfwMakeContextCurrent(window);
if(!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)){
auto error = glad_glGetError();
return error;
}
return 0;
}