PS2GL
OpenGL*-like API for the PS2
Loading...
Searching...
No Matches
drawcontext.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_drawcontext_h
8#define ps2gl_drawcontext_h
9
10/********************************************
11 * includes
12 */
13
14#include "ps2s/cpu_matrix.h"
15
16#include "ps2gl/glcontext.h"
17#include "ps2gl/immgmanager.h"
18
19namespace GS {
20class CDrawEnv;
21class CMemArea;
22}
23
24/********************************************
25 * CDrawContext
26 */
27
29protected:
30 CGLContext& GLContext;
31
32public:
33 inline CDrawContext(CGLContext& context)
34 : GLContext(context)
35 {
36 }
37 virtual ~CDrawContext()
38 {
39 }
40
41 virtual void SetDoSmoothShading(bool yesNo) = 0;
42 virtual void SetDoClipping(bool clip) = 0;
43 virtual void SetDoCullFace(bool cull) = 0;
44 virtual void SetCullFaceDir(int direction) = 0;
45 virtual void SetRescaleNormals(bool rescale) = 0;
46 virtual void SetBlendEnabled(bool enabled) = 0;
47 virtual void SetDepthWriteEnabled(bool enabled) = 0;
48 virtual void SetFrameBufferDrawMask(unsigned int mask) = 0;
49 virtual void SetAlphaTestEnabled(bool enabled) = 0;
50 virtual void SetDepthTestEnabled(bool enabled) = 0;
51 virtual void SetInterlacingOffset(float yPixels) = 0;
52 virtual void SetPolygonMode(GLenum mode) = 0;
53
54 virtual void SetBlendMode(GLenum source, GLenum dest) = 0;
55 virtual void SetAlphaFunc(GLenum func, GLclampf ref) = 0;
56 virtual void SetDepthFunc(GLenum func) = 0;
57
58 virtual void SetDrawBuffers(bool interlaced,
59 GS::CMemArea* frame0Mem, GS::CMemArea* frame1Mem,
60 GS::CMemArea* depthMem)
61 = 0;
62};
63
64/********************************************
65 * CImmDrawContext
66 */
67
68class CClearEnv;
69
71public:
72 GS::CDrawEnv* DrawEnv;
73
74 GS::CMemArea *Frame0Mem, *Frame1Mem, *ZBufMem;
75 GS::CMemArea *CurFrameMem, *LastFrameMem;
76
77 CClearEnv* ClearEnv;
78
79 bool FrameIsDblBuffered;
80
81 // gl state
82 bool DoSmoothShading;
83 bool DoClipping;
84 bool DoCullFace;
85 int CullFaceDir; // 1 or -1
86 bool RescaleNormals;
87 bool BlendIsEnabled;
88 bool AlphaTestIsEnabled;
89 bool DepthTestIsEnabled;
90 bool DrawInterlaced;
91 GLenum PolyMode;
92 int DepthBits;
93
94 // current vertex xform
95 cpu_mat_44 VertexXform;
96 cpu_mat_44 GSScale;
97 bool IsVertexXformValid;
98
99 int Width, Height;
100
101public:
102 CImmDrawContext(CGLContext& context);
103 virtual ~CImmDrawContext();
104
105 GS::CDrawEnv& GetDrawEnv() { return *DrawEnv; }
106 void SwapBuffers(bool fieldIsEven);
107
108 inline CClearEnv& GetClearEnv() { return *ClearEnv; }
109
110 const cpu_mat_44& GetVertexXform();
111 inline void SetVertexXformValid(bool valid)
112 {
113 IsVertexXformValid = valid;
114 if (!valid)
115 GLContext.XformChanged();
116 }
117
118 int GetFBWidth() const { return Width; }
119 int GetFBHeight() const { return Height; }
120
121 int GetDepthBits() const { return DepthBits; }
122 void SetDepthBits(int depth) { DepthBits = depth; }
123
124 // virtuals
125
126 void SetBlendMode(GLenum source, GLenum dest);
127 void SetAlphaFunc(GLenum func, GLclampf ref);
128 void SetDepthFunc(GLenum func);
129
130 inline bool GetDoSmoothShading() const { return DoSmoothShading; }
131 void SetDoSmoothShading(bool yesNo);
132
133 inline bool GetDoClipping() const { return DoClipping; }
134 void SetDoClipping(bool clip);
135
136 inline bool GetDoCullFace() const { return DoCullFace; }
137 void SetDoCullFace(bool cull);
138
139 inline int GetCullFaceDir() const { return CullFaceDir; }
140 void SetCullFaceDir(int direction);
141
142 inline bool GetBlendEnabled() const { return BlendIsEnabled; }
143 void SetBlendEnabled(bool enabled);
144
145 inline bool GetAlphaTestEnabled() const { return AlphaTestIsEnabled; }
146 void SetAlphaTestEnabled(bool enabled);
147
148 inline bool GetDepthTestEnabled() const { return DepthTestIsEnabled; }
149 void SetDepthTestEnabled(bool enabled);
150
151 void SetInterlacingOffset(float yPixels);
152
153 void SetDepthWriteEnabled(bool enabled);
154 void SetFrameBufferDrawMask(unsigned int mask);
155
156 inline GLenum GetPolygonMode() const { return PolyMode; }
157 void SetPolygonMode(GLenum mode);
158
159 inline bool GetRescaleNormals() const { return RescaleNormals; }
160 void SetRescaleNormals(bool rescale);
161
162 void SetDrawBuffers(bool interlaced,
163 GS::CMemArea* frame0Mem, GS::CMemArea* frame1Mem,
164 GS::CMemArea* depthMem);
165};
166
167/********************************************
168 * CDListDrawContext
169 */
170
172public:
174 : CDrawContext(context)
175 {
176 }
177
178 void SetBlendMode(GLenum source, GLenum dest);
179 void SetAlphaFunc(GLenum func, GLclampf ref);
180 void SetDepthFunc(GLenum func);
181
182 void SetDoSmoothShading(bool yesNo);
183 void SetDoClipping(bool clip);
184 void SetDoCullFace(bool cull);
185 void SetCullFaceDir(int direction);
186 void SetRescaleNormals(bool rescale);
187 void SetBlendEnabled(bool enabled);
188 void SetAlphaTestEnabled(bool enabled);
189 void SetDepthTestEnabled(bool enabled);
190 void SetInterlacingOffset(float yPixels);
191 void SetDepthWriteEnabled(bool enabled);
192 void SetFrameBufferDrawMask(unsigned int mask);
193 void SetPolygonMode(GLenum mode) { assert(false); }
194
195 void SetDrawBuffers(bool interlaced,
196 GS::CMemArea* frame0Mem, GS::CMemArea* frame1Mem,
197 GS::CMemArea* depthMem);
198};
199
200#endif // ps2gl_drawcontext_h