00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GZ_RENDER_BASE_H__
00023 #define __GZ_RENDER_BASE_H__
00024
00030 #include "gzContext.h"
00031 #include "gzCamera.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 class gzRenderBase : public gzObject
00048 {
00049 public:
00050
00051 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_GRAPH_EXPORT);
00052
00053 GZ_GRAPH_EXPORT gzRenderBase();
00054
00055 GZ_GRAPH_EXPORT virtual ~gzRenderBase();
00056
00057 GZ_GRAPH_EXPORT virtual gzVoid onPreRender(gzContext *context, gzULong size_x , gzULong size_y);
00058 GZ_GRAPH_EXPORT virtual gzVoid onPostRender(gzContext *context, gzULong size_x , gzULong size_y);
00059 GZ_GRAPH_EXPORT virtual gzVoid onInitContext(gzContext *context);
00060
00061 GZ_GRAPH_EXPORT gzVoid setBackground( gzFloat red , gzFloat green , gzFloat blue , gzFloat alpha=1.0f );
00062 GZ_GRAPH_EXPORT gzVec4 getBackground();
00063
00064 GZ_GRAPH_EXPORT gzVoid setClearDepth( gzFloat depth );
00065
00066 GZ_GRAPH_EXPORT gzVoid setDepthFunc( gzEnum func );
00067
00068 GZ_GRAPH_EXPORT gzVoid setContext( gzContext *context );
00069 GZ_GRAPH_EXPORT gzContext *getContext() const;
00070
00071 GZ_GRAPH_EXPORT gzVoid setCamera( gzCamera *camera );
00072 GZ_GRAPH_EXPORT gzCamera *getCamera() const;
00073
00074 GZ_GRAPH_EXPORT virtual gzVoid render(gzContext *context, gzULong size_x,gzULong size_y,gzULong max_width);
00075
00076 GZ_GRAPH_EXPORT gzDouble getFrameRate();
00077
00078 GZ_GRAPH_EXPORT gzVoid setForcedRenderTime(const gzDouble &renderTime);
00079
00081 GZ_GRAPH_EXPORT gzVoid setViewportOffset(gzFloat x , gzFloat y);
00082
00084 GZ_GRAPH_EXPORT gzVoid setViewportScale(gzFloat sx , gzFloat sy);
00085
00086 GZ_GRAPH_EXPORT gzVoid useFinish(gzBool active=FALSE);
00087
00088 protected:
00089
00090 gzDouble m_lastFrameTime;
00091 gzULong m_frameCount;
00092 gzDouble m_frameRate;
00093
00094 gzFloat m_backColor_red;
00095 gzFloat m_backColor_green;
00096 gzFloat m_backColor_blue;
00097 gzFloat m_backColor_alpha;
00098 gzFloat m_clearDepth;
00099
00100 gzFloat m_refreshRate;
00101
00102 gzEnum m_depthFunc;
00103
00104 gzFloatXY m_viewportOffset;
00105
00106 gzFloatXY m_viewportScale;
00107
00108 gzRefPointer<gzContext> m_context;
00109
00110
00111
00112 gzRefPointer<gzCamera> m_camera;
00113
00114 private:
00115
00116 gzBool m_hasInitContext;
00117
00118 gzBool m_useFinish;
00119
00120 gzDouble m_forceRenderTime;
00121
00122 };
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 class gzImageRenderInterface : public gzRenderBase
00140 {
00141 public:
00142
00143 GZ_GRAPH_EXPORT gzImageRenderInterface(){};
00144
00145 GZ_GRAPH_EXPORT ~gzImageRenderInterface(){};
00146
00147
00148
00149 GZ_GRAPH_EXPORT virtual gzVoid refreshImage()=0;
00150
00151 GZ_GRAPH_EXPORT virtual gzVoid setImage(gzImage *image)=0;
00152
00153 GZ_GRAPH_EXPORT virtual gzImage *getImage()=0;
00154
00155
00156 GZ_GRAPH_EXPORT virtual gzReference* clone() const=0;
00157
00158
00159
00160 GZ_GRAPH_EXPORT static gzVoid installFactory(gzImageRenderInterface *instance);
00161
00162 GZ_GRAPH_EXPORT static gzVoid unInstallFactory();
00163
00164 GZ_GRAPH_EXPORT static gzBool hasFactory();
00165
00166 GZ_GRAPH_EXPORT static gzImageRenderInterface * getImageRender();
00167
00168 private:
00169
00170 static gzRefPointer<gzImageRenderInterface> s_factoryInstance;
00171
00172 };
00173
00174
00175 #endif // __GZ_RENDER_BASE_H__