Search icon
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Learning Hub
Free Learning
Arrow right icon
Over 7,000 tech titles at $9.99 each with AI-powered learning assistants on new releases
Building a 3D Game with LibGDX
Building a 3D Game with LibGDX

Building a 3D Game with LibGDX: Learn how to build an exciting 3D game with LibGDX from scratch

$25.99 $9.99
Book Aug 2016 234 pages 1st Edition
$25.99 $9.99
$15.99 Monthly
$25.99 $9.99
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details

Publication date : Aug 29, 2016
Length 234 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785288418
Category :
Table of content icon View table of contents Preview book icon Preview Book

Building a 3D Game with LibGDX

Chapter 1. Setting Up Your Development Environment

LibGDX's development is very powerful, and that is why we will set up a nice and stable structure to work with before jumping into the code and project structure. We will use IntelliJ IDEA to do most of our development for the simply because it's productive (and of course, there are few neat tricks to combine with LibGDX), though it's very common to use Eclipse for development too. There are other ways to set up a 3D game with LibGDX, but to start off this book; we will build the game with basic assets created by code. In this chapter, we will explain how to download and set up all the required tools to get you started with setting up an environment to build 3D games with LibGDX, and to work on desktop and Android platforms. Although LibGDX also builds for HTML (WebGL) and iOS, we won't cover these builds because they do not fit with our game, but they are as easy as the following documentation guidelines on the official site ( You will learn more about this in this chapter.

Assuming you know LibGDX, you already have the Java Development Kit (JDK) installed and the Android software development kit (SDK) updated (you need API 22 with the LibGDX version [1.6.4]); otherwise, a simple Google search will do. The steps are OS-free and we will use Windows to implement them.

We will cover the following topics in this chapter:

  • Downloading and installing IntelliJ IDEA

  • Setting up the LibGDX project and importing it to IntelliJ IDEA

  • Running and debugging the game

LibGDX 3D API overview

LibGDX is a Java cross-platform game development framework that released its first version in 2009. It lets you go as low-level as you want to and gives you direct access to all kinds of areas of development. It also comes with an OpenGL ES 2.0 and 3.0 wrapper interface, which is the one that lets us perform 3D development.

3D development with LibGDX already has a nice array of games under its belt already. The following screenshot shows a very popular game called Grandpa's Table, which is available on Android, iOS, and Amazon:

The following is a screenshot of an Android game named Apparatus:

The following screenshot is of the game Ingress, which is available on Android and iOS:

These are just a few of the most popular games out there.

We will not only cover as much as we can from this 3D API—to get the most of it and show a general structure for how to keep things organized and optimal—but also the use of other LibGDX tools to get the most of the framework too.

Downloading IntelliJ IDEA Community Edition

Download the latest version of IntelliJ IDEA Community Edition for Java developers from; it will suggest the download versions compatible with your current operating system. Select the version that best suits your operating system platform, which will either be 32-bit or 64-bit.

At the time of writing this book, IntelliJ IDEA Community Edition (14.1.4) is the latest version.

LibGDX project setup

At the time of writing this book, LibGDX was in version 1.6.4 and we will use that version. Download the setup app from and open it:

Set up your project name (ours will be called Space Gladiators) and package name (ours is com.deeep.spaceglad). Enter the game's main class name (ours is Core), set the destination path to your preferred directory, and point out the Android SDK directory location.

We will check the Desktop, Android, and iOS project, but leave out Html since we will use the Bullet physics API, which doesn't work on HTML because of the Google Web Toolkit (GWT) backend (for more information, check out

From Extensions, we'll select Bullet (Bullet physics API), Tools (Bitmap Font Generator [Hiero], 3D Particle Editor, and TexturePacker), Controllers (Controller Input API), and Ashley (Entity System API).

LibGDX comes, as you can see, with a lot of very useful tools that you should use for some time and explore them. We'll cover these selected APIs in some depth over the course of this book.

Click on Generate and wait. After it is done, open IntelliJ IDEA and click on Import Project. Go to your newly created project and look for a file called build.gradle, and IntelliJ will do everything else.

Basic use of IntelliJ IDEA with LibGDX

Running and debugging the app with IntelliJ IDEA is as simple as a click, but sometimes, we need to perform extra configurations on the IDE to avoid exceptions.

Running the Android app

Once IntelliJ is done with all the processes, the default app to run will be Android. To run it, click on the Bug or Play buttons to the right of the navigation bar:

Gradle will build and the Choose Device dialog will pop up, from which you'll choose the Android device on which you'll run the app (either an emulator or a physical device), for which you just have to plug in your device.

Running the desktop app

To run the desktop app we have to change the default configuration and add the desktop launcher:

  1. Click on android and select Edit Configurations; the Run/Debug Configurations dialog should pop up.

  2. Click on the + icon at the top left of it and select Application.

  3. Name it desktop. In the Main class field, select DesktopLauncher. For Working directory, go to your Android project and double-click the assets folder.

  4. Click on the Use Classpath of module field, select desktop, and then click on the OK button at the bottom.

Now instead of android at the top, you'll see desktop. You can run or debug with the two buttons to the right of it.


In this chapter, we introduced IntelliJ IDEA and its basic use; we also explained how to download and install it, and set up LibGDX Project for 3D work. We configured our work environment and launched the Android application into an actual device and the desktop application.

In the next chapter, we'll take the plunge to it and learn about LibGDX's 3D rendering API, perspective camera, 3D workflow, and more.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Implement an exhaustive list of features that LibGDX unleashes to build your 3D game.
  • Write, test, and debug your application on your desktop and deploy them on multiple platforms.
  • Gain a clear understanding of the physics behind LibGDX and libraries like OpenGL and WebGL that make up LibGDX.


LibGDX is a hugely popular open source, cross-platform, Java-based game development framework built for the demands of cross-platform game development. This book will teach readers how the LibGDX framework uses its 3D rendering API with the OpenGL wrapper, in combination with Bullet Physics, 3D Particles, and Shaders to develop and deploy a game application to different platforms You will start off with the basic Intellij environment, workflow and set up a LibGDX project with necessary APIs for 3D development. You will then go through LibGDX’s 3D rendering API main features and talk about the camera used for 3D. Our next step is to put everything together to build a basic 3D game with Shapes, including basic gameplay mechanics and basic UI. Next you will go through modeling, rigging, and animation in Blender. We will then talk about refining mechanics, new input implementations, implementing enemy 3D models, mechanics, and gameplay balancing. The later part of this title will help you to manage secondary resources like audio, music and add 3D particles in the game to make the game more realistic. You will finally test and deploy the app on a multitude of different platforms, ready to start developing your own titles how you want!

What you will learn

[*] Learn the potential of LibGDX in game development [*] Understand the LibGDX architecture and explore platform limitation and variations [*] Explore the various approaches for game development using LibGDX [*] Learn about the common mistakes and possible solutions of development [*] Discover the 3D workflow with Blender and how it works with LibGDX [*] Implement 3D models along with textures and animations into your games [*] Familiarize yourself with Scene2D and its potential to boost your game's design

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details

Publication date : Aug 29, 2016
Length 234 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785288418
Category :

Table of Contents

12 Chapters
Building a 3D Game with LibGDX Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Setting Up Your Development Environment Chevron down icon Chevron up icon
2. An Extra Dimension Chevron down icon Chevron up icon
3. Working toward a Prototype Chevron down icon Chevron up icon
4. Preparing Visuals Chevron down icon Chevron up icon
5. Starting to Look Like an Actual Game Chevron down icon Chevron up icon
6. Spicing Up the Game Chevron down icon Chevron up icon
7. Final Words Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by

No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial


How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to
  • To contact us directly if a problem is not resolved, use
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.