|
The Qt bitsTo use OpenGL in a Qt application, subclass QGLWidget and add it to your application like any other widget. You should reimplement at least these three virtual functions: initializeGL(), which should set up the OpenGL rendering context, define display lists, set up static lights etc. It gets called once before the first time resizeGL() or paintGL() is called. resizeGL(), which should do the calculations regarding OpenGL viewport and projection. It gets called whenever the widget has been resized, and once when it shown for the first time. paintGL(), which renders the OpenGL scene whenever necessary. Inside your subclassed QGLWidget you can call all OpenGL functions as you normally would. In my example I have placed my QGLWidget inside a QMainWindow, in order to get a normal application window with menus. A warning though: OpenGL applications on some systems using current version of Qt (2.2.3) will cause a segmentation fault on exit.
The concept of 3DWhen working in 3D you must understand the concept of a three-dimensional coordinate system. A 3D coordinate system has 3 directions, the x, y and z directions, which describe the right, up, and forwards directions. The left, down and backwards directions are described by negative x, y and z values. A point in three dimensional space can be described using these three values. The statement ( 2, 4, -1 ) means a point that lies 2 units to the right, 4 units up, and 1 unit towards us. All points are relative to the point (0,0,0). A point in OpenGL is called a vertex, plural vertices. A line that connects two vertices is an edge. My first approach to generating 3D graphics with a computer was the Persistence of Vision Raytracer (POV-Ray). POV-Ray requires at least three types of elements to make up an image: One or more objects to look at, one ore more light sources, and a camera. In OpenGL the objects and light sources are roughly the same, but instead of a camera (located at a point) OpenGL uses a viewport. The viewport is like a square window through which we can look into our 3D world. Comment List
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||