First Commit

This commit is contained in:
2025-02-06 22:24:29 +08:00
parent ed7df4c81e
commit 7539e6a53c
18116 changed files with 6181499 additions and 0 deletions

25
externals/dds-ktx/LICENSE vendored Normal file
View File

@@ -0,0 +1,25 @@
BSD 2-Clause License
Copyright (c) 2018, Sepehr Taghdisian
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

128
externals/dds-ktx/README.md vendored Normal file
View File

@@ -0,0 +1,128 @@
## dds-ktx: Portable single header DDS/KTX reader for C/C++
[@septag](https://twitter.com/septagh)
- Parses from memory blob. No allocations
- No dependencies
- Single-header for easy integration
- Overridable libc functions
### Build Example (ctexview)
[**ctexview**](ctexview/ctexview.c) is a tiny ddx-ktx viewer that can be built on linux/mac and windows. To build it just compile the single file with your compiler.
**Windows:**
```
cl ctexview.c /O2
```
**Linuxx**
```
gcc ctexview.c -O2 -lGL -ldl -lX11 -lXi -lXcursor -lm -o ctexview
```
**MacOS**
```
clang -framework Foundation -framework CoreServices -framework CoreFoundation -O2 -fobjc-arc -x objective-c -fmodules -x objective-c ctexview.c -o ./ctexview
```
to view images just provide the image path as an argument:
```
ctexview [dds_or_ktx_image_file_path]
```
Used open-source libraries for app creation/graphics: [**Sokol**](https://github.com/floooh/sokol)
**Keys:**
- UP/DOWN: change current mipmap
- Apostrophe: change text color
- F: Next cube-map face
- R: Toggle Red channel
- G: Toggle Green channel
- B: Toggle Blue channel
- A: Toggle Alpha channel
### Usage
In this example, a simple 2D texture is parsed and created using OpenGL
```c
#define DDSKTX_IMPLEMENT
#include "dds-ktx.h"
int size;
void* dds_data = load_file("test.dds", &size);
assert(dds_data);
ddsktx_texture_info tc = {0};
GLuint tex = 0;
if (ddsktx_parse(&tc, dds_data, size, NULL)) {
assert(tc.depth == 1);
assert(!(tc.flags & STC_TEXTURE_FLAG_CUBEMAP));
assert(tc.num_layers == 1);
//Create GPU texture from tc data
glGenTextures(1, &tex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(img->gl_target, tex);
for (int mip = 0; mip < tc->num_mips; mip++) {
ddsktx_sub_data sub_data;
ddsktx_get_sub(&tc, &sub_data, dds_data, size, 0, 0, mip);
// Fill/Set texture sub resource data (mips in this case)
if (ddsktx_format_compressed(tc.format))
glCompressedTexImage2D(..);
else
glTexImage2D(..);
}
// Now we can delete file data
free(dds_data);
}
```
### Links
- [DdsKtxSharp](https://github.com/rds1983/DdsKtxSharp): C# port of dds-ktx by [Roman Shapiro](https://github.com/rds1983)
### TODO
- Write KTX/DDS
- Read KTX metadata. currently it just stores the offset/size to the metadata block
### Others
- [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h) - Single header library that loads images (.png, .jpg, .bmp, etc)
- [bimg](https://github.com/bkaradzic/bimg) - Extensive C++ image library
**NOTE**: Many parts of the code is taken from _bimg_ library.
[License (BSD 2-clause)](https://github.com/septag/dds-ktx/blob/master/LICENSE)
--------------------------------------------------------------------------
<a href="http://opensource.org/licenses/BSD-2-Clause" target="_blank">
<img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">
</a>
Copyright 2018 Sepehr Taghdisian. All rights reserved.
https://github.com/septag/dds-ktx
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,11 @@
glslcc -i quad.vert --lang hlsl --bin -o quad_hlsl.vert.h --cvar quad
glslcc -i quad.vert --lang glsl --flatten-ubos --profile 330 -o quad_glsl.vert.h --cvar quad
glslcc -i quad.vert --lang metal -o quad_metal.vert.h --cvar quad
glslcc -i quad.frag --lang hlsl --bin -o quad_hlsl.frag.h --cvar quad
glslcc -i quad.frag --lang glsl --flatten-ubos --profile 330 -o quad_glsl.frag.h --cvar quad
glslcc -i quad.frag --lang metal -o quad_metal.frag.h --cvar quad
glslcc -i quad.frag --lang hlsl --bin -o quad_cubemap_hlsl.frag.h --cvar quad_cubemap --defines CUBEMAP
glslcc -i quad.frag --lang glsl --flatten-ubos --profile 330 -o quad_cubemap_glsl.frag.h --cvar quad_cubemap --defines CUBEMAP
glslcc -i quad.frag --lang metal -o quad_cubemap_metal.frag.h --cvar quad_cubemap --defines CUBEMAP

759
externals/dds-ktx/ctexview/ctexview.c vendored Normal file
View File

@@ -0,0 +1,759 @@
#if defined(_WIN32) || defined(_WIN64)
# define SOKOL_D3D11
# define _CRT_SECURE_NO_WARNINGS
# include "quad_hlsl.vert.h"
# include "quad_hlsl.frag.h"
# include "quad_cubemap_hlsl.frag.h"
# define SOKOL_LOG(s) OutputDebugStringA(s)
#elif defined(__linux__)
# include "quad_glsl.vert.h"
# include "quad_glsl.frag.h"
# include "quad_cubemap_glsl.frag.h"
# define SOKOL_GLCORE33
#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
# include "quad_metal.vert.h"
# include "quad_metal.frag.h"
# include "quad_cubemap_metal.frag.h"
# define SOKOL_METAL
#endif
#define SOKOL_IMPL
#define DDSKTX_IMPLEMENT
#define SOKOL_API_DECL static
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_glue.h"
#define DDSKTX_API static
#include "../dds-ktx.h"
#ifndef __APPLE__
# include <malloc.h>
#endif
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#define SOKOL_DEBUGTEXT_IMPL
#include "sokol_debugtext.h"
#define FONT_SCALE 1.1f
#define CHECKER_SIZE 8
typedef struct uniforms_fs
{
float color[4];
float args[4];
} uniforms_fs;
typedef struct uniforms_vs
{
float proj_mat[16];
} uniforms_vs;
typedef struct vertex
{
float x;
float y;
float u;
float v;
float w; // reserved for cubemapping
} vertex;
typedef struct ctexview_state
{
sg_pass_action pass_action;
void* file_data;
int file_size;
ddsktx_texture_info texinfo;
sg_image tex;
sg_shader shader;
sg_shader shader_cubemap;
sg_pipeline pip;
sg_pipeline pip_cubemap;
sg_pipeline pip_checker;
sg_buffer vb;
sg_buffer ib;
sg_buffer vb_checker;
sg_image checker;
bool inv_text_color;
uniforms_fs vars_fs;
int cur_mip;
int cur_slice;
int cube_face;
} ctexview_state;
ctexview_state g_state;
static const vertex k_vertices[] = {
{ -1.0f, -1.0f, 0.0f, 1.0f, 0 },
{ 1.0f, -1.0f, 1.0f, 1.0f, 0 },
{ 1.0f, 1.0f, 1.0f, 0.0f, 0 },
{ -1.0f, 1.0f, 0.0f, 0.0f, 0 },
};
static const uint16_t k_indices[] = { 0, 2, 1, 2, 0, 3 };
static const char* k_cube_face_names[DDSKTX_CUBE_FACE_COUNT] = {
"X+",
"X-",
"Y+",
"Y-",
"Z+",
"Z-"
};
#if defined(_WIN32) || defined(_WIN64)
static desktop_size(int* width, int* height)
{
RECT desktop;
const HWND hDesktop = GetDesktopWindow();
GetWindowRect(hDesktop, &desktop);
*width = desktop.right;
*height = desktop.bottom;
}
#endif
static int nearest_pow2(int n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n++;
return n;
}
// https://en.wikipedia.org/wiki/Cube_mapping
static void convert_cube_uv_to_xyz(int index, float u, float v, float* x, float* y, float* z)
{
// convert range 0 to 1 to -1 to 1
float uc = 2.0f * u - 1.0f;
float vc = 2.0f * v - 1.0f;
switch (index) {
case 0: *x = 1.0f; *y = vc; *z = -uc; break; // POSITIVE X
case 1: *x = -1.0f; *y = vc; *z = uc; break; // NEGATIVE X
case 2: *x = uc; *y = 1.0f; *z = -vc; break; // POSITIVE Y
case 3: *x = uc; *y = -1.0f; *z = vc; break; // NEGATIVE Y
case 4: *x = uc; *y = vc; *z = 1.0f; break; // POSITIVE Z
case 5: *x = -uc; *y = vc; *z = -1.0f; break; // NEGATIVE Z
}
}
static void set_cube_face(int index)
{
if (g_state.texinfo.flags & DDSKTX_TEXTURE_FLAG_CUBEMAP) {
assert(index >= 0 && index < DDSKTX_CUBE_FACE_COUNT);
vertex vertices[4];
memcpy(vertices, k_vertices, sizeof(k_vertices));
for (int i = 0; i < 4; i++) {
float x, y, z;
convert_cube_uv_to_xyz(index, vertices[i].u, vertices[i].v, &x, &y, &z);
vertices[i].u = x;
vertices[i].v = y;
vertices[i].w = z;
}
sg_update_buffer(g_state.vb, vertices, sizeof(vertices));
}
}
static void adjust_checker_coords(int width, int height)
{
int count_x = width/CHECKER_SIZE;
int count_y = height/CHECKER_SIZE;
float ratio = (float)width / (float)height;
float u, v;
if (width > height) {
u = (float)count_x;
v = (float)count_y * ratio;
}
else {
v = (float)count_y;
u = (float)count_x / ratio;
}
vertex vertices[4];
memcpy(vertices, k_vertices, sizeof(k_vertices));
for (int i = 0; i < 4; i++) {
vertices[i].u = vertices[i].u != 0 ? u : 0;
vertices[i].v = vertices[i].v != 0 ? v : 0;
}
sg_update_buffer(g_state.vb_checker, vertices, sizeof(vertices));
}
static void sx_mat4_ortho(float mat[16], float width, float height, float zn, float zf, float offset, bool ogl_ndc)
{
const float d = zf - zn;
const float cc = (ogl_ndc ? 2.0f : 1.0f) / d;
const float ff = ogl_ndc ? -(zn + zf) / d : -zn / d;
mat[0] = 2.0f / width;
mat[1] = 0;
mat[2] = 0;
mat[3] = 0;
mat[4] = 0;
mat[5] = 2.0f / height;
mat[6] = 0;
mat[7] = 0;
mat[8] = 0;
mat[9] = 0;
mat[10] = -cc;
mat[11] = 0;
mat[12] = offset;
mat[13] = 0;
mat[14] = ff;
mat[15] = 1.0f;
}
static void sx_mat4_ident(float mat[16])
{
mat[0] = 1.0f;
mat[1] = 0;
mat[2] = 0;
mat[3] = 0;
mat[4] = 0;
mat[5] = 1.0f;
mat[6] = 0;
mat[7] = 0;
mat[8] = 0;
mat[9] = 0;
mat[10] = 1.0f;
mat[11] = 0;
mat[12] = 0;
mat[13] = 0;
mat[14] = 0;
mat[15] = 1.0f;
}
static sg_image create_checker_texture(int checker_size, int size, uint32_t colors[2])
{
assert(size % 4 == 0 && "size must be multiple of four");
assert(size % checker_size == 0 && "checker_size must be dividable by size");
int size_bytes = size * size * sizeof(uint32_t);
uint32_t* pixels = malloc(size_bytes);
assert(pixels);
// split into tiles and color them
int tiles_x = size / checker_size;
int tiles_y = size / checker_size;
int num_tiles = tiles_x * tiles_y;
int* poss = malloc(sizeof(int) * 2 * num_tiles);
assert(poss);
int _x = 0, _y = 0;
for (int i = 0; i < num_tiles; i++) {
poss[i*2] = _x;
poss[i*2 + 1] = _y;
_x += checker_size;
if (_x >= size) {
_x = 0;
_y += checker_size;
}
}
int color_idx = 0;
for (int i = 0; i < num_tiles; i++) {
int* p = poss + i*2;
uint32_t c = colors[color_idx];
if (i == 0 || ((i + 1) % tiles_x) != 0)
color_idx = !color_idx;
int end_x = p[0] + checker_size;
int end_y = p[1] + checker_size;
for (int y = p[1]; y < end_y; y++) {
for (int x = p[0]; x < end_x; x++) {
int pixel = x + y * size;
pixels[pixel] = c;
}
}
}
sg_image tex = sg_make_image(&(sg_image_desc) {
.width = size,
.height = size,
.num_mipmaps = 1,
.pixel_format = SG_PIXELFORMAT_RGBA8,
.content = (sg_image_content){.subimage[0][0].ptr = pixels,
.subimage[0][0].size = size_bytes }
});
free(poss);
free(pixels);
return tex;
}
static void print_msg(const char* fmt, ...)
{
char msg[1024];
va_list args;
va_start(args, fmt);
vsnprintf(msg, sizeof(msg), fmt, args);
va_end(args);
#if defined(_WIN32) || defined(_WIN64)
MessageBoxA(NULL, msg, "DDS/KTX viewer", MB_OK);
#else
puts(msg);
#endif
}
static sg_shader_desc get_shader_desc(const void* vs_data, uint32_t vs_size, const void* fs_data,
uint32_t fs_size, sg_image_type imgtype)
{
return (sg_shader_desc){
.attrs = {
[0] = {.name = "a_pos", .sem_name = "POSITION" },
[1] = {.name = "a_uv", .sem_name = "TEXCOORD" }
},
.vs = {
#ifdef SOKOL_D3D11
.byte_code = (const uint8_t*)vs_data,
.byte_code_size = vs_size,
#else
.source = (const char*)vs_data,
#endif
#ifdef SOKOL_METAL
.entry = "main0",
#endif
.uniform_blocks[0] = {
.size = sizeof(uniforms_vs),
.uniforms = {
[0] = {.name = "proj_mat", .type = SG_UNIFORMTYPE_MAT4 },
}
}
},
.fs = {
#ifdef SOKOL_D3D11
.byte_code = (const uint8_t*)fs_data,
.byte_code_size = fs_size,
#else
.source = (const char*)fs_data,
#endif
#ifdef SOKOL_METAL
.entry = "main0",
#endif
.images[0] = {
.name = "tex_image",
.type = imgtype
},
.uniform_blocks[0] = {
.size = sizeof(uniforms_fs),
.uniforms = {
[0] = {.name = "color", .type = SG_UNIFORMTYPE_FLOAT4 },
[1] = {.name = "target_lod", SG_UNIFORMTYPE_FLOAT4 }
}
}
}
};
}
static void init(void)
{
sg_setup(&(sg_desc) {
.context = sapp_sgcontext()
});
sg_image_type imgtype = (g_state.texinfo.flags & DDSKTX_TEXTURE_FLAG_CUBEMAP) ? SG_IMAGETYPE_CUBE : SG_IMAGETYPE_2D;
g_state.pass_action = (sg_pass_action) {
.colors[0] = { .action = SG_ACTION_CLEAR, .val = {0, 0, 0, 1.0f} }
};
g_state.vb = sg_make_buffer(&(sg_buffer_desc) {
.usage = SG_USAGE_DYNAMIC,
.type = SG_BUFFERTYPE_VERTEXBUFFER,
.size = sizeof(k_vertices)
});
g_state.vb_checker = sg_make_buffer(&(sg_buffer_desc) {
.usage = SG_USAGE_DYNAMIC,
.type = SG_BUFFERTYPE_VERTEXBUFFER,
.size = sizeof(k_vertices)
});
g_state.ib = sg_make_buffer(&(sg_buffer_desc) {
.usage = SG_USAGE_IMMUTABLE,
.type = SG_BUFFERTYPE_INDEXBUFFER,
.size = sizeof(k_indices),
.content = k_indices
});
{
sg_shader_desc desc = get_shader_desc(quad_vs_data, quad_vs_size, quad_fs_data, quad_fs_size,
SG_IMAGETYPE_2D);
g_state.shader = sg_make_shader(&desc);
}
{
sg_shader_desc desc = get_shader_desc(quad_vs_data, quad_vs_size, quad_cubemap_fs_data,
quad_cubemap_fs_size, SG_IMAGETYPE_CUBE);
g_state.shader_cubemap = sg_make_shader(&desc);
}
sg_pipeline_desc pip_desc = (sg_pipeline_desc) {
.layout = {
.buffers[0] = {
.stride = sizeof(vertex),
},
.attrs = {
[0] = {.offset = 0, .format = SG_VERTEXFORMAT_FLOAT2 },
[1] = {.offset = 8, .format = SG_VERTEXFORMAT_FLOAT3 }
}
},
.primitive_type = SG_PRIMITIVETYPE_TRIANGLES,
.index_type = SG_INDEXTYPE_UINT16,
.rasterizer = {
.cull_mode = SG_CULLMODE_BACK
},
.blend = {
.enabled = true,
.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
}
};
{
pip_desc.shader = g_state.shader;
g_state.pip = sg_make_pipeline(&pip_desc);
}
{
pip_desc.shader = g_state.shader_cubemap;
g_state.pip_cubemap = sg_make_pipeline(&pip_desc);
}
// main texture (dds-ktx)
if (imgtype == SG_IMAGETYPE_CUBE) {
set_cube_face(0);
} else {
sg_update_buffer(g_state.vb, k_vertices, sizeof(k_vertices));
}
adjust_checker_coords(sapp_width(), sapp_height());
sg_image_desc desc = {
.type = imgtype,
.width = g_state.texinfo.width,
.height = g_state.texinfo.height,
.depth = 1,
.num_mipmaps = g_state.texinfo.num_mips,
.min_filter = SG_FILTER_NEAREST,
.mag_filter = SG_FILTER_NEAREST
};
switch (g_state.texinfo.format) {
case DDSKTX_FORMAT_BC1: desc.pixel_format = SG_PIXELFORMAT_BC1_RGBA; break;
case DDSKTX_FORMAT_BC2: desc.pixel_format = SG_PIXELFORMAT_BC2_RGBA; break;
case DDSKTX_FORMAT_BC3: desc.pixel_format = SG_PIXELFORMAT_BC3_RGBA; break;
case DDSKTX_FORMAT_BC4: desc.pixel_format = SG_PIXELFORMAT_BC4_R; break;
case DDSKTX_FORMAT_BC5: desc.pixel_format = SG_PIXELFORMAT_BC5_RG; break;
case DDSKTX_FORMAT_BC6H: desc.pixel_format = SG_PIXELFORMAT_BC6H_RGBF; break;
case DDSKTX_FORMAT_BC7: desc.pixel_format = SG_PIXELFORMAT_BC7_RGBA; break;
case DDSKTX_FORMAT_A8:
case DDSKTX_FORMAT_R8: desc.pixel_format = SG_PIXELFORMAT_R8; break;
case DDSKTX_FORMAT_RGBA8:
case DDSKTX_FORMAT_RGBA8S: desc.pixel_format = SG_PIXELFORMAT_RGBA8; break;
case DDSKTX_FORMAT_RG16: desc.pixel_format = SG_PIXELFORMAT_RG16; break;
case DDSKTX_FORMAT_RGB8: desc.pixel_format = SG_PIXELFORMAT_RGBA8; break;
case DDSKTX_FORMAT_R16: desc.pixel_format = SG_PIXELFORMAT_R16; break;
case DDSKTX_FORMAT_R32F: desc.pixel_format = SG_PIXELFORMAT_R32F; break;
case DDSKTX_FORMAT_R16F: desc.pixel_format = SG_PIXELFORMAT_R16F; break;
case DDSKTX_FORMAT_RG16F: desc.pixel_format = SG_PIXELFORMAT_RG16F; break;
case DDSKTX_FORMAT_RG16S: desc.pixel_format = SG_PIXELFORMAT_RG16; break;
case DDSKTX_FORMAT_RGBA16F: desc.pixel_format = SG_PIXELFORMAT_RGBA16F; break;
case DDSKTX_FORMAT_RGBA16: desc.pixel_format = SG_PIXELFORMAT_RGBA16; break;
case DDSKTX_FORMAT_BGRA8: desc.pixel_format = SG_PIXELFORMAT_BGRA8; break;
case DDSKTX_FORMAT_RGB10A2: desc.pixel_format = SG_PIXELFORMAT_RGB10A2; break;
case DDSKTX_FORMAT_RG11B10F: desc.pixel_format = SG_PIXELFORMAT_RG11B10F; break;
case DDSKTX_FORMAT_RG8: desc.pixel_format = SG_PIXELFORMAT_RG8; break;
case DDSKTX_FORMAT_RG8S: desc.pixel_format = SG_PIXELFORMAT_RG8; break;
default: assert(0); exit(-1);
}
int num_faces = imgtype == SG_IMAGETYPE_CUBE ? 6 : 1;
for (int face = 0; face < num_faces; face++) {
for (int mip = 0; mip < g_state.texinfo.num_mips; mip++) {
ddsktx_sub_data subdata;
ddsktx_get_sub(&g_state.texinfo, &subdata, g_state.file_data, g_state.file_size, 0, face, mip);
desc.content.subimage[face][mip].ptr = subdata.buff;
desc.content.subimage[face][mip].size = subdata.size_bytes;
}
}
g_state.tex = sg_make_image(&desc);
sdtx_setup(&(sdtx_desc_t) {
.fonts = {
[0] = sdtx_font_c64(),
},
});
sdtx_set_context(SDTX_DEFAULT_CONTEXT);
sdtx_canvas((float)sapp_width() * (1.0f/FONT_SCALE), (float)sapp_height() * (1.0f/FONT_SCALE));
uint32_t checker_colors[] = { 0xff999999, 0xff666666 };
g_state.checker = create_checker_texture(8, 16, checker_colors);
g_state.vars_fs.color[0] = g_state.vars_fs.color[1] = g_state.vars_fs.color[2] = g_state.vars_fs.color[3] = 1.0f;
}
static const char* texture_type_info()
{
static char info[128];
const char* type = "2D";
if (g_state.texinfo.flags & DDSKTX_TEXTURE_FLAG_CUBEMAP) {
snprintf(info, sizeof(info), "Cube (%s)", k_cube_face_names[g_state.cube_face]);
} else if (g_state.texinfo.depth > 1) {
snprintf(info, sizeof(info), "3D (%d/%d)", g_state.cur_slice, g_state.texinfo.depth);
} else {
strcpy(info, "2D");
}
return info;
}
static void frame(void)
{
sdtx_home();
sdtx_origin(1, 1);
sdtx_pos(0, 0);
sdtx_color3b(!g_state.inv_text_color ? 255 : 0, !g_state.inv_text_color ? 255 : 0, 0);
sdtx_printf("%s\t%dx%d (mip %d/%d)",
ddsktx_format_str(g_state.texinfo.format), g_state.texinfo.width,
g_state.texinfo.height, g_state.cur_mip + 1, g_state.texinfo.num_mips);
sdtx_crlf();
sdtx_printf("%s\tmask: %c%c%c%c\t",
texture_type_info(),
g_state.vars_fs.color[0] == 1.0f ? 'R' : 'X',
g_state.vars_fs.color[1] == 1.0f ? 'G' : 'X',
g_state.vars_fs.color[2] == 1.0f ? 'B' : 'X',
g_state.vars_fs.color[3] == 1.0f ? 'A' : 'X');
sdtx_crlf();
g_state.vars_fs.args[0] = (float)g_state.cur_mip;
sg_begin_default_pass(&g_state.pass_action, sapp_width(), sapp_height());
if (g_state.tex.id) {
sg_bindings bindings = {
.index_buffer = g_state.ib,
};
if (g_state.checker.id) {
bindings.fs_images[0] = g_state.checker;
bindings.vertex_buffers[0] = g_state.vb_checker;
uniforms_fs ufs = {
{1.0f, 1.0f, 1.0f, 1.0f},
{0, 0, 0, 0}
};
uniforms_vs uvs;
float ratio = (float)sapp_width() / (float)sapp_height();
float w = 1.0f, h = 1.0f;
if (sapp_width() > sapp_height()) {
h = w/ratio;
} else {
w = h*ratio;
}
sx_mat4_ortho(uvs.proj_mat, w, h, -1.0f, 1.0f, 0, false);
sg_apply_pipeline(g_state.pip);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &uvs, sizeof(uvs));
sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, &ufs, sizeof(ufs));
sg_apply_bindings(&bindings);
sg_draw(0, 6, 1);
}
uniforms_vs uvs;
sx_mat4_ident(uvs.proj_mat);
bindings.fs_images[0] = g_state.tex;
bindings.vertex_buffers[0] = g_state.vb;
// for the image to the window and keep the ratio
int w = g_state.texinfo.width;
int h = g_state.texinfo.height;
{
float ratio_outer = (float)sapp_width() / (float)sapp_height();
float ratio_inner = (float)w / (float)h;
float scale = (ratio_inner >= ratio_outer) ?
((float)sapp_width()/(float)w) :
((float)sapp_height()/(float)h);
w = (int)((float)w * scale);
h = (int)((float)h * scale);
}
sg_apply_viewport((sapp_width() - w)/2, (sapp_height() - h)/2, w, h, true);
sg_apply_pipeline((g_state.texinfo.flags & DDSKTX_TEXTURE_FLAG_CUBEMAP) ? g_state.pip_cubemap : g_state.pip);
sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &uvs, sizeof(uvs));
sg_apply_uniforms(SG_SHADERSTAGE_FS, 0, &g_state.vars_fs, sizeof(g_state.vars_fs));
sg_apply_bindings(&bindings);
sg_draw(0, 6, 1);
}
sg_apply_viewport(0, 0, sapp_width(), sapp_height(), true);
sdtx_draw();
sg_end_pass();
sg_commit();
}
static void release(void)
{
free(g_state.file_data);
sg_destroy_pipeline(g_state.pip);
sg_destroy_pipeline(g_state.pip_checker);
sg_destroy_pipeline(g_state.pip_cubemap);
sg_destroy_shader(g_state.shader);
sg_destroy_shader(g_state.shader_cubemap);
sg_destroy_buffer(g_state.vb);
sg_destroy_buffer(g_state.vb_checker);
sg_destroy_buffer(g_state.ib);
sg_destroy_image(g_state.tex);
sg_destroy_image(g_state.checker);
sdtx_shutdown();
sg_shutdown();
}
static void on_events(const sapp_event* e)
{
switch (e->type) {
case SAPP_EVENTTYPE_RESIZED:
sdtx_canvas((float)sapp_width() * (1.0f/FONT_SCALE), (float)sapp_height() * (1.0f/FONT_SCALE));
adjust_checker_coords(e->window_width, e->window_height);
break;
case SAPP_EVENTTYPE_KEY_DOWN:
if (e->key_code == SAPP_KEYCODE_GRAVE_ACCENT) {
g_state.inv_text_color = !g_state.inv_text_color;
}
if (e->key_code == SAPP_KEYCODE_A) {
g_state.vars_fs.color[3] = g_state.vars_fs.color[3] == 1.0f ? 0 : 1.0f;
}
if (e->key_code == SAPP_KEYCODE_R) {
g_state.vars_fs.color[0] = g_state.vars_fs.color[0] == 1.0f ? 0 : 1.0f;
}
if (e->key_code == SAPP_KEYCODE_G) {
g_state.vars_fs.color[1] = g_state.vars_fs.color[1] == 1.0f ? 0 : 1.0f;
}
if (e->key_code == SAPP_KEYCODE_B) {
g_state.vars_fs.color[2] = g_state.vars_fs.color[2] == 1.0f ? 0 : 1.0f;
}
if (e->key_code == SAPP_KEYCODE_UP) {
g_state.cur_mip = (g_state.cur_mip + 1) >= g_state.texinfo.num_mips ? (g_state.texinfo.num_mips - 1) : g_state.cur_mip + 1;
}
if (e->key_code == SAPP_KEYCODE_DOWN) {
g_state.cur_mip = (g_state.cur_mip > 0) ? g_state.cur_mip - 1 : 0;
}
if (e->key_code == SAPP_KEYCODE_ESCAPE) {
sapp_request_quit();
}
if (e->key_code == SAPP_KEYCODE_F) {
g_state.cube_face = (g_state.cube_face + 1) % DDSKTX_CUBE_FACE_COUNT;
set_cube_face(g_state.cube_face);
}
break;
}
}
sapp_desc sokol_main(int argc, char* argv[])
{
if (argc <= 1) {
print_msg("Provide a file to load as argument");
exit(-1);
}
FILE* f = fopen(argv[1], "rb");
if (!f) {
print_msg("Error: could not open file: %s\n", argv[1]);
exit(-1);
}
fseek(f, 0, SEEK_END);
int size = (int)ftell(f);
if (size == 0) {
print_msg("Error: file '%s' is empty\n", argv[1]);
exit(-1);
}
fseek(f, 0, SEEK_SET);
void* data = malloc(size);
if (!data) {
print_msg("out of memory: requested size: %d\n", (int)size);
exit(-1);
}
if (fread(data, 1, size, f) != size) {
print_msg("could not read file data : %s\n", argv[1]);
exit(-1);
}
g_state.file_data = data;
g_state.file_size = size;
fclose(f);
ddsktx_texture_info tc = {0};
ddsktx_error img_err;
if (!ddsktx_parse(&tc, data, size, &img_err)) {
print_msg("Loading image '%s' failed: %s", argv[1], img_err.msg);
exit(-1);
}
g_state.texinfo = tc;
int window_w = tc.width;
int window_h = tc.height;
#if defined(_WIN32) || defined(_WIN64)
int desktop_w, desktop_h;
desktop_size(&desktop_w, &desktop_h);
float ratio = (float)tc.width / (float)tc.height;
if (window_w > (desktop_w - 50)) {
window_w = desktop_w - 50;
window_h = (int)((float)window_w / ratio);
}
if (window_h > (desktop_h - 50)) {
window_h = desktop_h - 50;
window_w = (int)((float)window_h * ratio);
}
#endif
return (sapp_desc) {
.init_cb = init,
.frame_cb = frame,
.cleanup_cb = release,
.event_cb = on_events,
.width = window_w,
.height = window_h,
.window_title = "DDS/KTX viewer",
.swap_interval = 2,
.sample_count = 1
};
}

BIN
externals/dds-ktx/ctexview/ctexview.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

28
externals/dds-ktx/ctexview/quad.frag vendored Normal file
View File

@@ -0,0 +1,28 @@
#version 450
precision mediump float;
layout (location = TEXCOORD0) in vec3 f_uv;
layout (location = SV_Target0) out vec4 frag_color;
#ifdef CUBEMAP
layout (binding = 0) uniform samplerCube tex_image;
#else
layout (binding = 0) uniform sampler2D tex_image;
#endif
layout (binding = 0, std140) uniform globals {
vec4 color;
vec4 target_lod;
};
void main()
{
#ifdef CUBEMAP
frag_color = textureLod(tex_image, f_uv, target_lod.x) * vec4(color.xyz, 1.0);
#else
frag_color = textureLod(tex_image, f_uv.xy, target_lod.x) * vec4(color.rgb, 1.0);
#endif
frag_color.a = color.a < 1.0 ? 1.0 : frag_color.a;
}

15
externals/dds-ktx/ctexview/quad.vert vendored Normal file
View File

@@ -0,0 +1,15 @@
#version 450
layout (location = POSITION) in vec2 a_pos;
layout (location = TEXCOORD0) in vec3 a_uv;
layout (location = TEXCOORD0) out vec3 f_uv;
layout (binding = 0, std140) uniform globals {
mat4 proj_mat;
};
void main() {
gl_Position = proj_mat * vec4(a_pos, 0, 1.0);
f_uv = a_uv;
}

View File

@@ -0,0 +1,21 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_cubemap_fs_size = 381;
static const unsigned int quad_cubemap_fs_data[384/4] = {
0x72657623, 0x6e6f6973, 0x30333320, 0x6e750a0a, 0x726f6669, 0x6576206d, 0x67203463, 0x61626f6c,
0x325b736c, 0x750a3b5d, 0x6f66696e, 0x73206d72, 0x6c706d61, 0x75437265, 0x74206562, 0x695f7865,
0x6567616d, 0x6c0a0a3b, 0x756f7961, 0x6f6c2874, 0x69746163, 0x3d206e6f, 0x20293020, 0x2074756f,
0x34636576, 0x61726620, 0x6f635f67, 0x3b726f6c, 0x206e690a, 0x33636576, 0x755f6620, 0x0a0a3b76,
0x64696f76, 0x69616d20, 0x0a29286e, 0x20200a7b, 0x72662020, 0x635f6761, 0x726f6c6f, 0x74203d20,
0x75747865, 0x6f4c6572, 0x65742864, 0x6d695f78, 0x2c656761, 0x755f6620, 0x67202c76, 0x61626f6c,
0x315b736c, 0x29782e5d, 0x76202a20, 0x28346365, 0x626f6c67, 0x5b736c61, 0x782e5d30, 0x202c7a79,
0x29302e31, 0x20200a3b, 0x6c662020, 0x2074616f, 0x3b37345f, 0x2020200a, 0x20666920, 0x6f6c6728,
0x736c6162, 0x2e5d305b, 0x203c2077, 0x29302e31, 0x2020200a, 0x200a7b20, 0x20202020, 0x5f202020,
0x3d203734, 0x302e3120, 0x20200a3b, 0x0a7d2020, 0x20202020, 0x65736c65, 0x2020200a, 0x200a7b20,
0x20202020, 0x5f202020, 0x3d203734, 0x61726620, 0x6f635f67, 0x2e726f6c, 0x200a3b77, 0x7d202020,
0x2020200a, 0x61726620, 0x6f635f67, 0x2e726f6c, 0x203d2077, 0x3b37345f, 0x0a0a7d0a, 0x00000000 };

View File

@@ -0,0 +1,39 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_cubemap_fs_size = 988;
static const unsigned int quad_cubemap_fs_data[988/4] = {
0x43425844, 0xdcce51ee, 0x91aaa444, 0x1f1ddd8b, 0x4bd76050, 0x00000001, 0x000003dc, 0x00000005,
0x00000034, 0x000001d8, 0x0000020c, 0x00000240, 0x00000340, 0x46454452, 0x0000019c, 0x00000001,
0x000000c4, 0x00000003, 0x0000003c, 0xffff0500, 0x00008100, 0x00000173, 0x31314452, 0x0000003c,
0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x0000009c, 0x00000003,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000af, 0x00000002,
0x00000005, 0x00000009, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x000000b9, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x7865745f, 0x616d695f,
0x735f6567, 0x6c706d61, 0x74007265, 0x695f7865, 0x6567616d, 0x6f6c6700, 0x736c6162, 0xababab00,
0x000000b9, 0x00000002, 0x000000dc, 0x00000020, 0x00000000, 0x00000000, 0x0000012c, 0x00000000,
0x00000010, 0x00000002, 0x00000140, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
0x00000164, 0x00000010, 0x00000010, 0x00000002, 0x00000140, 0x00000000, 0xffffffff, 0x00000000,
0xffffffff, 0x00000000, 0x5f31325f, 0x6f6c6f63, 0x6c660072, 0x3474616f, 0xababab00, 0x00030001,
0x00040001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000136,
0x5f31325f, 0x67726174, 0x6c5f7465, 0x4d00646f, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820,
0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x4e475349, 0x0000002c,
0x00000001, 0x00000008, 0x00000020, 0x00000002, 0x00000000, 0x00000003, 0x00000000, 0x00000707,
0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074,
0x58454853, 0x000000f8, 0x00000050, 0x0000003e, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000,
0x00000002, 0x0300005a, 0x00106000, 0x00000000, 0x04003058, 0x00107000, 0x00000000, 0x00005555,
0x03001062, 0x00101072, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002,
0x08000031, 0x00100012, 0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x00004001, 0x3f800000,
0x8e000048, 0x80000182, 0x00155543, 0x001000f2, 0x00000001, 0x00101246, 0x00000000, 0x00107936,
0x00000000, 0x00106000, 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x08000038, 0x00102072,
0x00000000, 0x00100796, 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x09000037, 0x00102082,
0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0010000a, 0x00000001, 0x0100003e,
0x54415453, 0x00000094, 0x00000005, 0x00000002, 0x00000000, 0x00000002, 0x00000002, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };

View File

@@ -0,0 +1,32 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_cubemap_fs_size = 738;
static const unsigned int quad_cubemap_fs_data[740/4] = {
0x636e6923, 0x6564756c, 0x656d3c20, 0x5f6c6174, 0x6c647473, 0x0a3e6269, 0x636e6923, 0x6564756c,
0x69733c20, 0x732f646d, 0x2e646d69, 0x0a0a3e68, 0x6e697375, 0x616e2067, 0x7073656d, 0x20656361,
0x6174656d, 0x0a0a3b6c, 0x75727473, 0x67207463, 0x61626f6c, 0x7b0a736c, 0x2020200a, 0x6f6c6620,
0x20347461, 0x6f6c6f63, 0x200a3b72, 0x66202020, 0x74616f6c, 0x61742034, 0x74656772, 0x646f6c5f,
0x3b7d0a3b, 0x74730a0a, 0x74637572, 0x69616d20, 0x6f5f306e, 0x7b0a7475, 0x2020200a, 0x6f6c6620,
0x20347461, 0x67617266, 0x6c6f635f, 0x5b20726f, 0x6c6f635b, 0x3028726f, 0x3b5d5d29, 0x0a3b7d0a,
0x7274730a, 0x20746375, 0x6e69616d, 0x6e695f30, 0x200a7b0a, 0x66202020, 0x74616f6c, 0x5f662033,
0x5b207675, 0x6573755b, 0x6f6c2872, 0x29326e63, 0x0a3b5d5d, 0x0a0a3b7d, 0x67617266, 0x746e656d,
0x69616d20, 0x6f5f306e, 0x6d207475, 0x306e6961, 0x69616d28, 0x695f306e, 0x6e69206e, 0x735b5b20,
0x65676174, 0x5d6e695f, 0x63202c5d, 0x74736e6f, 0x20746e61, 0x626f6c67, 0x26736c61, 0x31325f20,
0x625b5b20, 0x65666675, 0x29302872, 0x202c5d5d, 0x74786574, 0x63657275, 0x3c656275, 0x616f6c66,
0x74203e74, 0x695f7865, 0x6567616d, 0x745b5b20, 0x75747865, 0x30286572, 0x2c5d5d29, 0x6d617320,
0x72656c70, 0x78657420, 0x616d695f, 0x6d536567, 0x20726c70, 0x61735b5b, 0x656c706d, 0x29302872,
0x0a295d5d, 0x20200a7b, 0x616d2020, 0x5f306e69, 0x2074756f, 0x2074756f, 0x7d7b203d, 0x20200a3b,
0x756f2020, 0x72662e74, 0x635f6761, 0x726f6c6f, 0x74203d20, 0x695f7865, 0x6567616d, 0x6d61732e,
0x28656c70, 0x5f786574, 0x67616d69, 0x706d5365, 0x202c726c, 0x662e6e69, 0x2c76755f, 0x76656c20,
0x5f286c65, 0x742e3132, 0x65677261, 0x6f6c5f74, 0x29782e64, 0x202a2029, 0x616f6c66, 0x5f283474,
0x632e3132, 0x726f6c6f, 0x7a79782e, 0x2e31202c, 0x0a3b2930, 0x20202020, 0x616f6c66, 0x345f2074,
0x200a3b37, 0x69202020, 0x5f282066, 0x632e3132, 0x726f6c6f, 0x3c20772e, 0x302e3120, 0x20200a29,
0x0a7b2020, 0x20202020, 0x20202020, 0x2037345f, 0x2e31203d, 0x200a3b30, 0x7d202020, 0x2020200a,
0x736c6520, 0x20200a65, 0x0a7b2020, 0x20202020, 0x20202020, 0x2037345f, 0x756f203d, 0x72662e74,
0x635f6761, 0x726f6c6f, 0x0a3b772e, 0x20202020, 0x20200a7d, 0x756f2020, 0x72662e74, 0x635f6761,
0x726f6c6f, 0x3d20772e, 0x37345f20, 0x20200a3b, 0x65722020, 0x6e727574, 0x74756f20, 0x0a7d0a3b,
0x0000000a };

View File

@@ -0,0 +1,21 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_fs_size = 382;
static const unsigned int quad_fs_data[384/4] = {
0x72657623, 0x6e6f6973, 0x30333320, 0x6e750a0a, 0x726f6669, 0x6576206d, 0x67203463, 0x61626f6c,
0x325b736c, 0x750a3b5d, 0x6f66696e, 0x73206d72, 0x6c706d61, 0x44327265, 0x78657420, 0x616d695f,
0x0a3b6567, 0x79616c0a, 0x2874756f, 0x61636f6c, 0x6e6f6974, 0x30203d20, 0x756f2029, 0x65762074,
0x66203463, 0x5f676172, 0x6f6c6f63, 0x690a3b72, 0x6576206e, 0x66203363, 0x3b76755f, 0x6f760a0a,
0x6d206469, 0x286e6961, 0x0a7b0a29, 0x20202020, 0x67617266, 0x6c6f635f, 0x3d20726f, 0x78657420,
0x65727574, 0x28646f4c, 0x5f786574, 0x67616d69, 0x66202c65, 0x2e76755f, 0x202c7978, 0x626f6c67,
0x5b736c61, 0x782e5d31, 0x202a2029, 0x34636576, 0x6f6c6728, 0x736c6162, 0x2e5d305b, 0x2c7a7978,
0x302e3120, 0x200a3b29, 0x66202020, 0x74616f6c, 0x39345f20, 0x20200a3b, 0x66692020, 0x6c672820,
0x6c61626f, 0x5d305b73, 0x3c20772e, 0x302e3120, 0x20200a29, 0x0a7b2020, 0x20202020, 0x20202020,
0x2039345f, 0x2e31203d, 0x200a3b30, 0x7d202020, 0x2020200a, 0x736c6520, 0x20200a65, 0x0a7b2020,
0x20202020, 0x20202020, 0x2039345f, 0x7266203d, 0x635f6761, 0x726f6c6f, 0x0a3b772e, 0x20202020,
0x20200a7d, 0x72662020, 0x635f6761, 0x726f6c6f, 0x3d20772e, 0x39345f20, 0x0a7d0a3b, 0x0000000a };

View File

@@ -0,0 +1,17 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_vs_size = 257;
static const unsigned int quad_vs_data[260/4] = {
0x72657623, 0x6e6f6973, 0x30333320, 0x6e750a0a, 0x726f6669, 0x6576206d, 0x67203463, 0x61626f6c,
0x345b736c, 0x6c0a3b5d, 0x756f7961, 0x6f6c2874, 0x69746163, 0x3d206e6f, 0x20293020, 0x76206e69,
0x20326365, 0x6f705f61, 0x6f0a3b73, 0x76207475, 0x20336365, 0x76755f66, 0x616c0a3b, 0x74756f79,
0x636f6c28, 0x6f697461, 0x203d206e, 0x69202932, 0x6576206e, 0x61203363, 0x3b76755f, 0x6f760a0a,
0x6d206469, 0x286e6961, 0x0a7b0a29, 0x20202020, 0x505f6c67, 0x7469736f, 0x206e6f69, 0x616d203d,
0x67283474, 0x61626f6c, 0x305b736c, 0x67202c5d, 0x61626f6c, 0x315b736c, 0x67202c5d, 0x61626f6c,
0x325b736c, 0x67202c5d, 0x61626f6c, 0x335b736c, 0x2a20295d, 0x63657620, 0x5f612834, 0x2c736f70,
0x302e3020, 0x2e31202c, 0x0a3b2930, 0x20202020, 0x76755f66, 0x61203d20, 0x3b76755f, 0x0a0a7d0a,
0x00000000 };

View File

@@ -0,0 +1,39 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_fs_size = 988;
static const unsigned int quad_fs_data[988/4] = {
0x43425844, 0x1f031d00, 0xb00294b3, 0x863dd79d, 0x353015d5, 0x00000001, 0x000003dc, 0x00000005,
0x00000034, 0x000001d8, 0x0000020c, 0x00000240, 0x00000340, 0x46454452, 0x0000019c, 0x00000001,
0x000000c4, 0x00000003, 0x0000003c, 0xffff0500, 0x00008100, 0x00000173, 0x31314452, 0x0000003c,
0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x0000009c, 0x00000003,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000af, 0x00000002,
0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x000000b9, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x7865745f, 0x616d695f,
0x735f6567, 0x6c706d61, 0x74007265, 0x695f7865, 0x6567616d, 0x6f6c6700, 0x736c6162, 0xababab00,
0x000000b9, 0x00000002, 0x000000dc, 0x00000020, 0x00000000, 0x00000000, 0x0000012c, 0x00000000,
0x00000010, 0x00000002, 0x00000140, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
0x00000164, 0x00000010, 0x00000010, 0x00000002, 0x00000140, 0x00000000, 0xffffffff, 0x00000000,
0xffffffff, 0x00000000, 0x5f33325f, 0x6f6c6f63, 0x6c660072, 0x3474616f, 0xababab00, 0x00030001,
0x00040001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000136,
0x5f33325f, 0x67726174, 0x6c5f7465, 0x4d00646f, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820,
0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x4e475349, 0x0000002c,
0x00000001, 0x00000008, 0x00000020, 0x00000002, 0x00000000, 0x00000003, 0x00000000, 0x00000307,
0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074,
0x58454853, 0x000000f8, 0x00000050, 0x0000003e, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000,
0x00000002, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002,
0x08000031, 0x00100012, 0x00000000, 0x0020803a, 0x00000000, 0x00000000, 0x00004001, 0x3f800000,
0x8e000048, 0x800000c2, 0x00155543, 0x001000f2, 0x00000001, 0x00101046, 0x00000000, 0x00107936,
0x00000000, 0x00106000, 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x08000038, 0x00102072,
0x00000000, 0x00100796, 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x09000037, 0x00102082,
0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0010000a, 0x00000001, 0x0100003e,
0x54415453, 0x00000094, 0x00000005, 0x00000002, 0x00000000, 0x00000002, 0x00000002, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };

View File

@@ -0,0 +1,36 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_vs_size = 876;
static const unsigned int quad_vs_data[876/4] = {
0x43425844, 0x850b49a2, 0x1c1eb79a, 0x88cec8a9, 0xac646615, 0x00000001, 0x0000036c, 0x00000005,
0x00000034, 0x00000144, 0x00000198, 0x000001f0, 0x000002d0, 0x46454452, 0x00000108, 0x00000001,
0x00000064, 0x00000001, 0x0000003c, 0xfffe0500, 0x00008100, 0x000000e0, 0x31314452, 0x0000003c,
0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x0000005c, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x626f6c67, 0x00736c61,
0x0000005c, 0x00000001, 0x0000007c, 0x00000040, 0x00000000, 0x00000000, 0x000000a4, 0x00000000,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
0x5f39315f, 0x6a6f7270, 0x74616d5f, 0x6f6c6600, 0x78347461, 0xabab0034, 0x00030002, 0x00040004,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000b1, 0x7263694d,
0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x31207265,
0x00312e30, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x00000303, 0x00000041, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
0x00000707, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0xabab0044, 0x4e47534f, 0x00000050,
0x00000002, 0x00000008, 0x00000038, 0x00000002, 0x00000000, 0x00000003, 0x00000000, 0x00000807,
0x00000041, 0x00000000, 0x00000001, 0x00000003, 0x00000001, 0x0000000f, 0x43584554, 0x44524f4f,
0x5f565300, 0x69736f50, 0x6e6f6974, 0xababab00, 0x58454853, 0x000000d8, 0x00010050, 0x00000036,
0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f, 0x00101032, 0x00000000,
0x0300005f, 0x00101072, 0x00000001, 0x03000065, 0x00102072, 0x00000000, 0x04000067, 0x001020f2,
0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x05000036, 0x00102072, 0x00000000, 0x00101246,
0x00000001, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46, 0x00000000,
0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006, 0x00000000, 0x00208e46, 0x00000000,
0x00000000, 0x00100e46, 0x00000000, 0x08000000, 0x001020f2, 0x00000001, 0x00100e46, 0x00000000,
0x00208e46, 0x00000000, 0x00000003, 0x0100003e, 0x54415453, 0x00000094, 0x00000005, 0x00000001,
0x00000000, 0x00000004, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000 };

View File

@@ -0,0 +1,32 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_fs_size = 739;
static const unsigned int quad_fs_data[740/4] = {
0x636e6923, 0x6564756c, 0x656d3c20, 0x5f6c6174, 0x6c647473, 0x0a3e6269, 0x636e6923, 0x6564756c,
0x69733c20, 0x732f646d, 0x2e646d69, 0x0a0a3e68, 0x6e697375, 0x616e2067, 0x7073656d, 0x20656361,
0x6174656d, 0x0a0a3b6c, 0x75727473, 0x67207463, 0x61626f6c, 0x7b0a736c, 0x2020200a, 0x6f6c6620,
0x20347461, 0x6f6c6f63, 0x200a3b72, 0x66202020, 0x74616f6c, 0x61742034, 0x74656772, 0x646f6c5f,
0x3b7d0a3b, 0x74730a0a, 0x74637572, 0x69616d20, 0x6f5f306e, 0x7b0a7475, 0x2020200a, 0x6f6c6620,
0x20347461, 0x67617266, 0x6c6f635f, 0x5b20726f, 0x6c6f635b, 0x3028726f, 0x3b5d5d29, 0x0a3b7d0a,
0x7274730a, 0x20746375, 0x6e69616d, 0x6e695f30, 0x200a7b0a, 0x66202020, 0x74616f6c, 0x5f662033,
0x5b207675, 0x6573755b, 0x6f6c2872, 0x29326e63, 0x0a3b5d5d, 0x0a0a3b7d, 0x67617266, 0x746e656d,
0x69616d20, 0x6f5f306e, 0x6d207475, 0x306e6961, 0x69616d28, 0x695f306e, 0x6e69206e, 0x735b5b20,
0x65676174, 0x5d6e695f, 0x63202c5d, 0x74736e6f, 0x20746e61, 0x626f6c67, 0x26736c61, 0x33325f20,
0x625b5b20, 0x65666675, 0x29302872, 0x202c5d5d, 0x74786574, 0x32657275, 0x6c663c64, 0x3e74616f,
0x78657420, 0x616d695f, 0x5b206567, 0x7865745b, 0x65727574, 0x5d293028, 0x73202c5d, 0x6c706d61,
0x74207265, 0x695f7865, 0x6567616d, 0x6c706d53, 0x5b5b2072, 0x706d6173, 0x2872656c, 0x5d5d2930,
0x0a7b0a29, 0x20202020, 0x6e69616d, 0x756f5f30, 0x756f2074, 0x203d2074, 0x0a3b7d7b, 0x20202020,
0x2e74756f, 0x67617266, 0x6c6f635f, 0x3d20726f, 0x78657420, 0x616d695f, 0x732e6567, 0x6c706d61,
0x65742865, 0x6d695f78, 0x53656761, 0x726c706d, 0x6e69202c, 0x755f662e, 0x79782e76, 0x656c202c,
0x286c6576, 0x2e33325f, 0x67726174, 0x6c5f7465, 0x782e646f, 0x2a202929, 0x6f6c6620, 0x28347461,
0x2e33325f, 0x6f6c6f63, 0x79782e72, 0x31202c7a, 0x3b29302e, 0x2020200a, 0x6f6c6620, 0x5f207461,
0x0a3b3934, 0x20202020, 0x28206669, 0x2e33325f, 0x6f6c6f63, 0x20772e72, 0x2e31203c, 0x200a2930,
0x7b202020, 0x2020200a, 0x20202020, 0x39345f20, 0x31203d20, 0x0a3b302e, 0x20202020, 0x20200a7d,
0x6c652020, 0x200a6573, 0x7b202020, 0x2020200a, 0x20202020, 0x39345f20, 0x6f203d20, 0x662e7475,
0x5f676172, 0x6f6c6f63, 0x3b772e72, 0x2020200a, 0x200a7d20, 0x6f202020, 0x662e7475, 0x5f676172,
0x6f6c6f63, 0x20772e72, 0x345f203d, 0x200a3b39, 0x72202020, 0x72757465, 0x756f206e, 0x7d0a3b74,
0x00000a0a };

View File

@@ -0,0 +1,25 @@
// This file is automatically created by glslcc v1.7.3
// http://www.github.com/septag/glslcc
//
#pragma once
static const unsigned int quad_vs_size = 521;
static const unsigned int quad_vs_data[524/4] = {
0x636e6923, 0x6564756c, 0x656d3c20, 0x5f6c6174, 0x6c647473, 0x0a3e6269, 0x636e6923, 0x6564756c,
0x69733c20, 0x732f646d, 0x2e646d69, 0x0a0a3e68, 0x6e697375, 0x616e2067, 0x7073656d, 0x20656361,
0x6174656d, 0x0a0a3b6c, 0x75727473, 0x67207463, 0x61626f6c, 0x7b0a736c, 0x2020200a, 0x6f6c6620,
0x78347461, 0x72702034, 0x6d5f6a6f, 0x0a3b7461, 0x0a0a3b7d, 0x75727473, 0x6d207463, 0x306e6961,
0x74756f5f, 0x200a7b0a, 0x66202020, 0x74616f6c, 0x5f662033, 0x5b207675, 0x6573755b, 0x6f6c2872,
0x29326e63, 0x0a3b5d5d, 0x20202020, 0x616f6c66, 0x67203474, 0x6f505f6c, 0x69746973, 0x5b206e6f,
0x736f705b, 0x6f697469, 0x3b5d5d6e, 0x0a3b7d0a, 0x7274730a, 0x20746375, 0x6e69616d, 0x6e695f30,
0x200a7b0a, 0x66202020, 0x74616f6c, 0x5f612032, 0x20736f70, 0x74615b5b, 0x62697274, 0x28657475,
0x5d5d2930, 0x20200a3b, 0x6c662020, 0x3374616f, 0x755f6120, 0x5b5b2076, 0x72747461, 0x74756269,
0x29312865, 0x0a3b5d5d, 0x0a0a3b7d, 0x74726576, 0x6d207865, 0x306e6961, 0x74756f5f, 0x69616d20,
0x6d28306e, 0x306e6961, 0x206e695f, 0x5b206e69, 0x6174735b, 0x695f6567, 0x2c5d5d6e, 0x6e6f6320,
0x6e617473, 0x6c672074, 0x6c61626f, 0x5f202673, 0x5b203931, 0x6675625b, 0x28726566, 0x5d5d2930,
0x0a7b0a29, 0x20202020, 0x6e69616d, 0x756f5f30, 0x756f2074, 0x203d2074, 0x0a3b7d7b, 0x20202020,
0x2e74756f, 0x505f6c67, 0x7469736f, 0x206e6f69, 0x315f203d, 0x72702e39, 0x6d5f6a6f, 0x2a207461,
0x6f6c6620, 0x28347461, 0x612e6e69, 0x736f705f, 0x2e30202c, 0x31202c30, 0x3b29302e, 0x2020200a,
0x74756f20, 0x755f662e, 0x203d2076, 0x612e6e69, 0x3b76755f, 0x2020200a, 0x74657220, 0x206e7275,
0x3b74756f, 0x0a0a7d0a, 0x00000000 };

9796
externals/dds-ktx/ctexview/sokol_app.h vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

14836
externals/dds-ktx/ctexview/sokol_gfx.h vendored Normal file

File diff suppressed because it is too large Load Diff

129
externals/dds-ktx/ctexview/sokol_glue.h vendored Normal file
View File

@@ -0,0 +1,129 @@
#ifndef SOKOL_GLUE_INCLUDED
/*
sokol_glue.h -- glue helper functions for sokol headers
Project URL: https://github.com/floooh/sokol
Do this:
#define SOKOL_IMPL
before you include this file in *one* C or C++ file to create the
implementation.
...optionally provide the following macros to override defaults:
SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
SOKOL_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_IMPL - public function implementation prefix (default: -)
If sokol_glue.h is compiled as a DLL, define the following before
including the declaration or implementation:
SOKOL_DLL
On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport)
or __declspec(dllimport) as needed.
OVERVIEW
========
The sokol core headers should not depend on each other, but sometimes
it's useful to have a set of helper functions as "glue" between
two or more sokol headers.
This is what sokol_glue.h is for. Simply include the header after other
sokol headers (both for the implementation and declaration), and
depending on what headers have been included before, sokol_glue.h
will make available "glue functions".
PROVIDED FUNCTIONS
==================
- if sokol_app.h and sokol_gfx.h is included:
sg_context_desc sapp_sgcontext(void):
Returns an initialized sg_context_desc function initialized
by calling sokol_app.h functions.
LICENSE
=======
zlib/libpng license
Copyright (c) 2018 Andre Weissflog
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the
use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software in a
product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#define SOKOL_GLUE_INCLUDED
#ifndef SOKOL_API_DECL
#if defined(_WIN32) && defined(SOKOL_DLL) && defined(SOKOL_IMPL)
#define SOKOL_API_DECL __declspec(dllexport)
#elif defined(_WIN32) && defined(SOKOL_DLL)
#define SOKOL_API_DECL __declspec(dllimport)
#else
#define SOKOL_API_DECL extern
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(SOKOL_GFX_INCLUDED) && defined(SOKOL_APP_INCLUDED)
SOKOL_API_DECL sg_context_desc sapp_sgcontext(void);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SOKOL_GLUE_INCLUDED */
/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_IMPL
#define SOKOL_GLUE_IMPL_INCLUDED (1)
#include <string.h> /* memset */
#ifndef SOKOL_API_IMPL
#define SOKOL_API_IMPL
#endif
#if defined(SOKOL_GFX_INCLUDED) && defined(SOKOL_APP_INCLUDED)
SOKOL_API_IMPL sg_context_desc sapp_sgcontext(void) {
sg_context_desc desc;
memset(&desc, 0, sizeof(desc));
desc.color_format = (sg_pixel_format) sapp_color_format();
desc.depth_format = (sg_pixel_format) sapp_depth_format();
desc.sample_count = sapp_sample_count();
desc.gl.force_gles2 = sapp_gles2();
desc.metal.device = sapp_metal_get_device();
desc.metal.renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor;
desc.metal.drawable_cb = sapp_metal_get_drawable;
desc.d3d11.device = sapp_d3d11_get_device();
desc.d3d11.device_context = sapp_d3d11_get_device_context();
desc.d3d11.render_target_view_cb = sapp_d3d11_get_render_target_view;
desc.d3d11.depth_stencil_view_cb = sapp_d3d11_get_depth_stencil_view;
desc.wgpu.device = sapp_wgpu_get_device();
desc.wgpu.render_view_cb = sapp_wgpu_get_render_view;
desc.wgpu.resolve_view_cb = sapp_wgpu_get_resolve_view;
desc.wgpu.depth_stencil_view_cb = sapp_wgpu_get_depth_stencil_view;
return desc;
}
#endif
#endif /* SOKOL_IMPL */

1271
externals/dds-ktx/dds-ktx.h vendored Normal file

File diff suppressed because it is too large Load Diff