GithubHelp home page GithubHelp logo

lwjglgamedev / lwjglbook-bookcontents-leg Goto Github PK

View Code? Open in Web Editor NEW
161.0 18.0 65.0 13.91 MB

Book contents for the book "3D Game Development with LWJGL 3" (https://ahbejarano.gitbook.io/lwjglgamedev/).

CSS 100.00%

lwjglbook-bookcontents-leg's Introduction

3D Game Development with LWJGL 3 (Legacy version)

**** IMPORTANT: If you are here, you are viewing the legacy version. It is kept in case it contains usefull information for anybody but it will not be maintained **** **** IMPORTANT: Current version is here ****

This online book will introduce the main concepts required to write a 3D game using the LWJGL 3 library.

LWJGL 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.

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.

I started to collect some materials, develop some examples and decided to organize that information in the form of a book.

2020/06/20 - NEWS: Vulkan book first chapters already available here.

Source Code

The source code of the samples of this book is in GitHub.

The source code for the book itself is also published in GitHub.

License

The book is licensed under Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)

The source code for the book is licensed under Apache v2.0

Support

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:
Paypal

Comments are welcome

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.

Author

Antonio Hernández Bejarano

Special Thanks

To all the readers that have contributed with corrections, improvements and ideas.

lwjglbook-bookcontents-leg's People

Contributors

alanjoshua avatar arrwhidev avatar benjman avatar chinjja avatar derkuehnekollege avatar hexeption avatar hfreeb avatar httpdigest avatar insprill avatar j-ibarra avatar jgweiss01 avatar kahitar avatar lwjglgamedev avatar mcol avatar mido3ds avatar mouse0w0 avatar nicarran avatar nutriz avatar ogregoire avatar phlosioneer avatar rems19 avatar robertindie avatar rubbaboy avatar samypesse avatar shepherdjerred avatar stefancanvas avatar technicalsoup avatar thestacktracewhisperer avatar tylorkolbeck avatar vzaramel 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lwjglbook-bookcontents-leg's Issues

NanoVG restore state

After rendering UI with NanoVG, you restore the state. You forgot to restore the GL_CULL_FACE stuff. Maybe default state should be set at one place.

PNGDecoder vs STBImage

In the latest release of LWJGL, there is STBImage class for loading images. Is there any particular reason to use PNGDecoder in the book?

If you wish I can rewrite the needed chapter :)

Typo in chapter 17

In the shader file, this line has a typo:
newNormal = texture(material.normalMap, text_coord).rgb;

It should be normalMap only, not material.normalMap

Add alpha support to textures chapter

Hi,

I really enjoy your gitbook, it's very helpful! However in the texture chapter, I feel like you should at least mention how to work with alpha values in an image. It's not even that hard from what I googled (https://learnopengl.com/Advanced-OpenGL/Blending). Of course, I can always pull the repository and add it myself and then do a pull request. I just would like to know your thoughts on this matter.

Cheers!

Chapter 7 - wrong cube indices

Hi!

Was left for a while trying Unity, got sick of it! :D
Back again, and started from scratch again, to get a deep understanding now.
Here is the current issue I found.
The indices wrong for the cube.
These will be good though:
// Front face 0, 1, 3, 3, 1, 2, // Top Face 4, 0, 3, 5, 4, 3, // Right face 3, 2, 7, 5, 3, 7, // Left face 6, 1, 0, 6, 0, 4, // Bottom face 2, 1, 6, 2, 6, 7, // Back face 7, 6, 4, 7, 4, 5,

Variable name error

Page 11:
I think current should be replaced by loopStartTime, or I don't understand something.

Annotation 2019-06-29 130805

Requesting discord for chapter support (excercises)

Hi, Can I request for discord, I am trying these chapter exercises. Currently working on cascading shadow maps but I'm having a problem. As you can see, that the only shadow I see is a big grass shadow. I am not directly copying the code instead I am using ECS (Entity Component System) framework

image

Book updates are not being compiled to web page

It seems that updates to this repository are not being compiled into the website https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl anymore.
For example, the page https://lwjglgamedev.gitbooks.io/3d-game-development-with-lwjgl/content/chapter06/chapter6.html still references a very old JOML version 1.9.6 (from 2017), but the version has been updated many times in the GitHub repo already.
I am assuming that this also applies to any other of the many many changes to the book.

Typo in readme

The source code for the book itself is also publishd in GitHub.
that line is missing an "e" in published.

Calculating Normals at Runtime

So, I'm working on a sort of Minecraft-like clone, and everything worked great up until I added the lighting system. Without ambient light, every mesh is completely black. My first thought was that the normals I was supplying were wrong, but I don't think so. This is how I define my normals: new Vector3f(1, 0, 0) this specific normal is used on a left-facing face, and I have tried flipping the normals.

After I found out it wasn't working, I copied and pasted the shader code and lighting code, so that's not the problem. I really don't see what could be wrong. The only light that works is ambient.

Here is my code for creating the light sources:

ambientLight = new Vector3f(0.5f, 0.5f, 0.5f);
pointLight = new PointLight(new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0, 0, 0), 100.0f, new Attenuation(1.0f, 0.0f, 0.0f));
directionalLight = new DirectionalLight(new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(-1.0f, -1.0f, 0.0f), 100.0f);

