lwjglgamedev / lwjglbook Goto Github PK
View Code? Open in Web Editor NEWSource code of the chapters of the book 3D Game Development with LWJGL 3
License: Apache License 2.0
Source code of the chapters of the book 3D Game Development with LWJGL 3
License: Apache License 2.0
o/
Love the new revision of the book and getting modern java into use.
Though I have found a inconsistency with the book.
This line specifically showed up multiple times.
https://github.com/lwjglgamedev/lwjglbook-bookcontents/blob/main/chapter-21/chapter-21.md?plain=1#L529
Where you go into stream territory and then leap out of it again to use lists instead.
While I get that using streams can be useful to filter unwanted things out, you honestly shouldn't double dip every time it seems convenient.
While it is just a small issue, you are kinda teaching a habit here.
instead of "toList" you could have used "forEach" and have gotten out slightly more performance then normal instead of iterating over every element twice that was selected.
I know this is more for tutorial reasons,
but constantly recalculating everything isn't always a good idea.
While i get this is to display how things work, a lot of new people, like me back then, don't know certain pitfalls that lie ahead.
Note that this is honestly just a "I have to itch that tick" kinda issue report/improvement suggestion, i am fully aware of that.
That's why I am also totally fine with you just closing the issue without actually addressing things.
One last thing: for this exact reason (stream point) i have written myself a library that can do stream things but with "Iterable" interfaces instead. Less overhead and same functionality and still not forced to create copies if you want to use them in things that use Iterable.
I am on chapter 03
I am using intellij idea
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!
The Normal Mapping instructions change the location of the texture VBO to index 4.
The skybox.vert textCoord reference location should be changed to 4, too, if one wanted to use skybox and the normal mapping setup as presented in the chapter.
compiling in windows chapter 20,21 getting when running the app from IDE ::
Exception in thread "main" java.lang.RuntimeException: Error linking Shader code: Type mismatch: Type of outMaterialIdx different between shaders.
Out of resource error.
at org.lwjglb.engine.graph.ShaderProgram.link(ShaderProgram.java:62)
at org.lwjglb.engine.graph.ShaderProgram.<init>(ShaderProgram.java:23)
at org.lwjglb.engine.graph.SceneRender.<init>(SceneRender.java:29)
at org.lwjglb.engine.graph.Render.<init>(Render.java:30)
at org.lwjglb.engine.Engine.<init>(Engine.java:25)
at org.lwjglb.game.Main.main(Main.java:27)
all working up until chapter 19 included
Other chapters are - ok.
Use command: mvn clean package exec:java
try on two gpu platforms:
OS: debian 11
output:
java.lang.RuntimeException: Could not find uniform [shadowMap_0] in shader program [1]
at org.lwjglb.engine.graph.UniformsMap.createUniform (UniformsMap.java:24)
at org.lwjglb.engine.graph.SceneRender.createUniforms (SceneRender.java:77)
at org.lwjglb.engine.graph.SceneRender. (SceneRender.java:24)
at org.lwjglb.engine.graph.Render. (Render.java:25)
at org.lwjglb.engine.Engine. (Engine.java:25)
at org.lwjglb.game.Main.main (Main.java:28)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
at java.lang.Thread.run (Thread.java:840)
Audio stops halfway when playing a long audio file.
I tested this with a 1 minute stereo song and it only played 30 seconds of it.
I have looked around the problem and found a solution to it:
In the SoundBuffer
class and in the readVorbis
method, instead of passing in lengthSamples
to allocate the result, we need to pass in lengthSamples
multiplied by the channels
.
int channels = info.channels();
int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
ShortBuffer result = MemoryUtil.memAllocShort(lengthSamples * channels);
At the start of the chapter new dependencies are added to the pom.xml:
<dependency>
<groupId>io.github.spair</groupId>
<artifactId>imgui-java-binding</artifactId>
<version>${imgui-java.version}</version>
</dependency>
<dependency>
<groupId>io.github.spair</groupId>
<artifactId>imgui-java-${native.target}</artifactId>
<version>${imgui-java.version}</version>
<scope>runtime</scope>
</dependency>
However, neither ${imgui-java.version}
resolves to anything, nor ${native.target}
or ${imgui-java.version}
.
As a result, Maven complains that it cannot find io.github.spair:imgui-java-binding:jar:${imgui-java.version}
in Central https://repo.maven.apache.org/maven2
Are these placeholder values referencing something I should have added somewhere? I checked the original pom.xml, and I cannot see any definitons in there either.
Describe the bug
If you use the demo GUI and write text in an InputText, the standard characters will work but it's not possible to use the arrows to navigate in the string or to delete characters with DEL or BACKSPACE.
To Reproduce
Expected behavior
All keys should be mapped.
Screenshots
not needed
Desktop (please complete the following information):
Additional context
I tried to figure out how to solve it but I'm new to these topics and would appreciate your help.
Actually I like your book it's really well detailed and I like the way you structure the code.
This is the code for the scene.vert in the chapter 15:
vec4 tmpTangent = bonesMatrices[boneIndex] * vec4(tangent, 0.0);
initTangent += weight * tmpTangent;
vec4 tmpBitangent = bonesMatrices[boneIndex] * vec4(bitangent, 0.0);
initTangent += weight * tmpBitangent; // this should be initBitangent += ... Right?
I believe the initTangent is being set twice, and it should be replacecd by initBitangent
...
Another question about the chapter (more a question than an issue, really):
has it been tested for animations in the gltf format?
I'm able to load the animation data, and logs for the nextFrame() calls return sucessfully, but the animation never plays.
Thanks in advance.
Describe the bug
MouseInput
gets polled via window.pollEvents()
in Engine.run()
, line 51. This happens as fast as the program can run.A potential solution here is to not clear the mouse vector until it is polled (and adding to it in the meantime).
Or alternatively moving mouseInput.input();
out of Window.pollEvents()
and into Engine.run()
between line 57 and 58, so it is polled and used in the same frame.
Describe the bug
Line 38 in the file SceneRender.java in chapter 7 says
uniformsMap.setUniform("txtSampler", 0);
However, 0
is not a valid input for that function. It expects Matrix4f
there, but got an int
.
To Reproduce
Just paste the relevant lines into your IDE and watch it complain, I guess.
Expected behavior
Either for the function to accept 0, or to know what to put there instead. It seems to be about texture unit slots on the graphics card.
There seems to be a typo in the updateSpotLight method, in the SceneRender class:
..
uniformsMap.setUniform(prefix + ".conedir", coneDirection);
uniformsMap.setUniform(prefix + ".conedir", cutoff); // THIS SHOULD BE ".cutoff", RIGHT?
as per definition of the SpotLight struct in the scene.frag shader?
struct SpotLight
{
PointLight pl;
vec3 conedir;
float cutoff;
};
thanks in advance!
Hi.
Is there any way to get/compile the pdf-version of this book?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.