Android OpenGL ES & Quake 1 Tutorials (RFC)

Greets,

Some of you know me as Catharsis on JGO and I’ve been a member for quite some time going in and out of following the forums and posting over the years. Most recently I posted on the Auriga3D (a Quake 3 class rendering engine) port to Android.

Well I have some exciting news as my next project at Tactel US (I’m a software architect working on Android projects) is to start a technology blog/tutorial site for Android. I proposed basing the first tutorial sections on OpenGL ES and with a section on a Java port of Quake 1 as there is very little information specifically targeting Android, OpenGL ES, and 3D engines (let alone for desktop Java on this topic). With a bit of good fortune this topic was approved and I’ll be providing educational tutorials on core OpenGL ES techniques and dissect a bit of a Java port of a Q1 class engine and initially provide a port for the level renderer and model loader. This will provide a kick start for a native Java Q1 port effort and a foundation to complete the rest of the port to Android for those inclined to do so.

Here is an overview of the sections. Note Section 3 will draw from the NeHe tutorials that are pertinent to Q1 tech and may include new material for Android that is not a part of the NeHe tutorials. Section 4 is on the Q1 engine and will likely contain more sections.

I’d like you guys to review this outline and let me know if there are additional topics you’d like to see covered that fit into the general goals of the site.

My plan is to work pretty furiously on this project and launch it by Google I/O at the end of May with at least the Q1 level renderer and model loader completed if possible and all goes well.

Also this effort is a partial coordination with the Android & Me Mobile Quake challenge:
http://www.androidandme.com/2009/03/contests/android-bounty-ii-mobile-quake/

There is a Google group for the Q1 port effort here:
http://groups.google.com/group/android-bounty-ii-mobile-quake

Regards,
–Mike

Section 1: General Information

  1. Android Development Setup – This tutorial describes how to set up the Android developer environment for Eclipse and command line Ant compilation. Links to relevant information will be provided.

  2. AndroidManifest.xml – There are a lot of parameters in AndroidManifest.xml and some that are quite useful for the life cycle of an Android activity.

  3. Timing and Control – One of the most important aspects of near real time software development is accurate timing control. This tutorial will cover the EGR Software / Typhon timing mechanism that will be reused in all OpenGL examples and the Q1 engine.

  4. Setting up Android / OpenGL ES – Describes the base code used to setup the rendering context that will be used in all OpenGL ES examples including the Q1 engine.

  5. Testing capabilities of the device and OpenGL ES specific support.

  6. Input control – Describes framework code that will be used to gather input control from various sources such as the keyboard, trackball, and accelerometer. This tutorial also covers how to setup the standard menu system.

  7. An overview of the T-Mobile G1 – Pertinent information on the G1 and HTC Magic (“G2”) will be covered in this tutorial from processor information to OpenGL performance metrics.

  8. Android 1.0 API vs Android 1.5 API – Discuss the differences between both API versions and any ramifications on supported OpenGL ES functionality.

  9. NIO NIO NIO – Discussed Java NIO and why it is important for OpenGL rendering and networking. Also discusses performance issues when using NIO on Android.

Section 2: Math and Algorithms

  1. Vectors / Matrices / Normals – Provides an overview with links to other online material covering the basics of linear algebra including vectors and normals and some applied information. Discussion on the framework code that provides this functionality is discussed.

  2. Coordinate systems and units – Discusses the left hand and right hand coordinate systems and the concept of unit measurement in OpenGL.

  3. Faster math shortcuts - Including lookup tables and approximations for common functions

  4. Radix Sort – A fast sorting technique useful for alpha blending

  5. BSP Trees – A general introduction to binary space partitioning trees.