If you have any suggestions for what I should be doing or what I can do to debug, please let me know. Thank you.

Full source code is available here: https://github.com/cjburkey01/Cubulus

Chapter19 calculate normals

You do it like this when computing the vertex normals:

v0.normal.add(normal).normalize();
v1.normal.add(normal).normalize();
v2.normal.add(normal).normalize();

Is it correct?
It seems to me that the newly added normal will take more weight if there're more than 2 triangles and It's not an arithmetic mean.
Am I missing something?

2D look on 3D objects using z-buffer with perspective projection

Hi all.
My question and source code will be based on secion 9 (camera) because IMHO there is no need to go any further to explain my problem or post my whole source code.
In my application I want to have a 3D scene (all objects expecting hud, text a.s.o. are in 3D space) but they are shown only from one side, camera will not be movable. You could imagine a plattformer game. But there should be more than one layer for the backgrounds (textured quads will be ok I think) and this make a problem, because the z-buffer differences result in scaling/resizing of the textured quads, since the objects are at different distances to the camera. How do I avoid the resizing /scaling of my objects done by the perspective projection?
I don't want to solve this with the orthographic 2D scene.
I tried to implement it in 2 to ways, the z coordinate set for all positions to 0.

First way was in the vertex shader after all projections:
gl_Position.z=(u_zOffset-1.0)*gl_Position.w;

Second way in the fragment shader, setting the the end the gl_fragDepth to some value, range [0, 1], for example:
gl_FragDepth = 0.5f;

Both methods didn't have any effects. What do I wrong? Is there an other way to go?
regards

OBJ file confusing

Hi!

I learn OpenGL using your tutorial, thinmatrix's tutorials and learnopengl.com's tutorials. I do not copy the codes, write my own mixing the knowledge I learned from all of them.

Yesterday I debugged a lot when I finished to implement my lightning, because light was so strange (simple cube exported from blender):
https://drive.google.com/open?id=0Bz3i57GvpVZhYXRqRlpzY2lYQnM

Debugged hours and found that all of my code is OK(?), so I started to think is my obj ok as well?
I downloaded the dragon and it was OK. Downloaded your cube.obj from the source code and it was OK as well.
https://drive.google.com/open?id=0Bz3i57GvpVZhMUFaUWI4dnZLbEk

The interesting thing is that I downloaded several cube.obj files from the internet, and all of them were wrong, such as:
https://drive.google.com/open?id=0Bz3i57GvpVZhVUh5eFVNUm5YZWM

So my question is: I followed your and thinmatrix's tutorials as how to export OBJ from blender and I fail. What could be the problem? I just open blender, export and use this settings:
https://drive.google.com/open?id=0Bz3i57GvpVZhSHFXRm9GcDQwOVk

And I got the strange colors as it was shown on the first link.
Am I doing something wrong in blender? Is my code the bad guy?

One more thing: I use for OBJ loading the thinmatrix's approach, but tried the failing cube.obj files with your objloader as well, but nothing changed.

I use CentOS now, Intellij Idea and the latest Java/LWJGL/Blender.

Chapter 12 part 3 : Font rendering issue

image

First I would like to thank you very much for this awesome tutorial. It is rare that I have the patience to read through pages of explanations but your writing is very easy to follow.

I am having problems with the rendering of the system fonts in Chapter 12 part 3. As you can see on the screen shot some letters seem to have misaligned texture. It is supposed to read "M m M D d". I am running your maven project with Eclipse with JRE version: OpenJDK Runtime Environment (11.0+28) on a windows 10. I did not see any problems in previous chapters but I tried running some of the projects towards the end (for example chapter 28) and I get a crash. I could create a new issue but maybe it is related. Maybe my system is corrupted. Anyway when I run chapter 28, the window appears very small in the top left corner and disappear with the following console message:


#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffde6472503, pid=9620, tid=16872
#
# JRE version: OpenJDK Runtime Environment (11.0+28) (build 11+28)
# Java VM: OpenJDK 64-Bit Server VM (11+28, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C  [ntdll.dll+0x12503]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\ramho\eclipse-workspace\lwjglbook\chapter28\hs_err_pid9620.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp

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.