kotlin-graphics/imgui

MacOS not working with latest changes in master

Closed this issue · 49 comments

Screen is just black on mac but on linux gl2/3 works ok.

Can you try on mac d60ba95 and 3724218?

I can not compile d60ba95 while 3724218 can be compiled:

 ./gradlew lightjar
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (9, 19): Unresolved reference: BufferTarget
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (10, 19): Unresolved reference: Usage
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (20, 20): Unresolved reference: usingProgram
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (21, 20): Unresolved reference: initTexture2d
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (51, 39): None of the following functions can be called with the arguments supplied: 
public final fun createFromSource(type: ShaderType, sourceText: Array<String>): GlShader defined in gln.objects.GlShader.Companion
public final fun createFromSource(type: ShaderType, sourceText: String): GlShader defined in gln.objects.GlShader.Companion
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (52, 39): None of the following functions can be called with the arguments supplied: 
public final fun createFromSource(type: ShaderType, sourceText: Array<String>): GlShader defined in gln.objects.GlShader.Companion
public final fun createFromSource(type: ShaderType, sourceText: String): GlShader defined in gln.objects.GlShader.Companion
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (64, 9): Unresolved reference: usingProgram
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (65, 27): Unresolved reference: uniform
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (66, 23): Unresolved reference: unit
e: /home/yuraj/IdeaProjects/imgui/src/main/kotlin/imgui/impl/ImplGL2.kt: (72, 9): None of the following functions can be called with the arguments supplied: 
public inline fun glBufferData(target: BufferTarget, mat: Mat4, usage: Usage): Unit defined in gln.buffer

Is that the d60ba95 output?

Also, how do you import imgui? Probably is just a mismatch gln version

Yes - just checkout on that commit and then compile the imgui project using ./gradlew lightjar

Oh yeah, it's broken, what about the next where I fixed the errors?

out of curiosity, which mac are you running this on?

Mojave version 10.14.3, gl2

3724218 crashes on:

Caused by: java.lang.NoSuchMethodError: gln.objects.GlTexture.constructor-impl$default(IILkotlin/jvm/internal/DefaultConstructorMarker;)V
    at imgui.impl.ImplGL2.<init>(ImplGL2.kt:36)
    at imgui.impl.LwjglGlfw.<init>(LwjglGlfw.kt:148)
    at imgui.impl.LwjglGlfw$Companion.init(LwjglGlfw.kt:31)
    at imgui.impl.LwjglGlfw$Companion.init$default(LwjglGlfw.kt:30)

something is wrong with the gln dependency

how do you import imgui into your project? Can you run dependencies?

gln shall be

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
+--- org.jetbrains.kotlin:kotlin-stdlib:{prefer 1.3.11} -> 1.3.11
|    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.11
|    \--- org.jetbrains:annotations:13.0
+--- com.github.kotlin-graphics:uno-sdk:60edf33067835253aa30ac79bd5129363fee953f
|    +--- com.github.kotlin-graphics:gln:7e921b01cc01dbf3444e320f2a2af04490158952
compile 'com.github.kotlin-graphics:uno-sdk:60edf33067835253aa30ac79bd5129363fee953f'
compile files("../libs/imgui-light.jar")

       configurations.compile.resolvedConfiguration.getResolvedArtifacts().forEach {
            if (it.moduleVersion.id.group == "org.lwjgl" && it.moduleVersion.id.name != "lwjgl-jawt" && it.moduleVersion.id.name != "lwjgl-vulkan") {
                runtime "org.lwjgl:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}:${lwjglNatives}"
            }
        }

what's the output of dependencies? In Idea under Gradle Tasks help

In my project:

\--- com.github.kotlin-graphics:uno-sdk:60edf33067835253aa30ac79bd5129363fee953f
     +--- com.github.kotlin-graphics:gln:7e921b01cc01dbf3444e320f2a2af04490158952
     |    +--- com.github.kotlin-graphics:gli:968eb79758bf3475e8cf1a93f138b2a19aadd7a5
     |    |    +--- com.github.kotlin-graphics.glm:glm:a1cafbd4e1bda500291b19a8d0cb75374f97688c
     |    |    |    +--- com.github.kotlin-graphics:kotlin-unsigned:0e3cc3ec155986f2100fee03cc143cbd3dfd0d84
     |    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    |    |    +--- com.github.kotlin-graphics:kool:7c3dfaf417b00a0b7fe5dd273bf10291ebfe45d0
     |    |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    |    |    |    +--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     |    |    |    |    \--- org.lwjgl:lwjgl-jemalloc:3.2.2-SNAPSHOT (*)
     |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    |    |    +--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     |    |    |    +--- org.lwjgl:lwjgl-glfw:3.2.2-SNAPSHOT (*)
     |    |    |    +--- org.lwjgl:lwjgl-jemalloc:3.2.2-SNAPSHOT (*)
     |    |    |    +--- org.lwjgl:lwjgl-openal:3.2.2-SNAPSHOT (*)
     |    |    |    +--- org.lwjgl:lwjgl-opengl:3.2.2-SNAPSHOT (*)
     |    |    |    \--- org.lwjgl:lwjgl-stb:3.2.2-SNAPSHOT (*)
     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    |    +--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     |    |    +--- org.lwjgl:lwjgl-glfw:3.2.2-SNAPSHOT (*)
     |    |    +--- org.lwjgl:lwjgl-jemalloc:3.2.2-SNAPSHOT (*)
     |    |    +--- org.lwjgl:lwjgl-openal:3.2.2-SNAPSHOT (*)
     |    |    +--- org.lwjgl:lwjgl-opengl:3.2.2-SNAPSHOT (*)
     |    |    \--- org.lwjgl:lwjgl-stb:3.2.2-SNAPSHOT (*)
     |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.21
     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    +--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     |    +--- org.lwjgl:lwjgl-glfw:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-jemalloc:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-openal:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-opengl:3.2.2-SNAPSHOT (*)
     |    \--- org.lwjgl:lwjgl-stb:3.2.2-SNAPSHOT (*)
     +--- com.github.kotlin-graphics:vkk:a593ed45c49422b19e74b165a97bcd4a1245e2fd
     |    +--- com.github.kotlin-graphics:gli:968eb79758bf3475e8cf1a93f138b2a19aadd7a5 (*)
     |    +--- graphics.scenery:spirvcrossj:0.5.0-1.1.85
     |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     |    +--- org.jetbrains.kotlin:kotlin-reflect:1.3.21 (*)
     |    +--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     |    +--- org.lwjgl:lwjgl-glfw:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-jemalloc:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-openal:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-opengl:3.2.2-SNAPSHOT (*)
     |    +--- org.lwjgl:lwjgl-stb:3.2.2-SNAPSHOT (*)
     |    \--- org.lwjgl:lwjgl-vulkan:3.2.2-SNAPSHOT
     |         \--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.21 (*)
     +--- org.jetbrains.kotlin:kotlin-reflect:1.3.21 (*)
     +--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT
     +--- org.lwjgl:lwjgl-glfw:3.2.2-SNAPSHOT (*)
     +--- org.lwjgl:lwjgl-jemalloc:3.2.2-SNAPSHOT (*)
     +--- org.lwjgl:lwjgl-openal:3.2.2-SNAPSHOT (*)
     +--- org.lwjgl:lwjgl-opengl:3.2.2-SNAPSHOT (*)
     +--- org.lwjgl:lwjgl-stb:3.2.2-SNAPSHOT (*)
     +--- org.lwjgl:lwjgl-vulkan:3.2.2-SNAPSHOT (*)
     \--- org.lwjgl:lwjgl-jawt:3.2.2-SNAPSHOT
          \--- org.lwjgl:lwjgl:3.2.2-SNAPSHOT

gln version matches.. I dont know what else to do

and what about if you try the actual last snapshot?

With the same process but with latest master changes It works (With the mentioned black screen on mac but at least It runs) dependency tree is same.

Try branch TestLowGLN commit 673d347. The reason I ask which Mac is that it is clear that we'll need to test on more than just windows and linux systems in the future , so I figure getting an older mac laptop only doing GL21 isn't a bad idea

673d347 still black screen

Do you run your git and gradle in the same shell? if so, can you send what you'd do to check out and build your jars?

But I tested 673d347 and It didn't work - I mean I could compile It and run but I still see black screen on Mac only. I use VCS integrated in IntelliJ and same for gradle (I do not use command line)

Does TestLowGLN 3724218 work?

Crashes when I try to run screen with imgui (tested on linux):

Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError: gln.vertexArray.GlVertexArray.constructor-impl$default(IILkotlin/jvm/internal/DefaultConstructorMarker;)V
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:117)
	at com.x.prototype.desktop.DesktopLauncher.main(DesktopLauncher.kt:19)
Caused by: java.lang.NoSuchMethodError: gln.vertexArray.GlVertexArray.constructor-impl$default(IILkotlin/jvm/internal/DefaultConstructorMarker;)V
	at imgui.impl.ImplGL3.<init>(ImplGL3.kt:53)
	at imgui.impl.LwjglGlfw.<init>(LwjglGlfw.kt:146)
	at imgui.impl.LwjglGlfw$Companion.init(LwjglGlfw.kt:31)
	at imgui.impl.LwjglGlfw$Companion.init$default(LwjglGlfw.kt:30)

