LWJGL 3D Game Tutorial #1 - Java Workspace
Aug 15, 2023
LWJGL 3D Game Tutorial #1 - Java Workspace
Welcome to the first tutorial in my new 3D game tutorial series! Hope you find these videos helpful, please share any feedback you have in the comments! In this video I will walk you through how to use Eclipse to create and configure a new Java project, and use Maven to resolve the LWJGL jars which we will need in the following tutorials. Tutorial Code: https://github.com/Romejanic/LWJGL-Tu … Join the Discord: https://discord.gg/uJh37M4ynx Link to LWJGL Maven repo: https://mvnrepository.com/artifact/or … For the natives, here’s the list of technical names: - Windows (64 bit): natives-windows - Windows (32 bit): natives-windows-x86 - macOS (Intel): natives-macos - macOS (Apple Silicon): natives-macos-arm64 - Linux (x86 based): natives-linux - Linux (ARM based, 64 bit): natives-linux-arm64 - Linux (ARM based, 32 bit): natives-linux-arm32 Learn more and download: - LWJGL 3: https://www.lwjgl.org/ - OpenGL: https://www.opengl.org/ - Java Development Kit (JDK): https://www.oracle.com/au/java/techno … - Eclipse: https://www.eclipse.org/downloads/ - Maven: https://maven.apache.org/ - GLFW: https://www.glfw.org/ Thanks so much for watching, hope you found this tutorial helpful!
Content
0.21 -> Hello everybody, and welcome to my new channel:
Graphics Library University!
5.5 -> This is the first episode in my brand new
series which will cover the basics of creating
10.13 -> 3D graphics using the OpenGL API.
13.42 -> In this video, I’m going to be discussing
a little bit about the topics in this series,
19.009 -> introducing the libraries we are going to
be using, and setting up our workspace so
22.89 -> we can get started coding in the next video!
26.67 -> This series will go into the basics of creating
real time 3D graphics and building a simple
31.22 -> 3D game!
32.22 -> We’ll be covering a diverse range of topics,
including but not limited to: drawing, shading,
38.07 -> texturing, lighting, UI, post processing and
much more.
41.969 -> We’ll be starting from absolute scratch
with OpenGL, and building up our render engine
47.82 -> from the very ground up.
50.109 -> And of course, if there is anything you guys
want to see covered in particular, please
53.43 -> do let me know in the comments of the videos!
57.489 -> To try and keep my code as simple as possible,
I am going to be using Java as my programming
61.739 -> language of choice.
63.67 -> However all of the computer graphics concepts
will carry over directly to another language
68.509 -> such as C, C++, Python, etc.
72.409 -> However there are certain elements you will
need to find other tutorials for, such as
75.75 -> opening a window, handling user input and
the OpenGL functions may be slightly different
81.259 -> as C/C++ will require pointers for many of
them.
87.509 -> As for the library, I am going to be using
LWJGL 3 in order to access the OpenGL and
92.96 -> GLFW APIs.
95.149 -> LWJGL stands for Lightweight Java Game Library,
and it contains bindings for many different
100.27 -> C libraries which can be used for creating
basic 3D games.
104.729 -> In our case, we’re going to need the bindings
for OpenGL, which is an API for drawing 3D
109.74 -> graphics on the GPU, and for GLFW, which is
a nice API for creating and managing the window
116.039 -> for our game.
119.17 -> For my IDE I’m going to be using Eclipse.
121.28 -> However, you are obviously welcome to use
any Java IDE for your project, such as IntelliJ
126.58 -> IDEA or Visual Studio Code as some examples,
however please ensure that your IDE has Maven
133.22 -> support in some form, as we will be using
it to resolve the libraries for our project.
138.22 -> With all that out of the way, let’s proceed
to creating our project!
142.2 -> To start off, let's right click on our package
explorer, and select “New” and then “Java
149.02 -> Project”.
150.02 -> You can call it anything you want, I’m going
to be calling mine “My Game”.
153.98 -> Once you’ve picked a name, hit Enter or
click the “Finish” button.
158.02 -> Once that’s created, click the tick next
to the project to open it up.
163.62 -> This next step is optional but I still like
to do it.
166.31 -> If your JRE System Library is above your src
folder (like this), you can right click on
171.4 -> the project, then go to “Build Path” and
“Configure Build Path”.
175.82 -> In the “Order and Export” tab, just click
on the “Down” button, then click “Apply
183.37 -> and Close”.
184.42 -> In order to use Maven to resolve our libraries,
right click on the project, then click “Configure”
192.2 -> and “Convert to Maven project”.
194.37 -> You can choose any group and artifact ID you
want, I’m going to set my group ID to “com.glu”
201.9 -> and my artifact ID to “my-game”.
204.08 -> Once you’ve filled that out click on “Finish”.
209.68 -> Obviously this step will differ if you’re
using a different IDE so make sure you follow
213.19 -> the appropriate steps to configure your project
to use Maven.
217.81 -> Now it’s time to add LWJGL to our library’s
build path, so open up a browser and navigate
223.76 -> to the link in the description labelled “LWJGL
Maven Repository” (https://mvnrepository.com/artifact/org.lwjgl/).
228.9 -> This link will take you to a list of all of
the available LWJGL bindings we can choose
234.41 -> from.
236.45 -> For this tutorial series, we’re going to
need LWJGL, LWJGL OpenGL Bindings and LWJGL
242.97 -> GLFW Bindings, so go ahead and open each of
these in a new tab.
250.29 -> If we go to the first tab, you’ll see a
list of versions we can choose from.
253.48 -> As of the recording of this video the latest
version is 3.2.3.
258.449 -> If there is a newer version available, it
should be fine to use it, however if you’re
261.959 -> watching this off a few years down the line,
check the description of this video in case
266.069 -> there’s a version which is incompatible
with this tutorial.
269.669 -> Anyway I’m going to go and select version
3.2.3 for each of these libraries.
273.78 -> Make sure you select “Maven” in the tab
list on the page, and you’ll see a bunch
277.979 -> of XML code.
279.68 -> This is what we’ll paste into the pom.xml
file so Maven can resolve the libraries for
283.68 -> us.
284.75 -> So just select all this code and copy it.
289.55 -> Back in Eclipse, we’re going to open up
our pom.xml file.
297.169 -> Underneath the build tag, we’re going to
create a new dependencies tag.
305.37 -> Inside the dependencies tag, we’re gonna
paste the code from the Maven website.
313.33 -> We now have the tag for one of the libraries,
now we just need to copy the XML code for
318.35 -> the OpenGL and GLFW libraries.
324.34 -> Once you’ve done that, we’re still not
quite done.
337.83 -> You see, these libraries also require something
called natives, which is how they are able
343.56 -> to access C libraries from the Java code.
346.8 -> Unfortunately natives are specific to operating
system, so you’ll have to choose the appropriate
351.419 -> natives for your computer’s operating system.
354.74 -> I have a list of all the available LWJGL natives
on screen now, so take a note of the technical
361.84 -> name for your operating system.
363.87 -> This list is also in the description if you
would like to copy and paste it.
368.46 -> Back in pom.xml, we’re going to duplicate
all of the tags we just made, so we have two
373.23 -> copies of each one.
375.319 -> However for the copies, we’re going to add
a new classifier tag inside of each of them.
387.29 -> This will tell Maven that we want to resolve
a different file associated with the libraries,
391.669 -> rather than the libraries themselves.
393.999 -> The different files will be the natives for
each of these libraries.
396.99 -> For me that will be natives-windows since
I am on a 64 bit Windows machine, but remember
403.289 -> to simply use whichever technical name is
correct for your OS.
407.52 -> Just remember to copy the
classifier tag for all three of your libraries,
424.809 -> but make sure there is still a copy of each
library without the classifier tag, so Maven
437.13 -> will load both the Java code and natives for
each one.
441.599 -> If we go ahead and save our pom.xml file,
you should soon see a new Maven Dependencies
447.69 -> library in your Java project, and if we open
it up you’ll see the jar files for each
454.5 -> of our dependencies!
456.01 -> If it doesn’t immediately appear, try clicking
on the project and pressing the F5 key to
463.68 -> refresh your project.
465.93 -> And there we go!
466.93 -> Our Java project is now set up and correctly
configured for using LWJGL and we are ready
471.52 -> to go ahead and start creating our game!
474.58 -> Thank you so much for watching this introductory
tutorial, in the next video we’ll be exploring
479.159 -> how to create a window using GLFW so we can
begin drawing some graphics.
485.379 -> In the description of every video there will
be a link to a GitHub repo with all of the
489.169 -> code from each episode, and a link to a Discord
server I’ve set up which you can jump onto
494.15 -> and get help from me and others in real time.
497.219 -> In the meantime, thank you so much for watching
and be sure to like this video and subscribe
501.65 -> to this channel in order to keep up to date
with any future tutorials.
504.949 -> Thank you so much for watching, hope you have
a wonderful day!
Source: https://www.youtube.com/watch?v=r3CIqJfey1Y