This is the Kotlin port of the original OpenGL Image (GLI), written by g-truc (repository)

Overview

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

How to retrieve it:

You can find all the instructions by mary

You might also like...
Squishy button effect with kotlin
Squishy button effect with kotlin

Squishy Usage Add squishy() modifier on your composable element. Text( text = "Squishhhhyyyyy", modifier = Modifier .size(200.dp, 100.dp

Car Shop App Built With Kotlin
Car Shop App Built With Kotlin

Car Shop O aplicativo conta com 2 telas no total sendo elas a home(Tela principa

Ms-goals - Project developed using Kotlin and Spring

Goals microservice Kotlin + Spring CRUD application. You can find the following

LittleKt - An OpenGL game framework written in Kotlin

LittleKt - A 2D game framework written in Kotlin Currently in development. Littl

Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.

Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image sel

Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻
Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻

BigImageViewer Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling

This project is basically PowerNukkit but just in Kotlin (check out the original PowerNukkit source here: https://github.com/PowerNukkit/PowerNukkit)
This project is basically PowerNukkit but just in Kotlin (check out the original PowerNukkit source here: https://github.com/PowerNukkit/PowerNukkit)

Introduction Nukkit is nuclear-powered server software for Minecraft: Pocket Edition. It has a few key advantages over other server software: Written

Build a compiler in Kotlin (based on the original tutorial by Jack Crenshaw)

Let's Build a Compiler Based on the original series "Let’s Build a Compiler!" by Jack Crenshaw. This is an adaptation of the original series to Kotlin

Spring & Kotlin equivalent to original CraftMania's TypeScript CraftAPI.

KotlinCraftAPI This project is Spring & Kotlin equivalent to original CraftMania's TypeScript CraftAPI. This project was created solely to study Sprin

A flexible view for providing a limited rect window into a large data set,just like a two-dimensional RecyclerView.  It different from RecyclerView is that it's two-dimensional(just like a Panel) and it pin the itemView of first row and first column in their original location.
Unofficial, FOSS-friendly fork of the original Telegram client for Android

or 1McafEgMvqAVujNLtcJumZHxp2UfaNByqs Telegram-FOSS Telegram is a messaging app with a focus on speed and security. It’s superfast, simple and free. T

Pi-hole for Android - The original
Pi-hole for Android - The original

Pi-hole for Android - The original "killer app" for Raspberry Pi works great on most rooted Android devices as well.

Added support to modify text size and indicator width based on the original TabLayout.
Added support to modify text size and indicator width based on the original TabLayout.

XTabLayout——可修改选中项字体大小和指示器长度的TabLayout XTabLayout是基于design包中的TabLayout进行了功能的扩展,在保留原有功能的基础上,增加了修改选中项字体大小、修改指示器长度以及限制屏幕显示范围内显示的Tab个数。 集成步骤: 1.添加XTabLayo

androidx window manager sample taken from the original source and modified for easy deploy and test

androidx-window-samples This project contains the WindowManager samples located in the androidx WM project location The goal of this project is to pro

Appdbg - make it possible to run android dex file in original Java Virtual Machine
Appdbg - make it possible to run android dex file in original Java Virtual Machine

Appdbg - make it possible to run android dex file in original Java Virtual Machine

Partial port of https://github.com/davemorrissey/subsampling-scale-image-view library to Jetpack Compose.
Partial port of https://github.com/davemorrissey/subsampling-scale-image-view library to Jetpack Compose.

ComposeSubsamplingScaleImage Early preview (expect bugs) dependencies { implementation 'com.github.K1rakishou:ComposeSubsamplingScaleImage:fab4ae38c

RemsEngine - OpenSource Kotlin/OpenGL/ECS based game engine

Game Engine: Rem's Engine Parallel to this video editor, I am developing my own

A tool to install components of the Android SDK into a Maven repository or repository manager to use with the Android Maven Plugin, Gradle and other tools.

Maven Android SDK Deployer Original author including numerous fixes and changes: Manfred Moser [email protected] at simpligility technologies i

A tool to install components of the Android SDK into a Maven repository or repository manager to use with the Android Maven Plugin, Gradle and other tools.

Maven Android SDK Deployer Original author including numerous fixes and changes: Manfred Moser [email protected] at simpligility technologies i

Comments
  • AWT does not work with glfw on Mac OS. Image loading freezes the program

    AWT does not work with glfw on Mac OS. Image loading freezes the program

    Using AWT and glfw together on a mac leads to a deadlock. The reason for that is that both programs try to run an event loop on the main thread AFAIK (https://github.com/LWJGL/lwjgl3/issues/68). We use awt to load images.

    The proposed solution for this (from lwjgl) is to use stb instead. The C bindings for this are part of lwjgl.

    bug 
    opened by Wasabi375 4
Releases(v0.8.3.0-build-16)
Owner
Friendly community providing JVM counterpart of open source tools for real time 3d graphic. "Take care of your tools and they will take care of you." (cit)
null
ProfilePercentageView - A Profile Image View with percentage progress developed in Kotlin

ProfilePercentageView It is a Profile Image View with percentage progress develo

smartSense Solutions 8 Dec 31, 2021
Code Guide: How to create Snapchat-like image stickers and text stickers.

MotionViews-Android Code Guide : How to create Snapchat-like image stickers and text stickers After spending 2000+ hours and releasing 4+ successful a

Uptech 474 Dec 9, 2022
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

Patrick Favre-Bulle 1k Dec 1, 2022
Muirwik - a Material UI React wrapper written in Kotlin

Muirwik Welcome to Muirwik. Muirwik gets it name from being a Material UI React wrapper written in Kotlin. For more information, see the above links (

null 134 Nov 8, 2022
Janishar Ali 2.1k Jan 1, 2023
Provenance-eventstream-legacy-kotlin - A legacy Kotlin library for reading from the Provenance event stream

provenance-eventstream-legacy-kotlin A legacy Kotlin library for reading from th

Figure Technologies Inc. 1 Jan 13, 2022
Multiplatform UI DSL with screen management in common code for mobile (android & ios) Kotlin Multiplatform development

Mobile Kotlin widgets This is a Kotlin MultiPlatform library that provides declarative UI and application screens management in common code. You can i

IceRock Development 320 Dec 30, 2022
Kotlin/Native interop to libui: a portable GUI library

kotlin-libui Kotlin/Native bindings to the libui C library. libui is a C lightweight multi-platform UI library using native widgets on Linux (Gtk3), m

Mike Sinkovsky 611 Dec 30, 2022
Kotlin Wrapper Library of Material-UI

kotlin-material-ui Kotlin Wrapper Library of Material-UI Core: Lab: Installation repositories { jcenter() // or maven { url 'https://dl.bintra

Subroh Nishikori 78 Nov 24, 2022
Have a look at Job Allocation app build with SQLite database and Kotlin support

Job Allocation Overview Do you remember or forget sometimes to whom you allocated a task ?? Have a look at Job Allocation app build with SQLite databa

null 0 Dec 13, 2021