diff --git a/.gitmodules b/.gitmodules index 3810adf..2121d34 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "lib/glad"] path = lib/glad url = https://github.com/Dav1dde/glad.git +[submodule "extern/stb"] + path = extern/stb + url = https://github.com/nothings/stb.git diff --git a/CMakeLists.txt b/CMakeLists.txt index ecadb36..6cb33b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,5 +14,10 @@ add_subdirectory(lib/glfw) # GLAD add_subdirectory(lib/glad) +# External headers & sources +file(GLOB EXTERN_SOURCES extern/*) +include_directories(${EXTERN_SOURCES}) +link_directories(${EXTERN_SOURCES}) + # Linking target_link_libraries(Hohmann PRIVATE glfw glad) diff --git a/extern/stb b/extern/stb new file mode 160000 index 0000000..8b5f1f3 --- /dev/null +++ b/extern/stb @@ -0,0 +1 @@ +Subproject commit 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55 diff --git a/headers/textures.hpp b/headers/textures.hpp new file mode 100644 index 0000000..513af29 --- /dev/null +++ b/headers/textures.hpp @@ -0,0 +1,8 @@ +#ifndef TEXTURES_HPP +#define TEXTURES_HPP + +#define STB_IMAGE_IMPLEMENTATION +#include "../extern/stb/stb_image.h" + + +#endif diff --git a/src/main.cpp b/src/main.cpp index 513cf33..2a45833 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ #define VERT_SHADER_SRC_FILE "shaders/vertex.glsl" #define FRAG_SHADER_SRC_FILE "shaders/fragment.glsl" +#define RUSTY_METAL_TEXTURE "assets/textures/rusty_metal.jpg" void framebuffer_size_callback(GLFWwindow* win, int w, int h) { glViewport(0, 0, w, h); @@ -126,6 +127,10 @@ int main() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); + // "blending" + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + float borderColor[] = {1.0f, 1.0f, 1.0f, 1.0f}; glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); diff --git a/src/textures.cpp b/src/textures.cpp new file mode 100644 index 0000000..e69de29