Section 3: OpenGL ES fundamentals & NeHe Tutorial Ports – One demo APK with all tutorials in finished form available for download

  1. Tutorial 1 – Vertex Arrays & Your First Polygon – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02
    In addition to the basic NeHe lesson OpenGL ES specific information will be covered including vertex arrays. A discussion on the various primitive drawing modes.
    Deliverables – source code for tutorial 1

  2. Tutorial 2 – Adding Color – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=03
    Deliverables – source code for tutorial 2

  3. Tutorial 3 – Projection, Model View Matrices including orthographic projection and basic camera functionality
    Deliverables – source code for tutorial 3

  4. Tutorial 4 – Rotation – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=04
    Deliverables – source code for tutorial 4

  5. Tutorial 5 – 3D Shapes – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=05
    Deliverables – source code for tutorial 5

  6. Tutorial 6 – Texture Mapping – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06
    Deliverables – source code for tutorial 6

  7. Tutorial 7 – Texture Filters, Lighting – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=07
    Deliverables – source code for tutorial 7

  8. Tutorial 8 – Blending – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08
    Deliverables – source code for tutorial 8

  9. Tutorial 9 – Fonts – Provides a discussion on font rendering with OpenGL ES and creating font textures dynamically from installed Android fonts.
    Deliverables – source code for tutorial 9

  10. Tutorial 10 – Masking – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20
    Deliverables – source code for tutorial 10

  11. Tutorial 11 – Bump-Mapping, Multi-Texturing & Lightmapping – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=22

In addition to covering the standard NeHe lesson lightmapping will be discussed as part of multi-texturing.
Deliverables – source code for tutorial 11

  1. Tutorial 12 – Alpha Blending / Alpha Testing / Sorting – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32
    Deliverables – source code for tutorial 12

  2. Tutorial 13 – Billboarding – Billboarding is one of the most crucial techniques to use to fake 3D shapes and allow for better rendering performance. Discusses the different types of billboarding and the math behind it.
    Deliverables – source code for tutorial 13

  3. Tutorial 14 – Point Sprites – Covers point sprite functionality and limitations with the G1.
    Deliverables – source code for tutorial 14

  4. Tutorial 15 – Particle Engine Using Triangle Strips – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19
    Deliverables – source code for tutorial 15

  5. Tutorial 16 – Bounding Geometry / Basic Collision Detection / Picking –
    Deliverables – source code for tutorial 16

This tutorial will cover basic bounding geometry including AABB, OBB, Sphere, Cylinder, Plane geometry primitives and collision detection between the various types and finally a picking example.

  1. Tutorial 17 – Advanced Picking w/ Touch Screen Interaction – The orientation of 3D objects on screen are not coordinated with touch screen interactions. This tutorial discusses how to find the orientation of a 3D object and adjust picking accordingly.

Deliverables – source code for tutorial 17

  1. Tutorial 18 – Frustum Culling – Discusses how to create a frustum which defines the viewing area. Tricks are necessary to complete this with Android / G1. Once a frustum is defined the first level of culling optimization is to remove objects that are not within the frustum.

  2. Tutorial 19 – Vertex Buffer Objects – http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=45

Defines the fastest way to render vertex data.
Deliverables – source code for tutorial 19

  1. Tutorial 20 – Time based state management / animation – This tutorial discusses animation and the importance to base all animation on time.

Deliverables – source code for tutorial 20

Section 4: Quake 1 Java Source Port – A demo APK will be available on the market.

  1. Historical background on Quake 1 – Discusses the state of computer graphics / OpenGL in 1999 when the Q1 source was released.

  2. Q1 level loader – Discusses the data structures and loading process to read in Q1 data

  3. Q1 level rendering – Discusses rendering a Q1 level including applications of frustum culling, state sorting, and other pertinent optimization techniques including how BSP trees play a major role in culling out unseen surfaces.

  4. Q1 model loading / rendering / animation – Discusses rendering a Q1 model and animation capabilities possible

  5. Q1 collision detection – BSP trees are used in both rendering optimization and collision detection. This tutorial will cover how to do collision detection with BSP trees and the bounding geometry primitives

  6. Basic player movements – Running, jumping, stair climbing, strafing in 3D and the necessity to do smoothing of trackball input to accomplish circle staffing. 
    

