Commit 0cd83fba authored by Philip Trettner's avatar Philip Trettner

removed stb submodule

parent f1f7299b
[submodule "extern/stb/stb"]
path = extern/stb/stb
url = https://github.com/nothings/stb.git
[submodule "extern/lodepng/lodepng"]
path = extern/lodepng/lodepng
url = https://github.com/lvandeve/lodepng
......@@ -10,7 +10,6 @@ set(GLOW_OPENGL_SUPPORT CORE_45 CACHE STRING "Defines the OpenGL version with su
# libs
set(GLOW_USE_OWN_GLAD ON CACHE BOOL "If true, extern/glad is used")
set(GLOW_USE_OWN_STB ON CACHE BOOL "If true, extern/stb is used")
set(GLOW_USE_OWN_LODEPNG ON CACHE BOOL "If true, extern/lodepng is used")
# build options
......@@ -56,7 +55,7 @@ endif()
# ==================================
# Collect files
file(GLOB_RECURSE SOURCE_FILES "src/*.cc")
file(GLOB_RECURSE HEADER_FILES "src/*.hh")
file(GLOB_RECURSE HEADER_FILES "src/*.hh" "src/*.h")
file(GLOB_RECURSE TEST_FILES "test/*.cc" "test/*.hh")
file(GLOB_RECURSE SCRIPT_FILES "scripts/*.sh" "scripts/*.py")
if(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
......@@ -157,6 +156,11 @@ if (${GLOW_EXPERIMENTAL_THREAD_AGNOSTIC})
target_compile_definitions(glow PUBLIC GLOW_THREAD_AGNOSTIC)
endif()
if(GCC)
# workaround for https://github.com/nothings/stb/issues/280
target_link_libraries(glow PUBLIC gcc_s gcc)
endif()
# ==================================
# Include Dirs
target_include_directories(glow PUBLIC
......@@ -212,12 +216,6 @@ if(GLOW_USE_OWN_GLAD)
target_link_libraries(glow PUBLIC glad)
endif()
# STB image
if(GLOW_USE_OWN_STB)
add_subdirectory(extern/stb)
target_link_libraries(glow PRIVATE stb)
endif()
# Lodepng
if(GLOW_USE_OWN_LODEPNG)
add_subdirectory(extern/lodepng)
......
cmake_minimum_required(VERSION 3.0)
project(stb)
add_library(stb ${GLOW_LINK_TYPE} stb-impl.cc)
target_include_directories(stb PUBLIC ./)
if(MSVC)
target_compile_options(stb PUBLIC /MP)
else()
target_compile_options(stb PRIVATE -Wall -std=c++11)
endif()
if(GCC)
# workaround for https://github.com/nothings/stb/issues/280
target_link_libraries(stb PUBLIC gcc_s gcc)
endif()
Subproject commit e6afb9cbae4064da8c3e69af3ff5c4629579c1d2
......@@ -4,12 +4,12 @@
#include <glow/common/log.hh>
#include <glow/common/profiling.hh>
#include <stb/stb_image.h>
#include <stb/stb_image_write.h>
#include <glow/detail/stb/stb_image.h>
#include <glow/detail/stb/stb_image_write.h>
using namespace glow;
SharedTextureData TextureData::loadWithStb(const std::string& filename, const std::string& ending, ColorSpace colorSpace)
SharedTextureData TextureData::loadWithStb(const std::string& filename, const std::string& /* ending */, ColorSpace colorSpace)
{
GLOW_ACTION();
......@@ -18,13 +18,13 @@ SharedTextureData TextureData::loadWithStb(const std::string& filename, const st
int width, height, channel;
unsigned char* data = stbi_load(filename.c_str(), &width, &height, &channel, 0);
unsigned char* data = glow_stbi_load(filename.c_str(), &width, &height, &channel, 0);
// error case
if (!data)
{
error() << "Error loading STB texture data from " << filename;
error() << " Reason: " << stbi_failure_reason();
error() << " Reason: " << glow_stbi_failure_reason();
return nullptr;
}
......@@ -35,7 +35,7 @@ SharedTextureData TextureData::loadWithStb(const std::string& filename, const st
// ... replace '0' with '1'..'4' to force that many components per pixel
// ... but 'n' will always be the number that it would have been if you said 0
surface->setData(std::vector<char>(data, data + width * height * channel));
stbi_image_free(data);
glow_stbi_image_free(data);
surface->setType(GL_UNSIGNED_BYTE);
surface->setMipmapLevel(0);
......@@ -172,11 +172,11 @@ void TextureData::saveWithStb(TextureData* data, const std::string& filename, co
int ok;
if (ending == ".png")
ok = stbi_write_png(filename.c_str(), surf->getWidth(), surf->getHeight(), comps, surf->getFlippedData().data(), comps * surf->getWidth());
ok = glow_stbi_write_png(filename.c_str(), surf->getWidth(), surf->getHeight(), comps, surf->getFlippedData().data(), comps * surf->getWidth());
else if (ending == ".bmp")
ok = stbi_write_bmp(filename.c_str(), surf->getWidth(), surf->getHeight(), comps, surf->getFlippedData().data());
ok = glow_stbi_write_bmp(filename.c_str(), surf->getWidth(), surf->getHeight(), comps, surf->getFlippedData().data());
else if (ending == ".tga")
ok = stbi_write_tga(filename.c_str(), surf->getWidth(), surf->getHeight(), comps, surf->getFlippedData().data());
ok = glow_stbi_write_tga(filename.c_str(), surf->getWidth(), surf->getHeight(), comps, surf->getFlippedData().data());
else
{
error() << "Error saving STB texture data to " << filename;
......@@ -187,7 +187,7 @@ void TextureData::saveWithStb(TextureData* data, const std::string& filename, co
if (!ok)
{
error() << "Error saving STB texture data to " << filename;
error() << " Reason: " << stbi_failure_reason();
error() << " Reason: " << glow_stbi_failure_reason();
}
return;
......
......@@ -4,12 +4,10 @@
#endif
#define STB_IMAGE_IMPLEMENTATION
#include "stb/stb_image.h"
#include <glow/detail/stb/stb_image.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb/stb_image_write.h"
#include <glow/detail/stb/stb_image_write.h>
#define STB_TRUETYPE_IMPLEMENTATION
#include "stb/stb_truetype.h"
void dummy_stb_func() { }
#include <glow/detail/stb/stb_truetype.h>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment