OpenGL ES - A Gentle Introduction

So far my adventures have been going well, no fatalities to report. As I continue forward, the more and more I want to keep going, this stuff is truly fascinating. Once I can get to the point of making pointless RPG games for my Nexus 7, I will be in a good spot, haha.

So lets being. This is what I have covered thus far; I will try to expand on my own notes a bit, so you can better follow along. Any questions, please leave a comment below, and I will try to answer as best as I can. Remember, I am just learning.  :P

What is OpenGL?

When looking at graphics programming with Android, the standard Canvas API can only do so much. It is a very simply solution to very, very simple graphics based applications. With that, we can look toward OpenGL for the ability to not be limited in the 2D realm, and enter the world of 3D, with a lot of power at our disposal.

OpenGL ES is an industry standard for 3D graphics programming, that is mantained by the Khronos Group, a conglomerate made up of ATI, NVIDIA, and Intel. Together, they define and extend the industry standard for OpenGL, and other vital aspects of technology, all in a rather successful attempt of connecting software to silicone.

When it comes to using OpenGL ES with Android, we must take a special note when it comes to what version of OpenGL ES we want to use:

  • OpenGL ES 1.0: Supported by all Android devices, old and new
  • OpenGL ES 1.1: Supported by most newer Android devices
  • OpenGL ES 2.0: Only supported by Android 2.3 and higher

Now why is this? Well, OpenGL ES 1.X follows a fixed-function pipeline, where all functions used are pre-defined and more or less, cannot be directly altered. This is perfectly fine for the majority of games that one may develop. OpenGL ES 2.0 adds shaders, which is a standard part of standard OpenGL. This allows for programmatically defined parts of the rendering pipeline. Since OpenGL 1.X is most supported, and is perfectly fine for our purposes, it will be used.

Understanding OpenGL ES - An Analogy

The best way to explain the OpenGL ES programming model is with the whole camera analogy. You can think of OpenGL ES as working like that of a camera. When you are going to snap a picture, you have to go to the scene you wish to photograph. This scene is made up of objects, all of which maintain some sort of position and orientation relative to your camera. Though some of these object maybe moving, when you press the shutter release, you catch a still image of the scene, and thus, you get a still image of all of the objects, with their relative position, orientation, etc, at that exact moment.

This whole idea is a very abstract, high level look into how OpenGL ES is modled. To better understand how this applies, we need to define some things:

  • Objects (or models) - Made up of geometry, color, texture, and material. Geometry is defined by a set of triangles, each of which has a position in 3D space (x, y, z). Color follows the standard RBG triple, and texture can be thought of as an image that covers the object.
  • Lights - Mathematical objects with positions and/or directions in 3D space, with color attributes, etc. 
  • Camera - Mathematical object with position and orientation in 3D space. Controls what is actually seen, much like a real camera (starting to connect to our analogy). This defines a viewing area, or view frustum.
  • Viewport: Defines the size and resolution of the final image

While this may seem a little abstract, simply remember this: OpenGL ES can construct a 2D bitmap of everything in our scene from the camera's point of view. This is all done via projection.

OpenGL ES - A New Adventure

I have been wanting to learn OpenGL for quite a long time. I have a pretty extensive background with doing game development using libraries like SDL and PyGame, though never really got into anything complex. This is why I've been so interested in OpenGL, and learning the library for myself.

OpenGL is pretty complex, and allows for some very advanced graphics processing. After looking through many books and online tutorials (which are a bit lacking, I might add), I've decided to start my adventures with OpenGL ES, a slimed down version of OpenGL for mobile devices and embedded systems. My focus will be OpenGL ES on the Android platform, as I have a number of books covering the topic, including the series of books covering Android 4 Games Development.

As I start going through the books, and thus beginning my adventure in into the world of OpenGL awesomeness, I figured that I would need to document my learning in some way. Normally, I would just get a journal, to take notes in and what have you. Though, I figured since I have this lovely website setup to document my works, I might as well use it as such. So, with that being said, as I have the free time to go through my OpenGL / OpenGL ES books, I will make various blog posts discussing what I have learned, with code examples, etc. I figured this will not only help me really understand the vast complexity of OpenGL, but it may also help someone else get started, because at first glance, OpenGL, and even the slimmed down OpenGL ES, can be a bit scary.

So with that, I begin my journey. See you all on the other side!

Code on!

-
Zach

Woah, a blog post!

No everyone, I have not at all forgotten about this glorious website of mine, nor have I forgotten about the blog in which it houses. I have been extremely busy with school work, and just life in general. I have just begun my senior year in high school, and as such, I have quite the homework load, trying to stock up on AP / College credits, in the hope that it will benefit me when I start my Fall term at the university level.

Due to this lack of free time, I haven't had the opportunity to work on my projects too much, and as you know, update 'ye 'ole blog. I have been receiving a lot of emails inquiring about the status of my Android-chan project, wishing to receive status updates, and to even get their hands on the source code. After some final testing, I decided to push the current stable development version on the Google Play Store. This, first and foremost, allows you all to have access to the project, and to begin figuring out what is good, and what completely sucks. Once I compile all the feedback I receive (it has been less than 24hours since the release and I already have 100 emails, cool!) I will be able to fix these issues, as quickly as I am able to. I will also be trying to implement new features whenever I can. Sadly, the current version I feel is super lacking, my goal was to have thread monitoring and thread posting / replying for 4chan implemented, though that just didn't happen. Furthermore, with the recent release of the 4chan API, I am going to have todo some testing to see if my backend API works better than the official API, or if I need to redo some backend stuff, to implement this API.

With all of this being said, and with all of the awesome feedback I am getting from people, I will continue working on this project, making progress whenever I can. Though, with that being said, I do apologize in advanced if it takes a while to get updates out. For now, school takes top priority.

I believe that sums up everything that I have to say currently. Until next time, code on my fellow tech enthusiasts! 

-
Zach