https://kotlinlang.org logo
Title
d

Dave

09/08/2020, 1:20 PM
I am trying to write Vertex and Fragment Shaders (for rendering a SkyBox). I am having trouble regarding the version of GLSL that is in use. How is the version decided ? Also, what version of openGL is used?
d

Deactivated User

09/08/2020, 4:00 PM
It uses an opengl version compatible with es 2.0
Regarding the version of glsl the dsl tries to hide that detail. It usually tries somethi g that works
Which kind of problems are you finding? A feature that is available on greater versions of the glsl shader language?
d

Dave

09/08/2020, 8:49 PM
I was using an example from here [https://learnopengl.com/Advanced-OpenGL/Cubemaps] couldn't seem to set up an input on the fragment shader. But I think I figured it out, using a Varying.
My next problem is figuring out the Texture class and all associated things. It seems a little difficult to understand. Any pointers welcome. 🙂 Else I'll get back to you when I get specific questions.
d

Deactivated User

09/09/2020, 12:42 AM
The AG.Texture is an unmanaged texture that represents a full texture on the GPU (no info about size or other things): https://github.com/korlibs/korgw/blob/e6aebe811a6a7b9c252ca3d82a3480859c8df34f/korgw/src/commonMain/kotlin/com/soywiz/korag/AG.kt#L204 Then on KorGE we have two more classes: Texture.Base (a wrapper around AG.Texture + width and height): https://github.com/korlibs/korge/blob/16aac42d6cf0e4eed19e088e12b73282661cf0f4/korge/src/commonMain/kotlin/com/soywiz/korge/render/Texture.kt#L80 And Texture that is a slice of a Texture.Base. Then there is a TextureManager: https://github.com/korlibs/korge/blob/16aac42d6cf0e4eed19e088e12b73282661cf0f4/korge/src/commonMain/kotlin/com/soywiz/korge/render/AgBitmapTextureManager.kt#L36 this is in charge of each frame get all the Bitmap and BmpSlice and generate the underlying textures as required and removed the textures that are stop being used. So on the korge level you usually use BmpSlice and Bitmap, and internally it generates Texture and Texture.Base, that in the end are wrapping AG.Texture. All that handled by the TextureManager
d

Dave

09/09/2020, 6:09 AM
thx
Is there an easy way to get some debug output or similar that shows the actual gl calls and in which order they are made ?
d

Deactivated User

09/09/2020, 11:10 AM
Yes it is. There is a LogKmlGlProxy here: https://github.com/korlibs/korge-next/blob/a7b9852dc2e4e2b7adab8ded8b16266ba8c6b481/korgw/src/commonMain/kotlin/com/soywiz/kgl/KmlGlProxy.kt#L1449-L1479 If you search references of
KmlGl.checkedIf
you can see where it is called, you can decorate the KmlGl instance with the LogKmlGlProxy to print all the calls You can use that class
d

Dave

09/09/2020, 2:15 PM
Great. Thanks.
Also, did you look at using mesa3d to get/include OpenGL headers and libs?
Still struggling with getting this skyboxe to render. Not sure if its the shaders or the gl calls. I will try the kml logging and see if that helps. Some of the shader trouble is that the examples are always in GLSL 330.
if i force the version to 330, it just gives me a glsl compile error
d

Deactivated User

09/09/2020, 3:07 PM
Im afraid I cannot help you much with that. I believe that if there is an error in the shaders, it throws an exception. And if it is related to opengl calls, it is just plain opengl in the end. The AG is in charge of setting the state, maybe some state was not set correctly?
d

Dave

09/10/2020, 8:43 AM
What is the reason for basing everything on what is a pretty old version of OpenGL ? • is this just historic - you started the work that long ago? • Or is there some compatibility problems with newer versions?
d

Deactivated User

09/10/2020, 12:23 PM
think that we have to support WebGL 1. We can support newer versions, but we need to provide a fallback for WebGL 1, at least until WebGPU is available
Also some phones still support OpenGL ES 2.0 only. Though probably pretty old already
The idea is to create new backends for AG supporting: vulkan, webgpu and metal at least, and maybe directx at some point, while still supporting opengl, for example when we try to support homebrew targets like 3ds, switch or psvita and there probably there will be some extra limitations on what's available
d

Dave

09/10/2020, 1:03 PM
ah.
my current issue, is wanting to use features that are not available in OpenGL 2.0. Or at least, I'm trying to use techniques that are illustrated in OpenGL 3/4, and I don't know enough to translate them backwards into v2.
d

Deactivated User

09/10/2020, 1:34 PM
Uhm. I wanted to support at least instanced rendering as an extension when available. But no work on this direction yet. That's part of AG/KmlGL. You can make additions if required, but that's not planned for 2.0 since I have to work on other things first