/******************************************************************************** Copyright (C) 2012 Hugh Bailey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ********************************************************************************/ #pragma once /*========================================================= Enums ==========================================================*/ //--------------------------------- //drawing types enum GSDrawMode {GS_POINTS, GS_LINES, GS_LINESTRIP, GS_TRIANGLES, GS_TRIANGLESTRIP}; //--------------------------------- //texture formats enum GSColorFormat {GS_UNKNOWNFORMAT, GS_ALPHA, GS_GRAYSCALE, GS_RGB, GS_RGBA, GS_BGR, GS_BGRA, GS_RGBA16F, GS_RGBA32F, GS_B5G5R5A1, GS_B5G6R5, GS_R10G10B10A2, GS_DXT1, GS_DXT3, GS_DXT5}; //--------------------------------- //index size enum GSIndexType {GS_UNSIGNED_SHORT, GS_UNSIGNED_LONG}; //--------------------------------- //blend functions enum GSBlendType {GS_BLEND_ZERO, GS_BLEND_ONE, GS_BLEND_SRCCOLOR, GS_BLEND_INVSRCCOLOR, GS_BLEND_SRCALPHA, GS_BLEND_INVSRCALPHA, GS_BLEND_DSTCOLOR, GS_BLEND_INVDSTCOLOR, GS_BLEND_DSTALPHA, GS_BLEND_INVDSTALPHA, GS_BLEND_FACTOR, GS_BLEND_INVFACTOR}; //--------------------------------- //sampling filters enum GSSampleFilter { GS_FILTER_LINEAR, GS_FILTER_POINT, GS_FILTER_ANISOTROPIC, GS_FILTER_MIN_MAG_POINT_MIP_LINEAR, GS_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT, GS_FILTER_MIN_POINT_MAG_MIP_LINEAR, GS_FILTER_MIN_LINEAR_MAG_MIP_POINT, GS_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR, GS_FILTER_MIN_MAG_LINEAR_MIP_POINT, GS_FILTER_MIN_MAG_MIP_POINT=GS_FILTER_POINT, GS_FILTER_MIN_MAG_MIP_LINEAR=GS_FILTER_LINEAR }; //--------------------------------- //sampling address mode enum GSAddressMode { GS_ADDRESS_CLAMP, GS_ADDRESS_WRAP, GS_ADDRESS_MIRROR, GS_ADDRESS_BORDER, GS_ADDRESS_MIRRORONCE, GS_ADDRESS_NONE=GS_ADDRESS_CLAMP, GS_ADDRESS_REPEAT=GS_ADDRESS_WRAP }; /*========================================================= Vertex Buffer Data struct ==========================================================*/ class UVCoordList : public List {}; struct VBData { List VertList; List NormalList; List ColorList; List TangentList; List UVList; inline VBData() {} inline ~VBData() {Clear();} inline void Clear() { VertList.Clear(); NormalList.Clear(); ColorList.Clear(); TangentList.Clear(); for(DWORD i=0;i MatrixStack; int curMatrix; virtual void ResetViewMatrix()=0; public: virtual void CopyTexture(Texture *texDest, Texture *texSrc)=0; }; //----------------------------------------- //main extern BASE_EXPORT extern GraphicsSystem *GS; //----------------------------------------- //C inline refs inline void MatrixPush() {GS->MatrixPush();} inline void MatrixPop() {GS->MatrixPop();} inline void MatrixSet(const Matrix &m) {GS->MatrixSet(m);} inline void MatrixGet(Matrix &m) {GS->MatrixGet(m);} inline void MatrixMultiply(const Matrix &m) {GS->MatrixMultiply(m);} inline void MatrixRotate(float x, float y, float z, float a) {GS->MatrixRotate(x, y, z, a);} //axis angle inline void MatrixRotate(const AxisAngle &aa) {GS->MatrixRotate(aa);} inline void MatrixRotate(const Quat &q) {GS->MatrixRotate(q);} inline void MatrixTranslate(float x, float y) {GS->MatrixTranslate(x, y);} inline void MatrixTranslate(const Vect2 &pos) {GS->MatrixTranslate(pos);} inline void MatrixScale(const Vect2 &scale) {GS->MatrixScale(scale);} inline void MatrixScale(float x, float y) {GS->MatrixScale(x, y);} inline void MatrixTranspose() {GS->MatrixTranspose();} inline void MatrixIdentity() {GS->MatrixIdentity();} inline Texture* CreateTexture(unsigned int width, unsigned int height, GSColorFormat colorFormat, void *lpData=NULL, BOOL bGenMipMaps=1, BOOL bStatic=1) {return GS->CreateTexture(width, height, colorFormat, lpData, bGenMipMaps, bStatic);} inline Texture* CreateTextureFromFile(CTSTR lpFile, BOOL bBuildMipMaps) {return GS->CreateTextureFromFile(lpFile, bBuildMipMaps);} inline Texture* CreateRenderTarget(unsigned int width, unsigned int height, GSColorFormat colorFormat, BOOL bGenMipMaps) {return GS->CreateRenderTarget(width, height, colorFormat, bGenMipMaps);} inline Texture* CreateGDITexture(unsigned int width, unsigned int height) {return GS->CreateGDITexture(width, height);} inline SamplerState* CreateSamplerState(SamplerInfo &info) {return GS->CreateSamplerState(info);} inline Shader* CreateVertexShader(CTSTR lpShader, CTSTR lpFileName) {return GS->CreateVertexShader(lpShader, lpFileName);} inline Shader* CreatePixelShader(CTSTR lpShader, CTSTR lpFileName) {return GS->CreatePixelShader(lpShader, lpFileName);} inline Shader* CreateVertexShaderFromFile(CTSTR lpFileName) {return GS->CreateVertexShaderFromFile(lpFileName);} inline Shader* CreatePixelShaderFromFile(CTSTR lpFileName) {return GS->CreatePixelShaderFromFile(lpFileName);} inline VertexBuffer* CreateVertexBuffer(VBData *vbData, BOOL bStatic=1) {return GS->CreateVertexBuffer(vbData, bStatic);} inline void LoadVertexBuffer(VertexBuffer* vb) {GS->LoadVertexBuffer(vb);} inline void LoadTexture(Texture *texture, UINT idTexture=0) {GS->LoadTexture(texture, idTexture);} inline void LoadSamplerState(SamplerState *sampler, UINT idSampler=0) {GS->LoadSamplerState(sampler, idSampler);} inline void LoadVertexShader(Shader *vShader) {GS->LoadVertexShader(vShader);} inline void LoadPixelShader(Shader *pShader) {GS->LoadPixelShader(pShader);} inline Shader* GetCurrentPixelShader() {return GS->GetCurrentPixelShader();} inline Shader* GetCurrentVertexShader() {return GS->GetCurrentVertexShader();} inline void SetRenderTarget(Texture *texture) {GS->SetRenderTarget(texture);} inline void Draw(GSDrawMode drawMode, DWORD StartVert=0, DWORD nVerts=0) {GS->Draw(drawMode, StartVert, nVerts);} inline void EnableBlending(BOOL bEnabled) {GS->EnableBlending(bEnabled);} inline void BlendFunction(GSBlendType srcFactor, GSBlendType destFactor, float fFactor=1.0f) {GS->BlendFunction(srcFactor, destFactor, fFactor);} inline void ClearColorBuffer(DWORD color=0xFF000000) {GS->ClearColorBuffer(color);} inline void StartVertexBuffer() {GS->StartVertexBuffer();} inline VertexBuffer* SaveVertexBuffer() {return GS->SaveVertexBuffer();} inline void Vertex(float x, float y, float z=0) {GS->Vertex(x, y, z);} inline void Vertex(const Vect &v) {GS->Vertex(v);} inline void Vertex(const Vect2 &v2) {GS->Vertex(v2);} inline void Normal(float x, float y, float z) {GS->Normal(x, y, z);} inline void Normal(const Vect &v) {GS->Normal(v);} inline void Color(DWORD dwRGBA) {GS->Color(dwRGBA);} inline void Color(const Color4 &v) {GS->Color(v);} inline void Color(float R, float G, float B, float A) {Color4 rgba(R,G,B,A); GS->Color(rgba);} inline void TexCoord(float u, float v, int idTexture=0) {GS->TexCoord(u, v, idTexture);} inline void TexCoord(const UVCoord &uv, int idTexture=0) {GS->TexCoord(uv, idTexture);} inline void Ortho(float left, float right, float top, float bottom, float znear, float zfar) {GS->Ortho(left, right, top, bottom, znear, zfar);} inline void Frustum(float left, float right, float top, float bottom, float znear, float zfar) {GS->Frustum(left, right, top, bottom, znear, zfar);} inline void SetViewport(float x, float y, float width, float height) {GS->SetViewport(x, y, width, height);} inline void SetScissorRect(XRect *pRect=NULL) {GS->SetScissorRect(pRect);} inline void DrawSprite(Texture *texture, DWORD color, float x, float y, float x2 = -998.0f, float y2 = -998.0f) {GS->DrawSprite(texture, color, x, y, x2, y2);} inline void DrawSpriteEx(Texture *texture, DWORD color, float x, float y, float x2 = -998.0f, float y2 = -998.0f, float u = -998.0f, float v = -998.0f, float u2 = -998.0f, float v2 = -998.0f) {GS->DrawSpriteEx(texture, color, x, y, x2, y2, u, v, u2, v2);} inline void DrawBox(const Vect2 &upperLeft, const Vect2 &size) {GS->DrawBox(upperLeft, size);}