lwjglgamedev / lwjglbook

Source code of the chapters of the book 3D Game Development with LWJGL 3
Apache License 2.0
127 stars 23 forks source link

chapter-20: glsl scene.frag shader version not updated #3

Closed consansri closed 1 year ago

consansri commented 1 year ago

In chapter-20: glsl shader versions aren't the same in scene.vert and scene.frag That causes a compiling error.

works fine when updating version of scene.frag to #version 460

Just wanted to inform you :D

Keep up and great job!

lwjglgamedev commented 1 year ago

Hi, shaders versions do not need to match according to OpenGL specs. Can you please post the error that you are getting?

consansri commented 1 year ago

This is my error code i'm getting if i just compile your chapter-21

Exception in thread "main" java.lang.RuntimeException: Error compiling Shader code: ERROR: 0:32: 'variable indexing sampler array' : not supported for this version or the enabled extensions ERROR: 0:32: '' : compilation terminated ERROR: 2 compilation errors. No code generated.

at org.lwjglb.engine.graph.ShaderProgram.createShader(ShaderProgram.java:47)
at org.lwjglb.engine.graph.ShaderProgram.lambda$new$0(ShaderProgram.java:21)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.lwjglb.engine.graph.ShaderProgram.<init>(ShaderProgram.java:21)
at org.lwjglb.engine.graph.SceneRender.<init>(SceneRender.java:31)
at org.lwjglb.engine.graph.Render.<init>(Render.java:31)
at org.lwjglb.engine.Engine.<init>(Engine.java:25)
at org.lwjglb.game.Main.main(Main.java:29)
consansri commented 1 year ago

Oh and exactly the same for chapter-20

lwjglgamedev commented 1 year ago

Ok, I see this is due to variable indexing which is not suported untill OpenGL4.x. The straneg thing is that I do not get thate error. Can you please check if putting #version 400 solves the issue? I like the idea of showiong that you can mix versions.

consansri commented 1 year ago

Works perfectly fine with #version 400 :D

lwjglgamedev commented 1 year ago

Thanks for reporting! Just uploaded a fix for this.