Fixing the NULL Pointer of the OculusWorldDemo [Oculus Rift SDK 0.4.3, Windows] when running in OpenGL mode

The OculusWorldDemo is little demo application which is shipped with the Oculus Rift SDK and demonstrates some features of the Rift. Recently, I (and some more people) came across a nasty exception while trying out the OculusWorldDemo in OpenGL mode.

When starting the demo, the demo breaks when trying to retrieve the OpenGL version of my system (Line 1901 in Render_GL_Device.cpp):
const char* version = (const char*)glGetString(GL_VERSION);

The function returns NULL and a few lines later an assert checks for the version and throws an exception. For retrieving a valid OpenGL version, one must create a valid OpenGL context before calling the glGetString function. In OculusWorldDemo this happens in Render_GL_Win32_Device.cpp at line 145 (HGLRC context = wglCreateContextAttribsARB(dc, 0, attribs);).
On my system (Windows 7, GeForce GTX 560 Ti), wglCreateContextAttribsARB fails to create a context and returns a NULL pointer. There are more than one reason for getting a NULL pointer here. Long story short, you can replace the function call by calling wglCreateContext instead. The function has only one argument (the handle to the device context) which is why we do not have to add some additional code.
Changing line 145 to HGLRC context = wglCreateContext(dc); does the trick. However, a proper solution would be to call wglCreateContext only if wglCreateContextAttribsARB fails to create a context. ;)

How to map String to TEXT instead of String to VARCHAR(255) (Teneo/Hibernate)

Teneo/Hibernate maps String to VARCHAR(255) per default. If values with sizes of more than 255 characters are expected, this mapping strategy might result in a lot of exceptions. A simple solution  for this is to change the mapping from VARCHAR to TEXT of the EAttribute. Teneo supports such a mapping by looking for a specific annotation value (“@Lob” in “teneo.jpa” annotation).

How-to:
1. Add an EAnnotation to the EAttribute
2. Set source of the EAnnotation to “teneo.jpa”
3. Add a Details Entry to the EAnnotation
4. Set the key of the Details Entry to “value”
5. Set the value of the Details Entry to “@Lob”
6. Regenerate your model
7. Recreate the database (Teneo will not update the table per default)