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

immgmanager.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 ps2gl_immgmanager_h
00008 #define ps2gl_immgmanager_h
00009 
00010 #include "ps2gl/gmanager.h"
00011 
00012 /********************************************
00013  * CImmGeomManager - the immediate renderer
00014  */
00015 
00016 class CImmGeomManager : public CGeomManager {
00017 
00018       CRendererManager  RendererManager;
00019 
00020       // a double set of buffers for storing immediate-mode vertices, normals, etc.
00021       // these don't really need to be dma packets since they will be reffed by
00022       // the microcode
00023       CDmaPacket        VertexBuf0, NormalBuf0, TexCoordBuf0, ColorBuf0;
00024       CDmaPacket        VertexBuf1, NormalBuf1, TexCoordBuf1, ColorBuf1;
00025       CDmaPacket        *CurVertexBuf, *CurNormalBuf, *CurTexCoordBuf, *CurColorBuf;
00026 
00027       CGeometryBlock    Geometry;
00028 
00029       void CommitNewGeom();
00030 
00031    public:
00032       CImmGeomManager( CGLContext &context, int immBufferQwordSize );
00033       virtual ~CImmGeomManager();
00034 
00035       CRendererManager& GetRendererManager() { return RendererManager; }
00036 
00037       void SwapBuffers();
00038 
00039       // state changes / updates
00040 
00041       void PrimChanged( GLenum primType );
00042       void SyncRendererContext( GLenum primType );
00043       void SyncRenderer();
00044       void SyncGsContext();
00045       void SyncColorMaterial( bool pvColorsArePresent );
00046 
00047       void DrawingLinearArray();
00048       void DrawingIndexedArray();
00049 
00050       void SyncArrayType( ArrayType::tArrayType type ) {
00051          if (type == ArrayType::kLinear) DrawingLinearArray();
00052          else DrawingIndexedArray();
00053       }
00054 
00055       // for microcode
00056 
00057       // microcode needs to be able to request these for storage when no
00058       // normal, tex coord or vertex color is supplied for each vertex
00059       inline CDmaPacket& GetNormalBuf() { return *CurNormalBuf; }
00060       inline CDmaPacket& GetTexCoordBuf() { return *CurTexCoordBuf; }
00061 
00062       // user state
00063 
00064       void EnableCustom( tU64 flag ) { RendererManager.EnableCustom(flag); }
00065       void DisableCustom( tU64 flag ) { RendererManager.DisableCustom(flag); }
00066 
00067       // geometry specification
00068 
00069       void BeginGeom( GLenum mode );
00070       void Vertex( cpu_vec_xyzw newVert );
00071       void Normal( cpu_vec_xyz normal );
00072       void TexCoord( float u, float v );
00073       void Color( cpu_vec_xyzw color );
00074       void EndGeom();
00075       void DrawArrays( GLenum mode, int first, int count );
00076       void DrawIndexedArrays( GLenum primType,
00077                               int numIndices, const unsigned char* indices,
00078                               int numVertices );
00079       void Flush();
00080 };
00081 
00082 #endif // ps2gl_immgmanager_h

ps2gl version cvs