Getting Started with OpenGL ES 3+ Programming by Hans de Ruiter - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Introduction

Welcome to this tutorial series, and congratulations for taking this first step. Maybe you’re interested in creating a game from scratch, and/or want to understand the code. Maybe you’re dreaming of writing your own game engine, or becoming a developer at a game studio. Or maybe you want to learn graphics programming for some other reason entirely. Whatever the case, you’re here.

These tutorials will give you an accelerated path from zero through to rendering stuff in 3D. You will learn modern OpenGL that’s usable on both desktop and mobile devices. No, it won’t meget you to AAA game engine level as that’s a huge task. However, it will give you the fundamentals you need before you can build more complicated stuff.

IMPORTANT: If your sole goal is to write a computer game and you don’t care about the code, then you may wish to look for a ready-made game engine instead. There are many game engines out there that can get your project underway faster. These tutorials are for those who want to learn how to do graphics programming which will help you build custom graphics engines or tailor existing ones to your needs.

  1. Who is this For?

These tutorials are intended for people with almost zero OpenGL programming experience. Having some C/C++ coding experience is helpful, but not required. The tutorials will explain the code at a fairly basic level.

That said, if you have no programming experience, then I recommend learning the basics of programming in C as well (e.g., follow this free online course: http://www.learn-c.org/).

  1. Why OpenGL ES 3+ and SDL2?

There are a mind-boggling array of options out there: OpenGL, Direct-X, Vulkan, Metal, GLUT, GLFW, etc. Which is best? How to choose?

I’ve chosen to teach OpenGL ES 3+ (GLES3) because it’s modern and available on all major mobile devices and is usable on desktops too. This maximises your options. Systems like Direct-X and Metal are restricted to specific platforms, and Vulkan is very complicated to use (definitely not good for beginners).

SDL2 (or Simple Direct-media Layer 2) takes care of low-level stuff like opening windows/screens, handling user input from joysticks, keyboards, touch, etc.. These tasks are normally platform dependent, and SDL2 gives you a common way of using them. There are other options like GLFW and GLUT, but I prefer SDL2. It has good support for both desktop and mobile devices, and provides a wide range of features, including multi-touch support, image loading (via SDL_image), etc. SDL2 also provides access to OS native objects should you want to use platform-specific features.

Don’t worry about whether SDL2 really is the best choice for you because it can always be replaced later if you wish. The key right now is to get started.

  1. How to Get the Most Out of These Tutorials

Simply owning a copy of these tutorials won’t magically give you expertise. It takes work, or to put it another way: “you still have to do your own push-ups.” Here are a few tips on how to get the most out of these tutorials.

First, follow the tutorials step-by-step. They’ve been written in a specific order for a reason; it’s what works best.

Write code by hand. It’s very tempting to copy and paste the code from this book to save time. Resist that urge, because you’ll learn and remember more by typing out the code manually.

Next, try to go through the tutorials on a regular schedule, e.g., one per day or maybe one every few days. You’ll learn and remember more with regular practise then trying to cram everything in a few sessions (e.g., 1 hour a day beats 7 hour marathons once a week)

Third, do the exercises and perform your own experiments. Try changing the code to do something else, e.g., draw a square instead of a triangle, change the texture or the colour, etc.

Finally, I’ve written a “Modern Graphics Programming Primer” to accompany these tutorials. While the tutorials teach you how to code graphics, you’ll be more capable if you understand what the hardware is doing (at least at a high level). The primer covers things such as: how modern GPUs work, 3D coordinate systems, and the underlying theory.

Get the primer at: https://keasigmadelta.com/graphics-primer

Image

What if I Get Stuck?

There’s a lot to learn, and you’re likely to get stuck at some point. Here’s what to do:

  1. Try to figure it out yourself first
  2. If you’re still stuck, search the internet for a solution. Chances are high that someone else has experienced your problem already, and published a solution
  3. Ask for help. Send me a message (https://keasigmadelta.com/support/)

Follow this process; resist the urge to jump to step 3 immediately. This isn’t for purely selfish reasons (I can’t respond to huge numbers of queries); it’s also better for you. By following this process you’re training yourself for developing software the real world. It’s how professional software developers solve problems.

That said, don’t be afraid to reach out for help if you need it. I’m happy to help, and knowing what people get stuck on will help me improve these tutorials.