Last week I have ported two chapters (the first 10 lessons) of the NeHe OpenGL lessons to make use of the Qt toolkit. You will notice that the code in Qt is much cleaner and simpler than the code in the original NeHe lessons. There is no need to create a rendering or device context yourself or anything like that, and input support like input from keyboard or mouse can simply be implemented by reimplementing one function. As an added bonus, your 3D applications will run on pretty much any platform.
First chapter: setting up an OpenGL window, polygons, colors, rotation, 3D shapes
After completing the first chapter, you will end up with a rotating pyramid and cube…
This video shows the end result (lesson 5).
You can download the Qt 4 source code for this chapter here.
Second chapter: texture mapping, texture filters, lighting, keyboard control, blending, moving bitmaps in 3D space, loading and moving through a 3D world
In the second chapter you will learn a lot about textures, among some other things. Sometimes we make use of QGLContext::bindTexture() to load an image, morph it into a texture and bind it to OpenGL all in one go. Other times we will do it manually because we want to specify the texture filter ourselves (but we do have QGLWidget::convertToGLFormat() which makes that easy as well). To handle keypresses we simply reimplement keyPressEvent(). To load in the 3D world from the file we make use of the excellent QFile and QTextStream classes. As an added bonus, we also make use of QGLWidget::renderText() to show the user what has changed when a key is pressed inside the OpenGL window. Lesson 9 also features a bonus fade-in effect for the revived stars. This makes the effect look much cooler.
This video shows the result of adding texture filters, lighting and keyboard control (lesson 7)
This video shows the result of all the above plus blending (lesson 8)
This video shows the result of moving bitmaps in 3D space (lesson 9)
This video shows the result of moving through a very simple 3D world (lesson 10)
You can download the Qt 4 source code for this chapter here.
The third and fourth chapter are almost complete as well, but I will give you the Qt ports of those chapters another time. Perhaps tomorrow.