Skip to content

Commit 4fb2188

Browse files
committed
First draft public version
0 parents  commit 4fb2188

File tree

127 files changed

+10017
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+10017
-0
lines changed

GLOSSARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Glossary

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# 3D Game Development with LWJGL 3
2+
3+
This online book will introduce the main concepts required to write a 3D game using the LWJGL 3 library.
4+
5+
[LWJGL](http://www.lwjgl.org/) is a Java library that provides access to native APIs used in the development of graphics \(OpenGL\), audio \(OpenAL\) and parallel computing \(OpenCL\) applications. This library leverages the high performance of native OpenGL applications while using the Java language.
6+
7+
My initial goal was to learn the techniques involved in writing a 3D game using OpenGL. All the information required was there in the internet but it was not organized and sometimes it was very hard to find and even incomplete or misleading.
8+
9+
I started to collect some materials, develop some examples and decided to organize that information in the form of a book.
10+
11+
[Table of contents](SUMMARY.md).
12+
13+
You can also check my Vulkan book [here](https://github.com/lwjglgamedev/vulkanbook).
14+
15+
## Source Code
16+
17+
The source code of the samples of this book is in [GitHub](https://github.com/lwjglgamedev/lwjglbook).
18+
19+
The source code for the book itself is also published in [GitHub](https://github.com/lwjglgamedev/lwjglbook-bookcontents).
20+
21+
## License
22+
23+
The book is licensed under [Attribution-ShareAlike 4.0 International \(CC BY-SA 4.0\)](http://creativecommons.org/licenses/by-sa/4.0/)
24+
25+
The source code for the book is licensed under [Apache v2.0](https://www.apache.org/licenses/LICENSE-2.0 "Apache v2.0")
26+
27+
## Support
28+
29+
If you like the book please rate it with a start and share it. If you want to contribute with a donation you can do a donation:
30+
[![Paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5MH9AA9TPQQBN)
31+
32+
## Comments are welcome
33+
34+
Suggestions and corrections are more than welcome \(and if you do like it please rate it with a star\). Please send them using the discussion forum and make the corrections you consider in order to improve the book.
35+
36+
## Author
37+
38+
Antonio Hernández Bejarano
39+
40+
## Special Thanks
41+
42+
To all the readers that have contributed with corrections, improvements and ideas.

SUMMARY.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Summary
2+
3+
* [Introduction](README.md)
4+
* [Chapter 01 - First steps](chapter-01/chapter-01.md)
5+
* [Chapter 02 - The Game Loop](chapter-02/chapter-02.md)
6+
* [Chapter 03 - Our first triangle](chapter-03/chapter-03.md)
7+
* [Chapter 04 - Render a quad](chapter-04/chapter-04.md)
8+
* [Chapter 05 - Perspective projection](chapter-05/chapter-05.md)
9+
* [Chapter 06 - Going 3D](chapter-06/chapter-06.md)
10+
* [Chapter 07 - Textures](chapter-07/chapter-07.md)
11+
* [Chapter 08 - Camera](chapter-08/chapter-08.md)
12+
* [Chapter 09 - Loading more complex models (Assimp)](chapter-09/chapter-09.md)
13+
* [Chapter 10 - GUI (Imgui)](chapter-10/chapter-10.md)
14+
* [Chapter 11 - Lights](chapter-11/chapter-11.md)
15+
* [Chapter 12 - Sky Box](chapter-12/chapter-12.md)
16+
* [Chapter 13 - Fog](chapter-13/chapter-13.md)
17+
* [Chapter 14 - Normal Mapping](chapter-14/chapter-14.md)
18+
* [Chapter 15 - Animations](chapter-15/chapter-15.md)
19+
* [Chapter 16 - Audio](chapter-16/chapter-16.md)
20+
* [Chapter 17 - Cascade shadow maps](chapter-17/chapter-17.md)
21+
* [Chapter 19 - Deferred Shading](chapter-19/chapter-19.md)
22+
* [Chapter 20 - Indirect drawing (static models)](chapter-20/chapter-20.md)
23+
* [Chapter 21 - Indirect drawing (animated models) and compute shaders](chapter-21/chapter-21.md)
24+
* [Appendix A - OpenGL Debugging](appendix-a/appendix-a.md)

appendix-a/appendix-a.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Appendix A - OpenGL Debugging
2+
3+
Debugging an OpenGL program can be a daunting task. Most of the times you end up with a black screen and you have no means of knowing what’s going on. In order to alleviate this problem we can use some existing tools that will provide more information about the rendering process.
4+
5+
In this annex we will describe how to use the [RenderDoc](https://renderdoc.org/ "RenderDoc") tool to debug our LWJGL programs. RenderDoc is a graphics debugging tool that can be used with Direct3D, Vulkan and OpenGL. In the case of OpenGL it only supports the core profile from 3.2 up to 4.5.
6+
7+
So let’s get started. You need to download and install the RenderDoc version for your OS. Once installed, when you launch it you will see something similar to this.
8+
9+
![RenderDoc](/appendix-a/renderdoc.png)
10+
11+
The first step is to configure RenderDoc to execute and monitor our samples. In the “Capture Executable” tab we need to setup the following parameters:
12+
13+
* **Executable path**: In our case this should point to the JVM launcher \(For instance, “C:\Program Files\Java\jdk-XX\bin\java.exe”\).
14+
* **Working Directory**: This is the working directory that will be setup for your program. In our case it should be set to the target directory where maven dumps the result. By setting this way, the dependencies will be able to be found \(For instance, "D:/Projects/booksamples/chapter-18/target"\).
15+
* **Command line arguments**: This will contain the arguments required by the JVM to execute our sample. In our case, just passing the jar to be executed \(For instance, “-jar chapter-18-1.0.jar”\).
16+
17+
![Exec arguments](/appendix-a/exec_arguments.png)
18+
19+
There are many other options int this tab to configure the capture options. You can consult their purpose in [RenderDoc documentation](https://renderdoc.org/docs/index.html "RenderDoc documentation"). Once everything has been setup you can execute your program by clicking on the “Launch” button. You will see something like this:
20+
21+
![Sample](/appendix-a/sample.png)
22+
23+
Once launched the process, you will see that a new tab has been added which is named “java \[PID XXXX\]\(where the XXXX number represents the PID, the process identifier, of the java process\).
24+
25+
![Java process](java_process.png)
26+
27+
From that tab you can capture the state of your program by pressing the “Trigger capture” button. Once a capture has been generated, you will see a little snapshot in that same tab.
28+
29+
![Capture](capture.png)
30+
31+
If you double click on that capture, all the data collected will be loaded and you can start inspecting it. The “Event Browser” panel will be populated will all the relevant OpenGL calls executed during one rendering cycle.
32+
33+
![Event browser](event_browser.png)
34+
35+
You can see, the following events:
36+
* Three depth passes for the cascade shadows.
37+
* The geometry pass. If you click over a glDrawELements event, and select the “Mesh” tab you can see the mesh that was drawn, its input and output for the vertex shader.
38+
* The lighting pass.
39+
40+
You can also view the input textures used for that drawing operation \(by clicking the “Texture Viewer” tab\).
41+
42+
![Texture inputs](texture_inputs.png)
43+
44+
In the center panel, you can see the output, and on the right panel you can see the list of textures used as an input. You can also view the output textures one by one. This is very illustrative to show how deferred shading works.
45+
46+
![Texture outputs](texture_outputs.png)
47+
48+
As you can see, this tool provides valuable information about what’s happening when rendering. It can save precious time while debugging rendering problems. It can even display information about the shaders used in the rendering pipeline.
49+
50+
![Pipeline state](pipeline_state.png)
51+

appendix-a/capture.png

61.8 KB
Loading

appendix-a/event_browser.png

88.9 KB
Loading

appendix-a/exec_arguments.png

16.3 KB
Loading

appendix-a/java_process.png

17.1 KB
Loading

appendix-a/mesh.png

79.6 KB
Loading

appendix-a/pipeline_state.png

109 KB
Loading

0 commit comments

Comments
 (0)