"As you know, OpenGL contains rendering commands but is designed to be independent of any window system or operating system. Consequently, it contains no commands for opening windows or reading events from the keyboard or mouse. [OpenGL Programming Guide, 3 Ed., p. 16]
One portable solution to this problem is GLUT (OpenGL Utility Toolkit). Its drawbacks are that its GUI support is minimal and that it uses a C-style interface with callbacks. It is, however, freely available for many platforms, including Windows and Linux. Qt, while not freely available for development under Windows, is superior in many areas. From CS-321, you already know about its robust, modern GUI support and its use of virtual, overridable functions instead of callback function registration. We will use Qt along with OpenGL; our platform will be Linux.
Demonstrate your working program to the professor (25% of grade).
Study the simple program using GLUT from Example 1-2 from the red book [OpenGL Programming Guide, pp. 18-19]. You are not required to compile it, but doing so is a good exercise and will get your computer set up to compile other examples from the text and from class. See Using GLUT.
Read the Qt documentation on QGLWidget.
In order to make the simple program from the book work under Linux/Qt the following components are needed:
main.cpp: This is where the program starts. The QApplication object is created and the main QWidget is created and activated.
shell.{h,cpp}: This serves as the main QWidget for the application. As you develop your application, you will want to create your UI widgets (text entry boxes, sliders, etc.) within this widget. This widget also contains a myGlWidget…
myGlWidget.{h,cpp}: This is derived from QGLWidget and acts as an OpenGL-enabled drawing area. This is where you will do most of your work.
lab2.pro: This contains qmake directives that specify which source files are required for the project, which compiler options to use, which shared libraries to link against, etc.
To get the example working under Qt, do the following…
Override paintGL() so that it performs the operation of display() from the GLUT example program.
Override initializeGL() so that it performs the operation of init() from the GLUT example program.
qmake, make, and test the program.
To demonstrate that you understand the basics of using OpenGL, modify the program so that it has two separate objects in different colors.
Modify your program so that the drawing is maintained at a 1:1 aspect ratio. You will need to override the resizeGL function (same interface as and analogous to the GLUT reshape callback (pp. 35-36)). Try to support both horizontal and vertical letterboxing.
In CS-421, you will use doxygen to automatically generate HTML documentation from your C++ files. If you are familiar with another tool, such as javadoc, that produces the same type of documentation (browsable class and member documentation with appropriate diagrams of inheritance, etc.), you may use it instead. Doxygen works by extracting specially formatted comments from your code files and using them to build documentation in a variety of formats. Doxygen will also coordinate the Graphviz tools to generate various UML and diagrams showing how your classes work; we will be taking advantage of this feature. This approach to documentation ensures that the documentation is maintained with the code but that it can readily be formatted into a variety of useful formats (including HTML, LaTeX, PDF, XML, and manpage).
Explore the doxygen documentation and use features appropriate for documenting your code. If using doxygen well requires violating my normal documentation standard (e.g., I specify that certain items must be at the beginning of a file, but doxygen wants them elsewhere), the doxygen standards take precedence.
Your lab report need not be self-contained. This means that it is not necessary to restate the entire specification in your report.