3D DevIL in a 2D QT World.

I will now attempt to create my first Qt Application: :)

We will use the "QApplication" object as our starting point, which is only used once regardless of how many windows or widgets are used, It must be called before any other objects related to the GUI, if we wish to instead make a console application we would instead use the "QCoreApplication" object.

Design Goals: Create a simple windowed application that has a basic GUI, and allows images to be loaded from DevIL or FreeImage libraries into a 3D OGL window for display.

I first use QMainApplication to subclass my own "MainWindow" this window is the parent window which handles memory handling and all associated window parameters. I then add a MenuBar which has "File" with a SubMenu "Open" this opens a FileDialog QString and parses the selected filename.

I then add an OpenGL window as our central widget, by making our own "GLMain" sub-class which will handle all GL drawing and functionality. We then include and integrate our DevIL function calls and draw a rectangle in GL, and bind the selected image from DevIL to OpenGL, and project the result and draw it in the OGL window. Below is the first compiled complete example. Yippee!


The image above shows a 32bit high dynamic range image i made quickly via Adobe Photoshop CS4, which was saved as "test.exr" and then "hardcoded" into the application, loaded and displayed in our Qt OGL window as native 64bit.exe.. Yippeee We have achieved our primary design goals. This completes my first Qt test application with DevIL and OGL support. I wll now try and use the existing framework to expand on a few ideas, I will outline in a later post.

To solve the hardcoding, I need to pass Qstring's "fileName" to ilLoadImage... As QString returned from QFileDialog is a 16bit unicode string, and DevIL's ilLoadImage takes a const char * or const wchar_t *

I found in the Qt GUI book, that "QPrintable" macro works.. So i was able to simply use "ilLoadImage(qPrintable(fileName));" which converts the filename to a QPrintable char*. So this will seemingly coming in handy, but a note to study strings and unicode and recasting a little more in depth at a later stage. Now we have a fairly useable, albeit simple cross platform capable image viewer. I still wish to take the current code and improve it's performance, and understand it completely!

Comments

Popular posts from this blog

Qt and the Beast...

Microsoft and the DevIL