kotlin-graphics / Gli

Licence: mit
jvm gli

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Gli

Silk.net
The high-speed OpenAL, OpenGL, Vulkan, and GLFW bindings library your mother warned you about.
Stars: ✭ 534 (+2442.86%)
Mutual labels:  opengl, graphics
Luminance Rs
Type-safe, type-level and stateless Rust graphics framework
Stars: ✭ 632 (+2909.52%)
Mutual labels:  opengl, texture
Hybridrenderingengine
Clustered Forward/Deferred renderer with Physically Based Shading, Image Based Lighting and a whole lot of OpenGL.
Stars: ✭ 563 (+2580.95%)
Mutual labels:  opengl, graphics
Renderhelp
⚡️ 可编程渲染管线实现,帮助初学者学习渲染
Stars: ✭ 494 (+2252.38%)
Mutual labels:  opengl, graphics
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+38800%)
Mutual labels:  opengl, graphics
Gfx
[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
Stars: ✭ 5,045 (+23923.81%)
Mutual labels:  opengl, graphics
Matcaps
Huge library of matcap PNG textures organized by color
Stars: ✭ 607 (+2790.48%)
Mutual labels:  opengl, texture
Midivisualizer
A small MIDI visualizer tool, using OpenGL
Stars: ✭ 347 (+1552.38%)
Mutual labels:  opengl, graphics
Pbr
An implementation of physically based shading & image based lighting in D3D11, D3D12, Vulkan, and OpenGL 4.
Stars: ✭ 722 (+3338.1%)
Mutual labels:  opengl, graphics
Fauxgl
Software-only 3D renderer written in Go.
Stars: ✭ 658 (+3033.33%)
Mutual labels:  opengl, graphics
Tprpix
a Cross-Platform, 2D Survival Sandbox Game Project. Based on C++17/cmake/OpenGL/SQLite3.
Stars: ✭ 448 (+2033.33%)
Mutual labels:  opengl, graphics
Bonzomatic
Live shader coding tool and Shader Showdown workhorse
Stars: ✭ 829 (+3847.62%)
Mutual labels:  opengl, graphics
Shadergen
Proof-of-concept library for generating HLSL, GLSL, and Metal shader code from C#,
Stars: ✭ 395 (+1780.95%)
Mutual labels:  opengl, graphics
Worldwindjava
The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
Stars: ✭ 526 (+2404.76%)
Mutual labels:  opengl, graphics
Sfml.net
Official binding of SFML for .Net languages
Stars: ✭ 354 (+1585.71%)
Mutual labels:  opengl, graphics
Renderdoc
RenderDoc is a stand-alone graphics debugging tool.
Stars: ✭ 5,969 (+28323.81%)
Mutual labels:  opengl, graphics
Overload
3D Game engine with editor
Stars: ✭ 335 (+1495.24%)
Mutual labels:  opengl, graphics
Fbg
Lightweight C 2D graphics API agnostic library with parallelism support
Stars: ✭ 349 (+1561.9%)
Mutual labels:  opengl, graphics
Imogen
GPU Texture Generator
Stars: ✭ 648 (+2985.71%)
Mutual labels:  opengl, texture
Sfml
Simple and Fast Multimedia Library
Stars: ✭ 7,316 (+34738.1%)
Mutual labels:  opengl, graphics

gli

Build Status license Release Size Github All Releases Awesome Kotlin Badge

This is the Kotlin port of the original OpenGL Image (GLI), written by g-truc (repository), a header only C++ image library for graphics software.

GLI provides classes and functions to load image files, facilitate graphics APIs texture creation, compare textures, access texture texels, sample textures, convert textures, generate mipmaps, etc.

This library works perfectly with OpenGL or Vulkan but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (raytracing / rasterization), image processing, image based software testing or any development context that requires a simple and convenient image library.

Don't hesitate to contribute to the project by submitting issues or pull requests for bugs and features. Any feedback is welcome at [email protected].

Kotlin:

import gli_.gli

fun createTexture(filename: String): Int {

    val texture = gli.load(filename)
    if(texture.empty())
        return 0

    gli.gl.profile = gl.Profile.GL33
    val format = gli.gl.translate(texture.format, texture.swizzles)
    val target = gli.gl.translate(texture.target)
    assert(texture.format.isCompressed && target == gl.Target._2D)

    val textureName = intBufferBig(1)
    glGenTextures(textureName)
    glBindTexture(target.i, textureName[0])
    glTexParameteri(target.i, GL_TEXTURE_BASE_LEVEL, 0)
    glTexParameteri(target.i, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1)
    val swizzles = intBufferBig(4)
    format.swizzles to swizzles
    glTexParameteriv(target.i, GL_TEXTURE_SWIZZLE_RGBA, swizzles)
    var extent = texture.extent()
    glTexStorage2D(target.i, texture.levels(), format.internal.i, extent.x, extent.y)
    for(level in 0 until texture.levels()) {
        extent = texture.extent(level)
        glCompressedTexSubImage2D(
                target.i, level, 0, 0, extent.x, extent.y,
                format.internal.i, texture.data(0, 0, level))
    }
    val texName = textureName[0]
    textureName.free()
    return texName
}

Kotlin with gl-next:

    fun createTexture(filename: String): Int {

        val texture = gli.load(filename)
        if(texture.empty())
            return 0

        gli.gl.profile = gl.Profile.GL33
        val (target, format) = gli.gl.translate(texture)
        assert(texture.format.isCompressed && target == gl.Target._2D)

        return initTexture2d {
            levels = 0 until texture.levels()
            swizzles = format.swizzles
            storage(texture.levels(), format.internal, texture.extent())
            levels.forEach {
                compressedSubImage(it, texture.extent(it), format.internal, texture.data(0, 0, it))
            }
        }
    }

Java:

public static int createTexture(String filename) {

    Texture texture = gli.load(filename);
    if (texture.empty())
        return 0;

    gli_.gli.gl.setProfile(gl.Profile.GL33);
    gl.Format format = gli_.gli.gl.translate(texture.getFormat(), texture.getSwizzles());
    gl.Target target = gli_.gli.gl.translate(texture.getTarget());
    assert (texture.getFormat().isCompressed() && target == gl.Target._2D);

    IntBuffer textureName = intBufferBig(1);
    glGenTextures(textureName);
    glBindTexture(target.getI(), textureName.get(0));
    glTexParameteri(target.getI(), GL12.GL_TEXTURE_BASE_LEVEL, 0);
    glTexParameteri(target.getI(), GL12.GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
    IntBuffer swizzles = intBufferBig(4);
    texture.getSwizzles().to(swizzles);
    glTexParameteriv(target.getI(), GL33.GL_TEXTURE_SWIZZLE_RGBA, swizzles);
    Vec3i extent = texture.extent(0);
    glTexStorage2D(target.getI(), texture.levels(), format.getInternal().getI(), extent.x, extent.y);
    for (int level = 0; level < texture.levels(); level++) {
        extent = texture.extent(level);
        glCompressedTexSubImage2D(
            target.getI(), level, 0, 0, extent.x, extent.y,
            format.getInternal().getI(), texture.data(0, 0, level));
    }
    int texName = textureName.get(0);
    MemoryUtil.memFree(textureName);
    return texName
}

Supported Image Formats

  • KTX
  • DDS
  • KMG
  • jpg
  • png
  • gif
  • bmp
  • tga
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].