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
CzPlatformRender.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(_CCZ_PLATFORM_RENDER_H_)
00015 #define _CCZ_PLATFORM_RENDER_H_
00016 
00017 #include "IwGx.h"
00018 #include "IzPlatformRender.h"
00019 #include "CzRender.h"
00020 
00021 
00022 
00023 class CzPlatformRender : public IzPlatformRender
00024 {
00025     // Properties
00026 protected:
00027     CzTexture               CurrentTexture;
00028     eCzAlphaMode            CurrentAlphaMode;
00029     bool                    CurrentTiled;
00030     bool                    CurrentFilter;
00031     int                     RedundantTextureCalls;
00032     CzRenderPrim**          Primitives;
00033     int                     NextPrimitive;
00034     int                     MaxPrimitives;
00035     CzRenderMaterial**      Materials;
00036     int*                    MaterialUsedCounts;
00037     int                     NextMaterial;
00038     int                     MaxMaterials;
00039     int*                    MaterialIndices;
00040     CzVec2**                BatchVerts;
00041     CzVec2**                BatchUVs;
00042     CzColour**              BatchColours;
00043     uint16**                BatchIndices;
00044 
00045     static bool             ClipRectModified;       // true if clipping rect has been modified
00046     static CzIRect          ScreenClipRect;         // Current transformed screen clipping rect
00047 public:
00048     // Properties end
00049 protected:
00050     static IwGxPrimType     CzToIwGxPrimType[16];
00051 
00052 public:
00053     // Init
00054     int             Init(int max_primitives = 1024, int max_materials = 100);
00055     void            Release();
00056 
00057     // Pre-post render
00058     void            Begin();
00059     void            End();
00060 
00061     // Primitive rendering
00062     void            DrawPrimitives(CzRenderPrim* prims, CzRenderMaterial* materials, int num_prims, bool single_material);
00063     void            DrawPrimitives(CzRenderPrim3* prims, CzRenderMaterial* materials, int num_prims, bool single_material);
00064     void            DrawText(CzFontPreparedText prepared_text, CzFont* font, CzMatrix3* transform, const CzColour& colour, CzVec4& skew, bool filter, eCzAlphaMode alpha_mode);
00065 
00066     // Batch rendering
00067     void            AddPrimtives(CzRenderPrim* prims, CzRenderMaterial* materials, int num_prims, bool single_material);
00068     int             AddMaterial(CzRenderMaterial* material);
00069     void            BatchDrawPrims(bool filter = true);
00070 
00071     // Global clipping
00072     void            SetClipRect(int x, int y, int w, int h);
00073     void            UpdateClipRect(int x, int y, int w, int h);
00074     CzIRect         GetClipRect() const                     { return ScreenClipRect; }
00075     void            ResetClipRect();
00076     bool            isFullyClipped(const CzIRect& rc) const;
00077     void            setClipRectModified(bool modified)      { ClipRectModified = modified; }
00078     bool            wasClipRectModified() const             { return ClipRectModified; }
00079 
00080     // Matrices and projection
00081     void            SetOrthoProjection(float left, float right, float bottom, float top, float nearz, float farz);
00082     void            SetPerspectiveMatrix(CzMatrix4* mat);
00083     void            SetModelMatrix(CzMatrix4* mat);
00084     void            SetViewMatrix(CzMatrix4* mat);
00085 };
00086 
00087 
00088 #endif  // _CCZ_PLATFORM_RENDER_H_