00001 #ifndef GRRENDER_H
00002 #define GRRENDER_H
00003 #include <SceneGraph/SGEngine.h>
00004 #include <WinBasis/WBCriticalSection.h>
00005
00006 namespace Spr{;
00007
00008 class GRCamera;
00009 class SGFrame;
00010 struct GRMaterialData;
00011 struct GRLightData;
00012
00013 class SPR_DLL GRFont{
00014 public:
00015 int height;
00016 int width;
00017 int weight;
00018 FIString face;
00019 DWORD color;
00020 bool bItalic;
00021 GRFont(int h=20, const char* f=NULL);
00022 void SetColor(DWORD c){ color = c; }
00023 bool operator < (GRFont& f);
00024 };
00025
00026
00027 class SPR_DLL GRRender:public SGEngine{
00028 public:
00029 SGOBJECTDEFABST(GRRender);
00030 WBCriticalSection cr;
00031 bool bDrawDebug;
00032 UTRef<GRCamera> camera;
00033 SGScene* scene;
00034 UTStack<SGFrame*> frames;
00035
00036 enum TDrawState{
00037 DRAW_OPAQUE=1,
00038 DRAW_TRANSPARENT=2,
00039 DRAW_BOTH=3,
00040 } drawState;
00041 GRRender();
00042 virtual ~GRRender();
00043
00044 virtual bool Create(void* arg){return false;}
00045
00046 virtual void InitTree(SGFrame* fr, SGScene* scene);
00047
00048 virtual bool SetViewport(void* arg){return false;}
00049
00050 virtual void Clear(SGScene* s);
00051
00052 virtual bool IsFullscreen(){return false;}
00053
00054 virtual void Fullscreen(){}
00055
00056 virtual void Window(){}
00057
00058
00059
00060 virtual void ClearBuffer(){}
00061 virtual void ClearColor(float r, float g, float b, float alpha){}
00062
00063
00064 virtual void BeginScene(){}
00065
00066 virtual void Render(SGScene* s);
00067
00068 virtual void RenderRecurse();
00069
00070 virtual void EndScene(){}
00071
00072 virtual void Present(){}
00073
00074
00075
00076
00077 enum TPrimitiveType {
00078 POINTS,
00079 LINES,
00080 LINESTRIP,
00081 TRIANGLES,
00082 TRIANGLESTRIP,
00083 TRIANGLEFAN
00084 };
00085 virtual void MultModelMatrix(const Affinef& afw){}
00086 virtual void PushModelMatrix(){}
00087 virtual void PopModelMatrix(){}
00088 virtual void SetModelMatrix(const Affinef& afw){}
00089 virtual void SetViewMatrix(const Affinef& afv){}
00090 virtual void SetProjectionMatrix(const Affinef& afp){}
00091 virtual void DrawDirect(TPrimitiveType ty, Vec3f* begin, Vec3f* end){}
00092 virtual void DrawIndexed(TPrimitiveType ty, size_t* begin, size_t* end, Vec3f* vtx){}
00093 virtual void DrawText(Vec2f pos, FIString str, const GRFont& font){}
00094 virtual Vec2f GetTextExtent(FIString str, const GRFont& font){ return Vec2f(); }
00095 virtual void SetMaterial(const GRMaterialData& m){}
00096 virtual void SetTexture(const char* fn){}
00097 virtual void PushLight(const GRLightData& m){}
00098 virtual void PopLight(){}
00099 virtual void SetLineWidth(float w){}
00100 virtual void SetDepthTest(bool b){}
00101 virtual void SetDepthWrite(bool b){}
00102 enum TDepthFunc{
00103 DF_NEVER, DF_LESS, DF_EQUAL, DF_LEQUAL, DF_GREATER, DF_NOTEQUAL,
00104 DF_GEQUAL, DF_ALWAYS
00105 };
00106 virtual void SetDepthFunc(TDepthFunc f){}
00107 enum TBlendFunc{
00108 BF_ZERO = 1,
00109 BF_ONE = 2,
00110 BF_SRCCOLOR = 3,
00111 BF_INVSRCCOLOR = 4,
00112 BF_SRCALPHA = 5,
00113 BF_INVSRCALPHA = 6,
00114 BF_DESTALPHA = 7,
00115 BF_INVDESTALPHA = 8,
00116 BF_DESTCOLOR = 9,
00117 BF_INVDESTCOLOR = 10,
00118 BF_SRCALPHASAT = 11,
00119 BF_BOTHSRCALPHA = 12,
00120 BF_BOTHINVSRCALPHA = 13,
00121 BF_BLENDFACTOR = 14,
00122 BF_INVBLENDFACTOR = 15
00123 };
00124 virtual void SetAlphaMode(TBlendFunc src, TBlendFunc dest){}
00125 virtual bool CanDraw(){return true;}
00126
00127
00128 virtual void Set(SGObject* obj);
00129
00130
00131 virtual Vec3f getPointUnderPixel(int x, int y, bool& found, SGScene* scene){
00132 found=false; Vec3f res; return res;}
00133
00134
00135 };
00136
00137 }
00138 #endif