Added windows support for the OpenGL example cube
This commit is contained in:
@@ -9,18 +9,37 @@ set(executable cube.a)
|
||||
set(SrcDIR ./src)
|
||||
set(IncludeDIR ./include)
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
if (UNIX)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
endif(UNIX)
|
||||
|
||||
if (WIN32)
|
||||
SET(CMAKE_CXX_FLAGS "-IC:/dev/SDL2/include/ -LC:/dev/SDL2/lib/x64/")
|
||||
SET(CMAKE_CXX_FLAGS "-IC:/dev/SDL2_image/include/ -LC:/dev/SDL2_image/lib/x64/")
|
||||
SET(CMAKE_CXX_FLAGS "-IC:/dev/glm")
|
||||
|
||||
include_directories(${executable}
|
||||
"C:/dev/glm"
|
||||
"C:/dev/SDL2/include/"
|
||||
"C:/dev/SDL2_image/include/"
|
||||
)
|
||||
endif (WIN32)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAD ON)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
if (UNIX)
|
||||
include_directories(${executable}
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${SDL2_IMAGE_INCLUDE_DIR}
|
||||
)
|
||||
endif (UNIX)
|
||||
|
||||
include_directories(${executable}
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${SDL2_IMAGE_INCLUDE_DIR}
|
||||
${PNG_INCLUDE_DIR}
|
||||
${JPEG_INCLUDE_DIR}
|
||||
${IncludeDIR}
|
||||
@@ -37,13 +56,28 @@ set_target_properties(${executable} PROPERTIES
|
||||
CXX_EXTENSIONS OFF
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(${executable}
|
||||
SDL2
|
||||
SDL2_image
|
||||
PNG::PNG
|
||||
JPEG::JPEG
|
||||
OpenGL::OpenGL
|
||||
OpenGL::GL
|
||||
Threads::Threads
|
||||
)
|
||||
endif (UNIX)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(${executable}
|
||||
"C:/dev/SDL2/lib/x64/SDL2.lib"
|
||||
"C:/dev/SDL2/lib/x64/SDL2main.lib"
|
||||
"C:/dev/SDL2/lib/x64/SDL2test.lib"
|
||||
"C:/dev/SDL2_image/lib/x64/SDL2_image.lib"
|
||||
${WinSDK}
|
||||
)
|
||||
endif (WIN32)
|
||||
|
||||
target_link_libraries(${executable}
|
||||
${CMAKE_DL_LIBS}
|
||||
OpenGL::OpenGL
|
||||
OpenGL::GL
|
||||
SDL2
|
||||
SDL2_image
|
||||
PNG::PNG
|
||||
JPEG::JPEG
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include <iostream>
|
||||
#include <glad/glad.h>
|
||||
#ifdef _WIN32
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#endif
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
@@ -158,6 +163,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
// Set up a GL texture
|
||||
GLuint tex;
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
// Set mag and min filtering levels
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
Reference in New Issue
Block a user