00001
00002
00003
00004
00005 #ifndef ps2gl_gmanager_h
00006 #define ps2gl_gmanager_h
00007
00008 #include "GL/gl.h"
00009 #include "ps2s/gs.h"
00010 #include "ps2s/cpu_vector.h"
00011 #include "ps2s/cpu_matrix.h"
00012 #include "ps2s/packet.h"
00013
00014 #include "ps2gl/vsmmanager.h"
00015 #include "ps2gl/gblock.h"
00016
00017
00018
00019
00020
00021 class CVertArray {
00022 void *Vertices, *Normals, *TexCoords, *Colors;
00023 bool VerticesAreValid, NormalsAreValid, TexCoordsAreValid, ColorsAreValid;
00024 char WordsPerVertex, WordsPerNormal, WordsPerTexCoord, WordsPerColor;
00025
00026 public:
00027 CVertArray();
00028
00029 inline bool GetVerticesAreValid() const { return VerticesAreValid; }
00030 inline bool GetNormalsAreValid() const { return NormalsAreValid; }
00031 inline bool GetTexCoordsAreValid() const { return TexCoordsAreValid; }
00032 inline bool GetColorsAreValid() const { return ColorsAreValid; }
00033
00034 inline void SetVerticesValid( bool valid ) { VerticesAreValid = valid; }
00035 inline void SetNormalsValid( bool valid ) { NormalsAreValid = valid; }
00036 inline void SetTexCoordsValid( bool valid ) { TexCoordsAreValid = valid; }
00037 inline void SetColorsValid( bool valid ) { ColorsAreValid = valid; }
00038
00039
00040 inline void* GetVertices() const { return Vertices; }
00041 inline void* GetNormals() const { return Normals; }
00042 inline void* GetTexCoords() const { return TexCoords; }
00043 inline void* GetColors() const { return Colors; }
00044
00045 inline void SetVertices( void *newPtr ) { Vertices = newPtr; }
00046 inline void SetNormals( void *newPtr ) { Normals = newPtr; }
00047 inline void SetTexCoords( void *newPtr ) { TexCoords = newPtr; }
00048 inline void SetColors( void *newPtr ) { Colors = newPtr; }
00049
00050
00051 inline int GetWordsPerVertex() const { return WordsPerVertex; }
00052 inline int GetWordsPerNormal() const { return WordsPerNormal; }
00053 inline int GetWordsPerTexCoord() const { return WordsPerTexCoord; }
00054 inline int GetWordsPerColor() const { return WordsPerColor; }
00055
00056 inline void SetWordsPerVertex( int numWords ) { WordsPerVertex = numWords; }
00057 inline void SetWordsPerNormal( int numWords ) { WordsPerNormal = numWords; }
00058 inline void SetWordsPerTexCoord( int numWords ) { WordsPerTexCoord = numWords; }
00059 inline void SetWordsPerColor( int numWords ) { WordsPerColor = numWords; }
00060 };
00061
00062
00063
00064
00065
00066 class CVifSCDmaPacket;
00067 class CGLContext;
00068 class CDList;
00069
00070 class CGeomManager {
00071 protected:
00072 CGLContext &GLContext;
00073
00074
00075 static CVertArray *VertArray;
00076
00077
00078 cpu_vec_xyz CurNormal;
00079 float CurTexCoord[2];
00080 static bool DoNormalize;
00081
00082 GLenum Vu1Prim;
00083
00084 bool InsideBeginEnd;
00085
00086 public:
00087 CGeomManager( CGLContext &context );
00088
00089
00090
00091 inline cpu_vec_xyz GetCurNormal() const { return CurNormal; }
00092 inline void SetCurNormal( cpu_vec_xyz normal ) { CurNormal = normal; }
00093
00094 inline const float* GetCurTexCoord() const { return CurTexCoord; }
00095 inline void SetCurTexCoord( float u, float v ) {
00096 CurTexCoord[0] = u; CurTexCoord[1] = v;
00097 }
00098
00099
00100 void SetDoNormalize( bool normalize ) { DoNormalize = normalize; }
00101
00102 inline CVertArray& GetVertArray() { return *VertArray; }
00103
00104
00105
00106 virtual void BeginGeom( GLenum mode ) = 0;
00107 virtual void Vertex( cpu_vec_xyzw newVert ) = 0;
00108 virtual void Normal( cpu_vec_xyz normal ) = 0;
00109 virtual void TexCoord( float u, float v ) = 0;
00110 virtual void Color( cpu_vec_xyzw color ) = 0;
00111 virtual void EndGeom() = 0;
00112 virtual void DrawArrays( GLenum mode, int first, int count ) = 0;
00113 virtual void Flush() = 0;
00114 };
00115
00116 #endif // ps2gl_gmanager_h