00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef OPENGLFRAMEH
00027 #define OPENGLFRAMEH
00028
00029
00030 #include <GOpenGLForm.h>
00031
00032
00033 #include <GVector3.h>
00034 #include <GElementID.h>
00035 #include <GElement.h>
00036
00037 #include <GWEInterface.h>
00038
00039
00040 #include <qgl.h>
00041 #include <qmutex.h>
00042 #include <qthread.h>
00043 #include <qvaluelist.h>
00044
00045
00046 using namespace GCS;
00047
00048
00049 using namespace GBE;
00050
00051
00052 using namespace GWE;
00053
00054
00055 namespace GCE
00056 {
00057
00064 class CViewProperties
00065 {
00066 public:
00067
00068 CViewProperties()
00069 : ViewPosition(0,0,-1),
00070 ViewTarget(0,0,0),
00071 ViewUp(0,1,0),
00072 fov(90),
00073 NearClippingPlane(0.01),
00074 FarClippingPlane(10),
00075 width(768),
00076 height(1024),
00077 CameraElement(0)
00078 {
00079 }
00080
00081 GVector3 ViewPosition;
00082 GVector3 ViewTarget;
00083 GVector3 ViewUp;
00084 double fov;
00085 double NearClippingPlane;
00086 double FarClippingPlane;
00087
00088 int width, height;
00089
00097 GElementID CameraElement;
00098
00099 void update()
00100 {
00101 glViewport(0,0,width,height);
00102 glMatrixMode(GL_PROJECTION);
00103 glLoadIdentity();
00104 gluPerspective(fov,(double)width/(double)height,NearClippingPlane,FarClippingPlane);
00105 glMatrixMode(GL_MODELVIEW);
00106 glLoadIdentity();
00107 }
00108 };
00109
00120 class OpenGLFrame : public QGLWidget, protected QThread, public QMutex
00121 {
00122 Q_OBJECT
00123 private:
00124
00125 const GWEInterface* Gwe;
00126
00127 QValueList<GElementID> TopElements;
00128
00129 void renderChildren(const GElement* element);
00130
00131 protected:
00132
00133 bool stop_rendering;
00134
00135 int sleep_time_ms;
00136
00137 virtual void run();
00138
00139
00140 public:
00141
00142 CViewProperties ViewProperties;
00143
00144 OpenGLFrame(const GWEInterface* gwe, QWidget* parent = 0, const char* name = 0);
00145
00146 ~OpenGLFrame()
00147 {}
00148
00149 public slots:
00150
00156 virtual void startRendering(int sleep_ms_between_updates_min = 20);
00157
00158 virtual void stopRendering();
00159
00160 virtual void initializeGL();
00161
00162 virtual void resizeGL(int w, int h);
00163
00164 virtual void paintGL();
00165
00166 virtual void addTopElement(const GElementID& element);
00167
00168 virtual void removeTopElement(const GElementID& element);
00169
00170 };
00171
00172 }
00173
00174 #endif