Code Monkey home page Code Monkey logo

lwjglbook's People

Contributors

lwjglgamedev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lwjglbook's Issues

Streams.toList vs Streams.forEach

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.

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

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!

chapters 20,21 getting Shader code: Type mismatch

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

Chapters 17 and 18 are not working

Other chapters are - ok.

Use command: mvn clean package exec:java

try on two gpu platforms:

  1. Renderer: NVIDIA GeForce GTX 960M/PCIe/SSE2 Version: 4.3.0 NVIDIA 525.147.05
  2. Renderer: Mesa Intel(R) HD Graphics 530 (SKL GT2) Version: 4.6 (Core Profile) Mesa 22.3.6

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 problems in Chapter 16

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);

[Chapter 10] Maven cannot resolve some symbols in pom.xml

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.

Arrows, delete and backspace not binded

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

  1. open any chapter (I did it with chapter 10 since it's where we introduce GUI)
  2. in the Dear ImGui Demo window go to Widgets > Text Input > Filtered Text Input
  3. type text
  4. try to delete it

Expected behavior
All keys should be mapped.

Screenshots
not needed

Desktop (please complete the following information):

  • OS: Windows

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.

[CHAPTER 15] typo in scene.vert initTangent set twice, second time should be initBitangent

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.

Chapter 8 - mouseInput.input() polled too often (or not checked often enough)

Describe the bug

  1. Chapter 8 is about camera movement. MouseInput gets polled via window.pollEvents() in Engine.run(), line 51. This happens as fast as the program can run.
  2. However, polling clears the previous mouse position delta, then grabs a new mouse X/Y delta.
  3. Input is checked in line 58 of Engine.run(), whenever a display frame occurs, so it's happening at a rate of let's say 60 times per second.
  4. The problem: The mouse cursor position is polled and cleared much more often in line 51 than it is applied in line 58. As a result mouse movement is basically ignored unless you happen to catch a mouse delta in the frame it checks for it. (then it stutters into a slightly different position.)

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.

chapter-07/src/main/java/org/lwjglb/engine/graph/SceneRender.java has invalid code

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.

[CHAPTER 11] SceneRender updateSpotLight typo ".conedir" should be ".cutoff"

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!

PDF version

Hi.

Is there any way to get/compile the pdf-version of this book?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.