Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

renderer.h

Go to the documentation of this file.
00001 /*        Copyright (C) 2000,2001,2002  Sony Computer Entertainment America
00002           
00003           This file is subject to the terms and conditions of the GNU Lesser
00004           General Public License Version 2.1. See the file "COPYING" in the
00005           main directory of this archive for more details.                             */
00006 
00007 #ifndef renderer_h
00008 #define renderer_h
00009 
00010 #include "ps2s/packet.h"
00011 
00012 #include "GL/gl.h"
00013 
00014 /********************************************
00015  * flags describing what pieces of microcode can do/
00016  * need to do
00017  */
00018 
00019 class CRendererProps {
00020    public:
00021       tU64 PrimType             : 3;
00022       tU64 Lighting             : 1;
00023       tU64 NumDirLights         : 2;
00024       tU64 NumPtLights          : 3;
00025       tU64 Texture              : 1;
00026       tU64 Specular             : 1;
00027       tU64 PerVtxMaterial       : 3;
00028       tU64 Clipping             : 2;
00029       tU64 CullFace             : 1;
00030       tU64 TwoSidedLighting     : 1;
00031       tU64 ArrayAccess          : 2;
00032 
00033       tU64 unused               : 12;
00034 
00035       tU64 UserProps            : 32;
00036 
00037       // convert to unsigned 64-bit value
00038 
00039       inline operator tU64() const {
00040          // this hack doesn't work on linux since the compiler thinks this is a 32-bit
00041          // machine..
00042          // asm (" ### CRendererProps to uint ### " : "=r" (value) : "0" (*this) );
00043 
00044          tU64 *value = (tU64*)this;
00045          return *value;
00046       }
00047 
00048       inline void operator = ( tU64 value ) {
00049          // see above..
00050          // asm(" ### CRendererProps assign from u64 ### " : "=r" (*(tU64*)this) : "0" (value) );
00051 
00052          *this = *(CRendererProps*)&value;
00053       }
00054 } __attribute__ (( aligned(8) ));
00055 
00056 namespace RendererProps {
00057    typedef enum { kPtsLinesStripsFans   = 1 << 0,
00058                   kTriangles            = 1 << 1,
00059                   kQuads                = 1 << 2 } tPrimType;
00060 
00061    typedef enum { k3DirLights           = 1 << 0,
00062                   k8DirLights           = 1 << 1 } tNumDirLights;
00063 
00064    typedef enum { k1PtLight             = 1 << 0,
00065                   k2PtLights            = 1 << 1,
00066                   k8PtLights            = 1 << 2 } tNumPtLights;
00067 
00068    typedef enum { kNoMaterial           = 1 << 0,
00069                   kDiffuse              = 1 << 1,
00070                   kSpecular             = 1 << 2 } tPerVtxMaterial;
00071 
00072    typedef enum { kLinear               = 1 << 0,
00073                   kIndexed              = 1 << 1 } tArrayAccess;
00074 
00075    typedef enum { kNonClipped           = 1 << 0,
00076                   kClipped              = 1 << 1 } tClipping;
00077 }      
00078 
00079 class CGeometryBlock;
00080 class CVertArray;
00081 
00087 class CRenderer {
00088    protected:
00089       tU64      Capabilities;
00090       tU64      Requirements;
00091 
00092       // this class can't be instantiated
00093       CRenderer() { }
00094       CRenderer( tU64 caps, tU64 reqs ) : Capabilities(caps), Requirements(reqs) {}
00095 
00096       void SetCapabilities( tU64 caps ) { Capabilities = caps; }
00097       void SetRequirements( tU64 reqs ) { Requirements = reqs; }
00098 
00099    public:
00100       virtual tU64 GetCapabilities() const { return Capabilities; }
00101       virtual tU64 GetRequirements() const { return Requirements; }
00102 
00113       virtual void InitContext( GLenum primType, tU32 rcChanges, bool userRcChanged ) = 0;
00114 
00116       virtual void Load() = 0;
00117 
00119       virtual void DrawLinearArrays( CGeometryBlock &block )
00120       { mError( "This renderer doesn't do linear arrays" ); }
00122       virtual void DrawIndexedArrays( CGeometryBlock &block )
00123       { mError( "This renderer doesn't do indexed arrays" ); }
00124 
00129       virtual bool GetCachePackets( const CGeometryBlock &geometry ) = 0;
00130 
00142       virtual CRendererProps GetRenderContextDeps() = 0;
00143 
00146       virtual int GetPacketQwordSize( const CGeometryBlock &geometry ) = 0;
00147 
00149       virtual const char* GetName() = 0;
00150 };
00151 
00152 #endif // renderer_h

ps2gl version cvs