PS2GL
OpenGL*-like API for the PS2
Loading...
Searching...
No Matches
immgmanager.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 ps2gl_immgmanager_h
8#define ps2gl_immgmanager_h
9
10#include "ps2gl/gmanager.h"
11
12/********************************************
13 * CImmGeomManager - the immediate renderer
14 */
15
17
18 CRendererManager RendererManager;
19
20 // a double set of buffers for storing immediate-mode vertices, normals, etc.
21 // these don't really need to be dma packets since they will be reffed by
22 // the microcode
23 CDmaPacket VertexBuf0, NormalBuf0, TexCoordBuf0, ColorBuf0;
24 CDmaPacket VertexBuf1, NormalBuf1, TexCoordBuf1, ColorBuf1;
25 CDmaPacket *CurVertexBuf, *CurNormalBuf, *CurTexCoordBuf, *CurColorBuf;
26
27 CGeometryBlock Geometry;
28
29 void CommitNewGeom();
30
31public:
32 CImmGeomManager(CGLContext& context, int immBufferQwordSize);
33 virtual ~CImmGeomManager();
34
35 CRendererManager& GetRendererManager() { return RendererManager; }
36
37 void SwapBuffers();
38
39 // state changes / updates
40
41 void PrimChanged(GLenum primType);
42 void SyncRendererContext(GLenum primType);
43 void SyncRenderer();
44 void SyncGsContext();
45 void SyncColorMaterial(bool pvColorsArePresent);
46
47 void DrawingLinearArray();
48 void DrawingIndexedArray();
49
50 void SyncArrayType(ArrayType::tArrayType type)
51 {
52 if (type == ArrayType::kLinear)
53 DrawingLinearArray();
54 else
55 DrawingIndexedArray();
56 }
57
58 // for microcode
59
60 // microcode needs to be able to request these for storage when no
61 // normal, tex coord or vertex color is supplied for each vertex
62 inline CDmaPacket& GetNormalBuf() { return *CurNormalBuf; }
63 inline CDmaPacket& GetTexCoordBuf() { return *CurTexCoordBuf; }
64
65 // user state
66
67 void EnableCustom(tU64 flag) { RendererManager.EnableCustom(flag); }
68 void DisableCustom(tU64 flag) { RendererManager.DisableCustom(flag); }
69
70 // geometry specification
71
72 void BeginGeom(GLenum mode);
73 void Vertex(cpu_vec_xyzw newVert);
74 void Normal(cpu_vec_xyz normal);
75 void TexCoord(float u, float v);
76 void Color(cpu_vec_xyzw color);
77 void EndGeom();
78 void DrawArrays(GLenum mode, int first, int count);
79 void DrawIndexedArrays(GLenum primType,
80 int numIndices, const unsigned char* indices,
81 int numVertices);
82 void Flush();
83};
84
85#endif // ps2gl_immgmanager_h