The Modern OpenGL tutorials series continue - now with a first section on lighting, covering the different kind of lights (sun, hemi, spot, etc.) using a simple diffuse model and clear code.

This one is derived from the excellent set of Blender GLSL tutorials by Martin Kraus.

As usual, the documentation is CC-BY-SA/GFDL, and the code is in the public domain.

We're also expecting another tutorial on scientific visualisation.

[EDIT: lighNing->lighing - sorry for the typo :)]

Posted Thu Sep 8 18:48:07 2011 Tags:

plot Guus started a new section in the OpenGL wikibook about scientific uses! In a first tutorial, he showcases how to interactively plot a simple mathematic function:

suzanne The lighting front is also progressing with a new tutorial on ambient and specular lights:


Posted Thu Sep 8 19:18:20 2011 Tags:

plot Guus wrote another scientific OpenGL tutorial, storing ordinates as a one-dimensional texture for increased performances.

two-sided I also went ahead and added a tutorial on two-sided lighting:

Remember: this is free documentation that you can share and/or improve upon - make sure you do so :)

Posted Tue Sep 13 06:55:56 2011 Tags:

flying cube Using plain C arrays of coordinates, instead of Vertex Buffer Objects, confused some readers. I did it so that the very first tutorials would be simpler.

However, it also appears that plain C arrays are not supported at all starting with OpenGL 3.0. Plus, specifying offsets is done differently in each case, and people will use VBOs in the end for performances.

So the basic tutorials are now rewritten to use VBOs :) It took me longer than expected!

Posted Tue Sep 13 23:21:48 2011 Tags:

I searched forever for a way to just build the examples in the Android NDK, preferably from the command line. Here's how.

First step: build the C++ code:

cd /usr/src/android-ndk-r6/samples/san-angeles/

Simple enough.

Second step:

You will then need to generate your final .apk through the usual means. -- Android NDK Dev Guide

Thanks a ****ing lot!

In addition the documentation is very much Eclipse-centered - and I can't be bothered to install and configure all the Eclipse stack for a mere Java wrapper for the above-generated .so file XD

We first need to use the 'android' wrapper and download the "SDK Platform Android 2.2, API 8, revision 3" - aka "android-8", the first environment to support OpenGL ES 2.


It appears we first need to "manage the project", more precisely import from an existing project:

So we create a project by importing the sources from the current directory:

/usr/src/android-sdk-linux_x86/tools/android update project \
  --name san-angeles --path . --target "android-8"

Then we use ant to build the thing:

apt-get install ant openjdk-6-jdk
ant debug  # avoid messing with signing

We now have a bin/san-angeles-debug.apk and we can run it in the emulator. Create a new "Virtual device" using the "android-8" platform we downloaded above, and launch it. Given the time needed to boot the OS, I suggest enabling snapshots. Scaling to display resulted in a very tiny, dark and slow display, in a first step I suggest using a non-scaled one.


At last we can run it! Install it in the emulator:

/usr/src/android-sdk-linux_x86/platform-tools/adb install -r bin/san-angeles-debug.apk

You'll find a DemoActivity in your apps directory :)

Note: I tried to compile the "hello-gl2", showcasing OpenGL ES 2.0, but sadly it crashes:

Sorry! The application GL2JNI (process has stopped unexpectedly. Please try again.

The emulator apparently doesn't advertise EGL_OPENGL_ES2_BIT (checked in in If you try to by-pass it, you'll get loads of:

E/libEGL ( 333): called unimplemented OpenGL ES API

It's worth noting the OpenGLES20 sample from the "API Demos" application uses a fall-back OpenGL ES 1 renderer if v2 is not available - it made me mistakenly believe that OpenGL ES 2 was supported only from Java >(

OpenGL ES 2 is not supported in the emulator as of 2011-09-17 - period.

Posted Sat Sep 17 10:50:57 2011 Tags:


Here's a third tutorial from Guus focused on GPU-assisted plotting. It also provides excellent exercices on manipulating the OpenGL windows using the Viewport and the Scissors :)

The OpenGL wikibook is free documentation, and you are welcome to redistribute it under certain conditions; see the CC-BY-SA or GFDL licenses for details ;)

Posted Mon Sep 19 19:36:27 2011 Tags:


After some restless hours of debugging, here's Phong lighting :)

The code can be optimized, but should give you a clear understanding on how to make smooth OpenGL lighting. And you can admire the stunning results with a mere basic material and one lamp!

Posted Sat Sep 24 21:58:41 2011 Tags:


Here's the fourth tutorial from Guus on Scientific OpenGL, this time going 3D, plotting the "Mexican Hat" function, and covering various line drawing methods as well as Index Buffer Objects.

Posted Tue Sep 27 20:10:53 2011 Tags: