openrndr / orx

A growing library of assorted data structures, algorithms and utilities for OPENRNDR
https://openrndr.org
BSD 2-Clause "Simplified" License
118 stars 36 forks source link

Bug report: Loading dds image fails #315

Closed hamoid closed 1 year ago

hamoid commented 1 year ago

Operating System

Linux

OPENRNDR version

dfa59b3d879e719a1b4b078a310d3758d1f4e743

ORX version

2b66390410b9f9d4acec19c1c9794b668a61d57b

Java version (if applicable)

adopt-openjdk-14.0.1

Describe the bug

When running DemoDDSImage01.kt from the orx repo I get

 DemoDDSImage01Kt.main(DemoDDSImage01.kt:-1)
├─ DemoDDSImage01Kt.main(DemoDDSImage01.kt:5)
│  org.openrndr.ApplicationBuilderKt.application(ApplicationBuilder.kt:89)
│  org.openrndr.Application.run$openrndr_application(Application.kt:71)
│  org.openrndr.internal.gl3.ApplicationGLFWGL3.loop(ApplicationGLFWGL3.kt:870)
├─ kotlinx.coroutines.BuildersKt.runBlocking$default(null:1)
├─ kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
├─ kotlinx.coroutines.BuildersKt.runBlocking(null:1)
├─ kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
├─ kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
├─ kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
├─ kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
├─ kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
│  org.openrndr.internal.gl3.ApplicationGLFWGL3.loop.{ }.invokeSuspend(ApplicationGLFWGL3.kt:871)
│  org.openrndr.ApplicationBuilderJVM.program.{ }.setup(ApplicationBuilder.kt:116)
│  DemoDDSImage01.main.{ :ApplicationBuilder }.{ }.{ }(DemoDDSImage01.kt:-1)
│  DemoDDSImage01.main.{ :ApplicationBuilder }.{ }.{ }(DemoDDSImage01.kt:-1)
├─ DemoDDSImage01.main.{ :ApplicationBuilder }.{ }.invokeSuspend(DemoDDSImage01.kt:7)
│  org.openrndr.draw.ColorBufferJVM.loadImage$default(ColorBuffer.kt:290)
│  org.openrndr.draw.ColorBufferJVM.loadImage(ColorBuffer.kt:297)
│  org.openrndr.draw.ColorBufferJVM.loadImage(ColorBuffer.kt:311)
│
↑ failed to load image: file '/home/funpro/OR/openrndr.org/orx/demo-data/cubemaps/garage_iem.dds' (RuntimeException) 
├─ java.nio.Buffer.nextGetIndex(Buffer.java:696)

Process finished with exit code 1

The CubemapDemos also fail, maybe because they are loading the same dds image.

Steps to reproduce the bug

The code of the failing demo:

import org.openrndr.application
import org.openrndr.draw.loadImage

fun main() {
    application {
        program {
            val image = loadImage("demo-data/cubemaps/garage_iem.dds")
            println(image.format)
            println(image.type)
            extend {
                drawer.image(image)
            }
        }
    }
}
edwinRNDR commented 1 year ago

Digging into this now. Loading DDS files should be made part of the openrndr-gl3 unit tests, because I've stumbled upon multiple causes for the DDS loader to fail.