I have tried It with imgui.jar compile files("../libs/imgui.jar")
Also while I am using fat jar instead of imgui-light jar I see this warning:

[LWJGL] [ERROR] Incompatible Java and native library versions detected.
Possible reasons:
	a) -Djava.library.path is set to a folder containing shared libraries of an older LWJGL version.
	b) The classpath contains jar files of an older LWJGL version.
Possible solutions:
	a) Make sure to not set -Djava.library.path (it is not needed for developing with LWJGL 3) or make
	   sure the folder it points to contains the shared libraries of the correct LWJGL version.
	b) Check the classpath and make sure to only have jar files of the same LWJGL version in it.

I also use this in my build

   // Look up which modules and versions of LWJGL are required and add setup the approriate natives.
        configurations.compile.resolvedConfiguration.getResolvedArtifacts().forEach {
            if (it.moduleVersion.id.group == "org.lwjgl" && it.moduleVersion.id.name != "lwjgl-jawt" && it.moduleVersion.id.name != "lwjgl-vulkan") {
                runtime "org.lwjgl:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}:${lwjglNatives}"
            }
        }

but I do not import LWJGL3 explicitly because It should be imported by GDX.

    dependencies {
        
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"

        //ImGui dependencies
        compile files("../libs/imgui.jar")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
    }

Can you refresh dependencies?

In IntelliJ this is done by clicking on the gradle window, clicking on the elephant at top, and then typing --refresh-dependencies in the window. Then run. This should fix that problem.

Do you have auto-import turned on? That could fix this issue in the future

Hm still doesn't work. Could you please upload Jar for 3724218 ?

All jars uploaded to my website

imgui-light.jar - black screen on mac, OK on linux

Does v1.68.01-00 work (located here)? I'm buying an old macbook soon so I'll be able to test, but until then it's a shot in the dark

Still the same problem as in #79 (comment) - here you can test It:
guitest.zip

This should fix the LWJGL version mismatch

Now It runs on linux and mac but I still see black screen on Mac.

@yuraj11 , I lost myelft, just to sum up, did the gl2 on mac ever worked?

If yes, let's take that and restore it for the moment, then maybe we can step by step apply all the changes in order to isolate the bug

Last working version on Mac for me is a8b471d . On later versions I see only black screen on Mac.

My guess is that it's got to do with the framebuffer scaling change. If I put together s debug build, will you run it?

I got some time in the meanwhile and I'd like gln to be working asap

Give it a try, 7b47b53 (branch #79)

#79

Exception in thread "main" java.lang.IllegalStateException: Property textureName should be initialized before get.
	at kotlin.properties.NotNullVar.getValue(Delegates.kt:62)
	at gln.texture.TextureKt.getTextureName(texture.kt)
	at imgui.impl.ImplGL2.createFontsTexture(ImplGL2.kt:103)
	at imgui.impl.ImplGL2.createDeviceObjects(ImplGL2.kt:80)
	at imgui.impl.LwjglGlfw.newFrame(LwjglGlfw.kt:159)
	at imgui.impl.LwjglGlfw$Companion.newFrame(LwjglGlfw.kt:34)

OpenGL2 crashes even on linux for me. OpenGL3 does not crash on linux. So no reason to test It on Mac where is opengl2.

Sorry, textureName refers to a global variable that has nothing to do in this context

1591dcc

@elect86 this one works correctly and also no more black screen on mac 👍

crash.txt
but this crash still randomly happens on MAC OpenGL2

how much random does it crash?

Not so often maybe about 3 times in 8 hours while working on the project.

Totally random :)

The crash points deep inside glfw, weird stuff, menu and menu key event

Spasi suggested that it may be not random, maybe the user does something odd that triggers it

However, I'm gonna open probably an issue on glfw

One last thing, did you happen to notice the same random crashes with the working snapshot before this last one? If you had a chance to test it intensively as it looks you did now

Hey Juraj,

could you try to build lwjgl on mac with glfw in debug mode (this without the AWS stuff and CMAKE_BUILD_TYPE to debug)?

Sorry I will investigate It later when I will have more time to do It. But in the meantime could you please merge It to master 1591dcc ?

And yes I had always crashes on mac with imgui as mentioned in previous issues.

Sure, pushed

Hey Juraj, any news?

Hi, sorry I am not using imgui anymore - I have migrated to libgdx scene2d. Anyway thanks for your effort.

If anyone has having problems with mac and GL2, he can feel free to reopen