lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3
https://ahbejarano.gitbook.io/lwjglgamedev/
Apache License 2.0
560 stars 202 forks source link

game26 in Kotlin #81

Closed hoijui closed 4 years ago

hoijui commented 4 years ago

Hello! :-) This is not directly about the book, but. quite close. but feel free to ignore if you deem in uninteresting/unrelated. I tried to convert chapter26/game26 into Kotlin, and am almost there. It compiles and runs without errors, and most things seem to work:

... BUT, the scene is invisible (everything behind the HUD is just black). it must be some quite small thing, but I can't find it... my guess was it being something with lightning, but.. I am an OpenGL newbie, and hoped you might have a better idea.

NOTE:\ the original, gmae26 in Java, works fine on my machine, so it is not hardware related.

here it is: https://github.com/hoijui/lwjgl-book-game26-kotlin

hoijui commented 4 years ago

ahhh... I had the idea that: it would be great if I could track the actual OpenGL calls that are happening, then I can compare them between the Java and the Kotlin code, and might find out where the problem lies. Is there a way to do that? I will investigate...

lwjglgamedev commented 4 years ago

Hi,

I think you could that easily with aspects. You can try AspectJ or eny equivalent library and log each OpenGL method invocation. In any case, although I do not use Kotlink I will try to have a look at your code. Another alternative approach is to use RenderDoc.

Regards.

lwjglgamedev commented 4 years ago

Hi,

I think you have a problem with your buffers, either they have not been initialized or not have been filled up. This is waht I got with RenderDoc. You got a black screen because you are basically have not uploaded any data.

screenshot

Regards.

hoijui commented 4 years ago

wow, thanks a lot @lwjglgamedev !!! :-) funny enough, independently of your suggestion, I stumbled over renderdoc aswell, and tried it today, but I could not make any sense of it. I used version 1.7 (you seem to have 1.8), but I don;t think that was the issue. ;-) so the buffers.. thank you! that is a big help.. narrowing it down that way, will check all the buffers stuff!

hoijui commented 4 years ago

I pushed more to github. I found some bugs, fixed them, and now it is mostly running. all except the fire visual, which seems to show only the first "particle", going up, disappearing, and then nothing after that. I will investigate further...

lwjglgamedev commented 4 years ago

Good progress, an interesting effect by the way ;)

It seems to me that all of your particles instances are sharing the same position information. So, when one of them isupdated, the rest take the same value. If you debug your sample you will see that they share the same Vector3f instance. This is the cause of the effect.

If you move the position declaration to the next block, for instance, just before the var isSelected = false line, the problem is solved. You will need to change the constructor. I don't know enough Kotlin and why these variables are shared, they seem to me like static variables.

Regards.

lwjglgamedev commented 4 years ago

Should I close this issue?

hoijui commented 4 years ago

thank you for that additional info about the positions! if I get the time and interest, I will try to fix that too, but for now, I am not in need for that myself for my project, so will focus on that project instead.

yeah you can close this issue. I don;t know if it might make sense to link to my repo somewhere, in case other people want to follow the book in Kotlin or so.. o maybe you just clone the repo onto your account, but it might also not make sense.. as you thnk. thanks a lot for the help, @lwjglgamedev ! :-)

lwjglgamedev commented 4 years ago

Thanks,

I think, linking would make sense if you created a port of the whole book in Kotlin. I've cloned the repository in any case.