Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmake/TargetOptimize.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ macro(target_optimize TARGET)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${TARGET} PRIVATE -fno-limit-debug-info)
endif()

# Add debug define
target_compile_definitions(${TARGET} PRIVATE DEBUG)
else()
# Build with optimizations and don't omit stack pointer for debugging
if(UNIX OR MINGW)
Expand Down
3 changes: 1 addition & 2 deletions ext/stb/include/stb_image_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,6 @@ STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const

#define stbiw__max(a, b) ((a) > (b) ? (a) : (b))

#ifndef STBI_WRITE_NO_STDIO

static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)
{
int exponent;
Expand Down Expand Up @@ -791,6 +789,7 @@ STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x,
return stbi_write_hdr_core(&s, x, y, comp, (float *) data);
}

#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
{
stbi__write_context s = { 0 };
Expand Down
13 changes: 13 additions & 0 deletions include/sourcepp/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
#define SOURCEPP_CONCAT_DETAIL(a, b) a##b
#define SOURCEPP_CONCAT(a, b) SOURCEPP_CONCAT_DETAIL(a, b)

/// Create a breakpoint in debug
#ifdef DEBUG
#if defined(_MSC_VER)
#define SOURCEPP_DEBUG_BREAK __debugbreak()
#elif defined(__linux__)
#include <csignal>
#define SOURCEPP_DEBUG_BREAK std::raise(SIGINT)
#endif
#endif
#ifndef SOURCEPP_DEBUG_BREAK
#define SOURCEPP_DEBUG_BREAK
#endif

/// Adds the current line number to the given base
#define SOURCEPP_UNIQUE_NAME(base) SOURCEPP_CONCAT(base, __LINE__)

Expand Down
84 changes: 84 additions & 0 deletions include/vtfpp/ImageConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ namespace vtfpp {

namespace ImagePixel {

#define VTFPP_CHECK_SIZE(format) \
static_assert(sizeof(format) == ImageFormatDetails::bpp(ImageFormat::format) / 8)

struct RGBA8888 {
static constexpr auto FORMAT = ImageFormat::RGBA8888;
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
VTFPP_CHECK_SIZE(RGBA8888);

struct ABGR8888 {
static constexpr auto FORMAT = ImageFormat::ABGR8888;
Expand All @@ -27,56 +31,66 @@ struct ABGR8888 {
uint8_t g;
uint8_t r;
};
VTFPP_CHECK_SIZE(ABGR8888);

struct RGB888 {
static constexpr auto FORMAT = ImageFormat::RGB888;
uint8_t r;
uint8_t g;
uint8_t b;
};
VTFPP_CHECK_SIZE(RGB888);

struct RGB888_BLUESCREEN : public RGB888 {
static constexpr auto FORMAT = ImageFormat::RGB888_BLUESCREEN;
};
VTFPP_CHECK_SIZE(RGB888_BLUESCREEN);

struct BGR888 {
static constexpr auto FORMAT = ImageFormat::BGR888;
uint8_t b;
uint8_t g;
uint8_t r;
};
VTFPP_CHECK_SIZE(BGR888);

struct BGR888_BLUESCREEN : public BGR888 {
static constexpr auto FORMAT = ImageFormat::BGR888_BLUESCREEN;
};
VTFPP_CHECK_SIZE(BGR888_BLUESCREEN);

struct RGB565 {
static constexpr auto FORMAT = ImageFormat::RGB565;
uint16_t r : 5;
uint16_t g : 6;
uint16_t b : 5;
};
VTFPP_CHECK_SIZE(RGB565);

struct I8 {
static constexpr auto FORMAT = ImageFormat::I8;
uint8_t i;
};
VTFPP_CHECK_SIZE(I8);

struct IA88 {
static constexpr auto FORMAT = ImageFormat::IA88;
uint8_t i;
uint8_t a;
};
VTFPP_CHECK_SIZE(IA88);

struct P8 {
static constexpr auto FORMAT = ImageFormat::P8;
uint8_t p;
};
VTFPP_CHECK_SIZE(P8);

struct A8 {
static constexpr auto FORMAT = ImageFormat::A8;
uint8_t a;
};
VTFPP_CHECK_SIZE(A8);

struct ARGB8888 {
static constexpr auto FORMAT = ImageFormat::ARGB8888;
Expand All @@ -85,6 +99,7 @@ struct ARGB8888 {
uint8_t g;
uint8_t b;
};
VTFPP_CHECK_SIZE(ARGB8888);

struct BGRA8888 {
static constexpr auto FORMAT = ImageFormat::BGRA8888;
Expand All @@ -93,6 +108,7 @@ struct BGRA8888 {
uint8_t r;
uint8_t a;
};
VTFPP_CHECK_SIZE(BGRA8888);

struct BGRX8888 {
static constexpr auto FORMAT = ImageFormat::BGRX8888;
Expand All @@ -101,13 +117,15 @@ struct BGRX8888 {
uint8_t r;
uint8_t x;
};
VTFPP_CHECK_SIZE(BGRX8888);

struct BGR565 {
static constexpr auto FORMAT = ImageFormat::BGR565;
uint16_t b : 5;
uint16_t g : 6;
uint16_t r : 5;
};
VTFPP_CHECK_SIZE(BGR565);

struct BGRX5551 {
static constexpr auto FORMAT = ImageFormat::BGRX5551;
Expand All @@ -116,6 +134,7 @@ struct BGRX5551 {
uint16_t r : 5;
uint16_t x : 1;
};
VTFPP_CHECK_SIZE(BGRX5551);

struct BGRA4444 {
static constexpr auto FORMAT = ImageFormat::BGRA4444;
Expand All @@ -124,6 +143,7 @@ struct BGRA4444 {
uint16_t r : 4;
uint16_t a : 4;
};
VTFPP_CHECK_SIZE(BGRA4444);

struct BGRA5551 {
static constexpr auto FORMAT = ImageFormat::BGRA5551;
Expand All @@ -132,12 +152,14 @@ struct BGRA5551 {
uint16_t r : 5;
uint16_t a : 1;
};
VTFPP_CHECK_SIZE(BGRA5551);

struct UV88 {
static constexpr auto FORMAT = ImageFormat::UV88;
uint8_t u;
uint8_t v;
};
VTFPP_CHECK_SIZE(UV88);

struct UVWQ8888 {
static constexpr auto FORMAT = ImageFormat::UVWQ8888;
Expand All @@ -146,6 +168,7 @@ struct UVWQ8888 {
uint8_t w;
uint8_t q;
};
VTFPP_CHECK_SIZE(UVWQ8888);

struct RGBA16161616F {
static constexpr auto FORMAT = ImageFormat::RGBA16161616F;
Expand All @@ -154,6 +177,7 @@ struct RGBA16161616F {
sourcepp::math::FloatCompressed16 b;
sourcepp::math::FloatCompressed16 a;
};
VTFPP_CHECK_SIZE(RGBA16161616F);

struct RGBA16161616 {
static constexpr auto FORMAT = ImageFormat::RGBA16161616;
Expand All @@ -162,6 +186,7 @@ struct RGBA16161616 {
uint16_t b;
uint16_t a;
};
VTFPP_CHECK_SIZE(RGBA16161616);

struct UVLX8888 {
static constexpr auto FORMAT = ImageFormat::UVLX8888;
Expand All @@ -170,18 +195,21 @@ struct UVLX8888 {
uint8_t l;
uint8_t x;
};
VTFPP_CHECK_SIZE(UVLX8888);

struct R32F {
static constexpr auto FORMAT = ImageFormat::R32F;
float r;
};
VTFPP_CHECK_SIZE(R32F);

struct RGB323232F {
static constexpr auto FORMAT = ImageFormat::R32F;
float r;
float g;
float b;
};
VTFPP_CHECK_SIZE(RGB323232F);

struct RGBA32323232F {
static constexpr auto FORMAT = ImageFormat::RGBA32323232F;
Expand All @@ -190,6 +218,62 @@ struct RGBA32323232F {
float b;
float a;
};
VTFPP_CHECK_SIZE(RGBA32323232F);

struct RG1616F {
static constexpr auto FORMAT = ImageFormat::RG1616F;
sourcepp::math::FloatCompressed16 r;
sourcepp::math::FloatCompressed16 g;
};
VTFPP_CHECK_SIZE(RG1616F);

struct RG3232F {
static constexpr auto FORMAT = ImageFormat::RG3232F;
float r;
float g;
};
VTFPP_CHECK_SIZE(RG3232F);

struct RGBX8888 {
static constexpr auto FORMAT = ImageFormat::RGBX8888;
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t x;
};
VTFPP_CHECK_SIZE(RGBX8888);

struct RGBA1010102 {
static constexpr auto FORMAT = ImageFormat::RGBA1010102;
uint32_t r : 10;
uint32_t g : 10;
uint32_t b : 10;
uint32_t a : 2;
};
VTFPP_CHECK_SIZE(RGBA1010102);

struct BGRA1010102 {
static constexpr auto FORMAT = ImageFormat::BGRA1010102;
uint32_t b : 10;
uint32_t g : 10;
uint32_t r : 10;
uint32_t a : 2;
};
VTFPP_CHECK_SIZE(BGRA1010102);

struct R16F {
static constexpr auto FORMAT = ImageFormat::R16F;
sourcepp::math::FloatCompressed16 r;
};
VTFPP_CHECK_SIZE(R16F);

struct R8 {
static constexpr auto FORMAT = ImageFormat::R8;
uint8_t r;
};
VTFPP_CHECK_SIZE(R8);

#undef VTFPP_CHECK_SIZE

} // namespace ImagePixel

Expand Down
Loading