PS2GL
OpenGL*-like API for the PS2
Loading...
Searching...
No Matches
renderer.h
1/* Copyright (C) 2000,2001,2002 Sony Computer Entertainment America
2
3 This file is subject to the terms and conditions of the GNU Lesser
4 General Public License Version 2.1. See the file "COPYING" in the
5 main directory of this archive for more details. */
6
7#ifndef renderer_h
8#define renderer_h
9
10#include "ps2s/packet.h"
11
12#include "GL/gl.h"
13
14/********************************************
15 * flags describing what pieces of microcode can do/
16 * need to do
17 */
18
20public:
21 tU64 PrimType : 3;
22 tU64 Lighting : 1;
23 tU64 NumDirLights : 2;
24 tU64 NumPtLights : 3;
25 tU64 Texture : 1;
26 tU64 Specular : 1;
27 tU64 PerVtxMaterial : 3;
28 tU64 Clipping : 2;
29 tU64 CullFace : 1;
30 tU64 TwoSidedLighting : 1;
31 tU64 ArrayAccess : 2;
32
33 tU64 unused : 12;
34
35 tU64 UserProps : 32;
36
37 // convert to unsigned 64-bit value
38
39 inline operator tU64() const
40 {
41 // this hack doesn't work on linux since the compiler thinks this is a 32-bit
42 // machine..
43 // asm (" ### CRendererProps to uint ### " : "=r" (value) : "0" (*this) );
44
45 tU64* value = (tU64*)this;
46 return *value;
47 }
48
49 inline void operator=(tU64 value)
50 {
51 // see above..
52 // asm(" ### CRendererProps assign from u64 ### " : "=r" (*(tU64*)this) : "0" (value) );
53
54 *this = *(CRendererProps*)&value;
55 }
56} __attribute__((aligned(8)));
57
58namespace RendererProps {
59typedef enum { kPtsLinesStripsFans = 1 << 0,
60 kTriangles = 1 << 1,
61 kQuads = 1 << 2 } tPrimType;
62
63typedef enum { k3DirLights = 1 << 0,
64 k8DirLights = 1 << 1 } tNumDirLights;
65
66typedef enum { k1PtLight = 1 << 0,
67 k2PtLights = 1 << 1,
68 k8PtLights = 1 << 2 } tNumPtLights;
69
70typedef enum { kNoMaterial = 1 << 0,
71 kDiffuse = 1 << 1,
72 kSpecular = 1 << 2 } tPerVtxMaterial;
73
74typedef enum { kLinear = 1 << 0,
75 kIndexed = 1 << 1 } tArrayAccess;
76
77typedef enum { kNonClipped = 1 << 0,
78 kClipped = 1 << 1 } tClipping;
79}
80
81class CGeometryBlock;
82class CVertArray;
83
89class CRenderer {
90protected:
91 tU64 Capabilities;
92 tU64 Requirements;
93
94 // this class can't be instantiated
95 CRenderer() {}
96 CRenderer(tU64 caps, tU64 reqs)
97 : Capabilities(caps)
98 , Requirements(reqs)
99 {
100 }
101
102 void SetCapabilities(tU64 caps) { Capabilities = caps; }
103 void SetRequirements(tU64 reqs) { Requirements = reqs; }
104
105public:
106 virtual tU64 GetCapabilities() const { return Capabilities; }
107 virtual tU64 GetRequirements() const { return Requirements; }
108
119 virtual void InitContext(GLenum primType, tU32 rcChanges, bool userRcChanged) = 0;
120
122 virtual void Load() = 0;
123
125 virtual void DrawLinearArrays(CGeometryBlock& block)
126 {
127 mError("This renderer doesn't do linear arrays");
128 }
131 {
132 mError("This renderer doesn't do indexed arrays");
133 }
134
139 virtual bool GetCachePackets(const CGeometryBlock& geometry) = 0;
140
153
156 virtual int GetPacketQwordSize(const CGeometryBlock& geometry) = 0;
157
159 virtual const char* GetName() = 0;
160};
161
162#endif // renderer_h
virtual bool GetCachePackets(const CGeometryBlock &geometry)=0
virtual void InitContext(GLenum primType, tU32 rcChanges, bool userRcChanged)=0
virtual void DrawIndexedArrays(CGeometryBlock &block)
Draw arrays of vertices that are accessed by index (i.e., glDrawElements)
Definition renderer.h:130
virtual void DrawLinearArrays(CGeometryBlock &block)
Draw arrays of vertices that are accessed linearly (i.e., glDrawArrays)
Definition renderer.h:125
virtual void Load()=0
Load the renderer into vu0/vu1 memory.
virtual const char * GetName()=0
Return a pointer to the text name of this renderer.
virtual int GetPacketQwordSize(const CGeometryBlock &geometry)=0
virtual CRendererProps GetRenderContextDeps()=0