Further topics TBD

What about how to set it up in JCreator?

I’ve not heard of JCreator before this (I’ve been an Idea user for ages). If there is no specific plugin for a particular IDE then Ant scripts are most often used to compile Android apps, so the Ant setup in Idea will be very similar. This section of the blog will mostly be pointing to other tutorials on the web that already thoroughly document his process. I will be providing project files for provided source for Eclipse, Idea, and maybe NetBeans. It should be simple to add JCreator too if you can make the project files and submit them to me. I won’t have the time to go out and setup all IDEs though than the 3 mentioned previously.

Well I’m sure Google only supports eclipse atm with android.
So I don’t know why would someone want to use a IDE not supported… Doesn’t take long to learn a new IDE.

Eclipse is bulky, and non-portable. It’d be like using Vista when all you need is DOS.

And you will loose a lot of development time trying to write in a IDE that doesn’t support android.
Eclipse is portable, I use to use it a lot on the move. 500+ meg sticks are common and dirt cheap these days.
Bulky? well I guess it depends on if you need its features. Which in developing for android comes in handy…

Anyway, use what you wish. Now back on topic…
Looking good MichaelTACTEL.

heh heh… minor details regarding IDE support for the source code tutorials… I’ve been doing everything with Idea and Ant scripts regarding Android since I’m most familiar with Idea and used it forever (switch for a plugin feature / bleh). It would be nice to have debugging support and the like, but an Idea plugin for Android is officially being developed by IntelliJ.

Back to the topics though. I’d be glad to hear about additions to the list or topics that folks would like to read about.

It would be fine to speak about cells-and-portals algorithms and portal culling. If JOGL 2 was released, I would have liked to see something about its use on Android.

I’m going to include occlusion culling info regarding PVS - potential visibility sets as that is what is used in the Quake engine. PVS is a cell oriented algorithm I’ll make a footnote on other portal algorithms.

I’ll cover the Android OpenGL ES API. I don’t believe JOGL 2 will have too much impact in the near term for OpenGL ES and Android. Luckily though for JOGL users the API is practically the same just different imports.

The following document has been useful for me to understand some important steps in the portal culling:
http://geck.bethsoft.com/index.php/Occlusion_Culling
I have almost completely implemented in a simplified case (one stair, orthogonal walls :() the part entitled " Portals and Rooms (PortalMultibounds)". I am interested in having a deeper understanding of the way of subdividing more complex levels into cells and portals.

Actually, I agree with you in the near term but JOGL 2 will ease the port on Android of the rendering system of some existing engines that already support JOGL (JME 2, Ardor3D?, Xith3D?). I speak only about the rendering system because I assume that other aspects require more plumbing and tinkering.

Portal rendering/culling doesn’t apply to the Q1/2/3 engine. BSP + PVS is the faster culling method, but more limited/rigid technique. Fastest for enclosed spaces due to the split up and aggressive pruning of non visible surfaces during preprocessing.

It really is no big deal if you want to write portable code between OpenGL ES and OpenGL to choose the proper methods that are applicable to both. As far as I’m aware JOGL 2 isn’t some silver bullet and one feature is to simply provide different interfaces / capability sets for targeting common profiles (shared functionality between GL and GL ES 1.X and other combinations). The problem is a little more long term in nature too such that JOGL 2, JOGL 2 ES, JOGL 2 will “likely” never exist on Android, so it won’t really help porting to Android. If you hard code a renderer to a particular binding well you just limited release options to where that binding lives. Instead of taking pride in adoption of a particular binding the solution is applying modern software architecture concepts that minimize deployment issues. OpenGL is OpenGL and the syntactic sugar if you will regarding API to access GL functionality is moot.

I’m an equal OpenGL binding enthusiast and support the “Big 3” (LWJGL, JOGL, Android GL ES).

Now back to topic… Any improvements to the tutorial outline above… :slight_smile: This particular effort with these tutorials and Q1 port will be hard coded to Android GL ES binding.