00001 #ifndef MERCURYOGL_H
00002 #define MERCURYOGL_H
00003
00004 #include "MercuryWindow.h"
00005
00006 #if defined (WIN32)
00007 #include "Win32Window.h"
00008 #include <GL/glaux.h>
00009 #endif
00010
00011 #include "MercuryDisplay.h"
00012 #include "MercuryMesh.h"
00013
00014 #include <GL/gl.h>
00015
00016 class MercuryOGLGLSLangObject
00017 {
00018 public:
00019 int id;
00020 int primaryTexture;
00021 };
00022
00023 class MercuryTexture;
00024
00025 class MercuryOGLFBOObject
00026 {
00027 public:
00028 unsigned int colorID;
00029 unsigned int depthID;
00030 };
00031
00032 class MercuryOGLFBOCubeObject
00033 {
00034 public:
00035 unsigned int colorID[6];
00036 unsigned int depthID[6];
00037 };
00038
00039
00040
00042 class MercuryOGL : public MercuryDisplay
00043 {
00044 public:
00045 MercuryOGL();
00046 virtual ~MercuryOGL();
00047 virtual bool MakeWindow(const char* title, int width, int height, int bits, bool fullscreenflag);
00048 virtual bool Init(const MString& name, unsigned int width, unsigned int height, unsigned short bpp, bool fullscreen);
00049 virtual bool BeginFrame();
00050 virtual bool EndFrame();
00051 virtual void DrawParticleField(const MercuryParticleField* field);
00052 virtual void DrawMesh(const MercuryMesh& mesh);
00053 virtual void DrawSprite(const MercuryMesh& sprite);
00054 virtual void GenerateVBO(MercuryMesh& mesh);
00055 virtual void DestroyVBO(MercuryMesh& mesh);
00056
00057 virtual void SetMaterial(const MercuryMaterial* material);
00058 virtual void RendererInfo();
00059
00060 virtual void ClearZBuffer() { glClear(GL_DEPTH_BUFFER_BIT); }
00061 virtual void ClearFrameBuffer() { glClear(GL_COLOR_BUFFER_BIT); }
00062
00063
00064 virtual void DeleteTextures(int n, unsigned int* textureNames);
00065
00066 virtual void UpdateTextureData(MercuryTexture* texture, unsigned int& ID) {};
00067 virtual void CreateCache(RawImageData* data, unsigned int& ID);
00068 virtual void CreateCache(RawImageData* data, unsigned int& ID, bool isMipmap);
00069
00070 virtual void Viewport(int x, int y, int width, int height) { MercuryDisplay::Viewport(x, y, width, height); glViewport(x, y, width, height); }
00071
00072 virtual void EnableTextures(MercuryMaterial* material);
00073 virtual void EnableShaders(MercuryMaterial* material);
00074
00075
00076 virtual void ErrorCheck();
00077
00078 virtual void ReadFrameBuffer(RawImageData& image);
00079
00080 virtual void SendMatrixData(const MercuryMatrix& m);
00081 virtual void SendProjectionMatrixData();
00082
00083 virtual void StencilOp(STENCILOPS fail, STENCILOPS zfail, STENCILOPS zpass);
00084 virtual void CullBackface(bool toggle);
00085 virtual void StencilFunc(TFUNCT func, int ref, unsigned int zref);
00086
00087 virtual int CompileShader(MString vertStr, MString fragStr);
00088 virtual void DestroyShaderProgram(int shaderID);
00089
00090 virtual void DefineClippingPlanes(const MVector<MQuaternion>& planes);
00091
00092 virtual void RenderTranslucentObject();
00093 virtual void RenderText(const MercuryText& text);
00094 virtual MercuryGLState SetStates(MercuryGLState states);
00095
00096 private:
00097 void BindShader(int shaderID);
00098 void ProcessTexture(MercuryTexture* texture);
00099 int ConvertDrawType(DRAWTYPES drawtype);
00100 virtual void ProcessLightsInternal( const MercuryLight* light[3], unsigned int count );
00101 void CompileShader(unsigned int shaderDesc);
00102 int ConvertStencilOp(STENCILOPS op) const;
00103 int ConvertTestFunction(TFUNCT funct) const;
00104 void SetUniformVariables(MercuryMaterial* material);
00105 void TestCapabilities();
00106 void LoadImageData(RawImageData* data, bool isMipmap);
00107
00108
00109 map <int, MercuryOGLGLSLangObject> m_shaderObjMap;
00110
00111 unsigned int m_arrayDrawType;
00112 int m_shaderProgramID;
00113 int m_NumEnabledLights;
00114 GLuint m_pixelFormat;
00115 bool active;
00116
00117 bool isLockRendering;
00118
00119 bool isRenderingToDynamicTexture;
00120 map <int, MercuryOGLFBOObject> m_fboMap;
00121
00122 bool isRenderingToDynamicCubeMap;
00123 map <int, MercuryOGLFBOCubeObject> m_fboCubeMap;
00124
00125 MercuryTexture* m_pCurRenderTex;
00126 };
00127
00128 #endif
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156