AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
IzPlatformRender.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CIZ_PLATFORM_RENDER_H_)
00015 #define _CIZ_PLATFORM_RENDER_H_
00016 
00017 #include "CzPlatform.h"
00018 
00019 #define PLATFORM_RENDER PLATFORM->getRender()
00020 
00021 class CzImage;
00022 class CzFont;
00023 
00024 enum eCzPrimType
00025 {
00026     PrimType_TriList    = 0, 
00027     PrimType_TriStrip   = 1, 
00028     PrimType_TriFan     = 2, 
00029     PrimType_QuadList   = 3, 
00030     PrimType_QuadStrip  = 4, 
00031     PrimType_Poly       = 5, 
00032     PrimType_LineList   = 6, 
00033     PrimType_LineStrip  = 7, 
00034 };
00035 
00036 enum eCzAlphaMode
00037 {
00038     AlphaMode_None, 
00039     AlphaMode_Half, 
00040     AlphaMode_Add, 
00041     AlphaMode_Sub, 
00042     AlphaMode_Blend, 
00043     AlphaMode_Normal, 
00044 };
00045 
00046 struct CzRenderMaterial
00047 {
00048     CzImage*            Image;          ///< Texture image
00049     bool                Filter;         ///< Texture filtering enable
00050     bool                Tiled;          ///< Texture coordinate tiling / clamping
00051     eCzAlphaMode        AlphaMode;      ///< Alpha blending mode
00052 };
00053 
00054 struct IzRenderPrim
00055 {
00056     eCzPrimType         Type;           ///< Type of primitive
00057     CzVec2*             UVs;            ///< Texture UV coordinmaes
00058     CzColour*           Colours;        ///< Colour vertices
00059     uint16*             Indices;        ///< Face indices
00060     uint16              VertCount;      ///< Vertex count
00061     uint16              FaceCount;      ///< Face count
00062     uint16              IndicesCount;   ///< Indices count
00063     int16               MaterialID;     ///< Material ID
00064     bool                SharedIndices;  ///< Set to true if indices are shared and should not be deleted
00065 
00066     IzRenderPrim() : UVs(NULL), Colours(NULL), Indices(NULL), SharedIndices(false) {}
00067     ~IzRenderPrim()
00068     {
00069         SAFE_DELETE_ARRAY(UVs);
00070         SAFE_DELETE_ARRAY(Colours);
00071         if (!SharedIndices)
00072             SAFE_DELETE(Indices);
00073     }
00074 
00075 };
00076 
00077 struct CzRenderPrim : public IzRenderPrim
00078 {
00079     CzVec2*         Verts;          ///< Screen vertices
00080 
00081     CzRenderPrim() : IzRenderPrim(), Verts(NULL) {}
00082     ~CzRenderPrim()
00083     {
00084         SAFE_DELETE_ARRAY(Verts);
00085     }
00086 
00087 };
00088 
00089 struct CzRenderPrim3 : public IzRenderPrim
00090 {
00091     CzVec3*         Verts;          ///< 3D vertices
00092     CzVec3*         Normals;        ///< 3D normals
00093     bool            ModelSpace;     ///< Set to true if this primitive should be rendered in model space, false if view space
00094 
00095     CzRenderPrim3() : IzRenderPrim(), Verts(NULL), Normals(NULL), ModelSpace(false) {}
00096     ~CzRenderPrim3()
00097     {
00098         SAFE_DELETE_ARRAY(Verts);
00099         SAFE_DELETE_ARRAY(Normals);
00100     }
00101 
00102 };
00103 
00104 //
00105 //
00106 //
00107 //
00108 // IzPlatformRender
00109 //
00110 //
00111 //
00112 //
00113 class IzPlatformRender
00114 {
00115     // Properties
00116 protected:
00117     bool        Initialised;
00118 public:
00119     bool        isInitialised() const   { return Initialised; }
00120     // Properties end
00121 public:
00122     // Init
00123     virtual int     Init(int max_primitives = 1024, int max_materials = 100) = 0;
00124     virtual void    Release() = 0;
00125 
00126     // Pre-post render
00127     virtual void    Begin() = 0;
00128     virtual void    End() = 0;
00129 
00130     // Primitive rendering
00131     virtual void    DrawPrimitives(CzRenderPrim* prims, CzRenderMaterial* materials, int num_prims, bool single_material) = 0;
00132     virtual void    DrawPrimitives(CzRenderPrim3* prims, CzRenderMaterial* materials, int num_prims, bool single_material) = 0;
00133     virtual void    DrawText(CzFontPreparedText prepared_text, CzFont* font, CzMatrix3* transform, const CzColour& colour, CzVec4& skew, bool filter, eCzAlphaMode alpha_mode) = 0;
00134 
00135     // Batch rendering
00136     virtual void    AddPrimtives(CzRenderPrim* prims, CzRenderMaterial* materials, int num_prims, bool single_material) = 0;
00137     virtual int     AddMaterial(CzRenderMaterial* material) = 0;
00138     virtual void    BatchDrawPrims(bool filter = true) = 0;
00139 
00140     // Global clipping
00141     virtual void    SetClipRect(int x, int y, int w, int h) = 0;
00142     virtual void    UpdateClipRect(int x, int y, int w, int h) = 0;
00143     virtual CzIRect GetClipRect() const = 0;
00144     virtual void    ResetClipRect() = 0;
00145     virtual bool    isFullyClipped(const CzIRect& rc) const = 0;
00146     virtual void    setClipRectModified(bool modified) = 0;
00147     virtual bool    wasClipRectModified() const = 0;
00148 
00149     // Matrices and projection
00150     virtual void    SetOrthoProjection(float left, float right, float bottom, float top, float nearz, float farz) = 0;
00151     virtual void    SetPerspectiveMatrix(CzMatrix4* mat) = 0;
00152     virtual void    SetModelMatrix(CzMatrix4* mat) = 0;
00153     virtual void    SetViewMatrix(CzMatrix4* mat) = 0;
00154 };
00155 
00156 
00157 #endif  // _CIZ_PLATFORM_RENDER_H_