Wednesday, August 7, 2013

OpenGL and Ubuntu

So I am dusting off my old GNU/Linux PC. It's pretty antique, as I had brought it over from the old country when I immigrated into Canada so long ago. It turns out that it is so old (from 2005 or so), that it can't do 64 bit. (It has an Intel Pentium M at 1.6GHz.) I gave it a fresh copy of Ubuntu 13.04 to see if I can port Little Crane to GNU/Linux.

Initially, I thought it would be easy because I already ported it to Raspbian (which is Debian running on the Raspberry Pi.) But the Raspberry Pi makes it easy, since you can get straight access to the GPU via OpenGL-ES2. There is no need to go through Xwindow, courtesy of the videocore libraries (libvcos) that comes with the little computer. On vanilla GNU/Linux, this is not so easy. First, I have yet to figure out: should I go the GLES2 route? Or can I somehow get access to OpenGL3 Core Profile on Ubuntu? So far, I'm not really sure how to do OpenGL3 on Ubuntu. The only reference to gl3.h header file in Ubuntu, is in a GLES package, strangely enough. However, I stumbled onto GLFW which promises a painless access to GL on UNIX. I will evaluate this framework.

To start off: GLFW is best retrieved from GIT, because the version in Ubuntu (2.7.x) is old. Furthermore, it is incompatible with the current version in GIT. Next, to build it, you need to use cmake. Then you can test by running the examples.

When it comes to building your own app on top of GLFW, it looks like you can force the use of GLES2 by doing:

#define GLFW_INCLUDE_ES2
#include <GLFW/glfw3.h>
Also, it turns out you need to force extension prototypes with:
#define GL_GLEXT_PROTOTYPES 1
...before including the GLFW header.

1 comment:

  1. I should mention this is outdated, as I now think that SDL2 is the way to go for creating an OpenGL context on GNU/Linux, and not GLFW3.

    ReplyDelete