All Projects → septag → Dds Ktx

septag / Dds Ktx

Licence: bsd-2-clause
Single header KTX/DDS reader

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Dds Ktx

Bgfx
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
Stars: ✭ 10,252 (+16435.48%)
Mutual labels:  gamedev, opengl, directx
Diligentengine
A modern cross-platform low-level graphics library and rendering framework
Stars: ✭ 2,142 (+3354.84%)
Mutual labels:  gamedev, opengl, directx
Bsf
Modern C++14 library for the development of real-time graphical applications
Stars: ✭ 1,640 (+2545.16%)
Mutual labels:  gamedev, opengl, directx
Diligentsamples
Sample projects demonstrating the usage of Diligent Engine
Stars: ✭ 138 (+122.58%)
Mutual labels:  gamedev, opengl, directx
Blue Flame Engine
A 3D/2D game engine that supports both DirectX11 and OpenGL 4.5
Stars: ✭ 129 (+108.06%)
Mutual labels:  gamedev, opengl, directx
Bansheeengine
Modern C++14 game engine with Vulkan support, fully featured editor and C# scripting
Stars: ✭ 2,906 (+4587.1%)
Mutual labels:  gamedev, opengl, directx
Matcaps
Huge library of matcap PNG textures organized by color
Stars: ✭ 607 (+879.03%)
Mutual labels:  opengl, texture
Luminance Rs
Type-safe, type-level and stateless Rust graphics framework
Stars: ✭ 632 (+919.35%)
Mutual labels:  opengl, texture
Effekseer
Stars: ✭ 728 (+1074.19%)
Mutual labels:  opengl, directx
Glfw
Go bindings for GLFW 3
Stars: ✭ 1,069 (+1624.19%)
Mutual labels:  gamedev, opengl
Dxwrapper
Fixes compatibility issues with older games running on Windows 10 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
Stars: ✭ 460 (+641.94%)
Mutual labels:  gamedev, directx
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+13075.81%)
Mutual labels:  opengl, gamedev
Bonzomatic
Live shader coding tool and Shader Showdown workhorse
Stars: ✭ 829 (+1237.1%)
Mutual labels:  opengl, directx
Renderdoc
RenderDoc is a stand-alone graphics debugging tool.
Stars: ✭ 5,969 (+9527.42%)
Mutual labels:  opengl, directx
Lighthouse2
Lighthouse 2 framework for real-time ray tracing
Stars: ✭ 542 (+774.19%)
Mutual labels:  gamedev, opengl
Imogen
GPU Texture Generator
Stars: ✭ 648 (+945.16%)
Mutual labels:  opengl, texture
Pyimgui
Cython-based Python bindings for dear imgui
Stars: ✭ 504 (+712.9%)
Mutual labels:  gamedev, opengl
Pyglet
pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.
Stars: ✭ 756 (+1119.35%)
Mutual labels:  gamedev, opengl
Hinterland
2D top-down shooter game
Stars: ✭ 34 (-45.16%)
Mutual labels:  gamedev, opengl
Gameoverlay
🎮 GameOverlay using CEF with support for common rendering backends
Stars: ✭ 32 (-48.39%)
Mutual labels:  opengl, directx

dds-ktx: Portable single header DDS/KTX reader for C/C++

@septag

  • Parses from memory blob. No allocations
  • No dependencies
  • Single-header for easy integration
  • Overridable libc functions

Build Example (ctexview)

ctexview 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

Linux:

gcc ctexview.c -O2 -lGL -ldl -lX11 -lXi -lXcursor -lm -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

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

#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

TODO

  • Write KTX/DDS
  • Read KTX metadata. currently it just stores the offset/size to the metadata block

Others

  • stb_image - Single header library that loads images (.png, .jpg, .bmp, etc)
  • bimg - Extensive C++ image library

NOTE: Many parts of the code is taken from bimg library.

License (BSD 2-clause)

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].