11#include "ps2s/cpu_matrix.h"
12#include "ps2s/displayenv.h"
14#include "ps2s/packet.h"
16#include "ps2gl/clear.h"
17#include "ps2gl/debug.h"
18#include "ps2gl/dlist.h"
19#include "ps2gl/glcontext.h"
20#include "ps2gl/gmanager.h"
21#include "ps2gl/matrix.h"
27CVertArray::CVertArray()
29 Vertices = Normals = TexCoords = Colors = NULL;
30 VerticesAreValid = NormalsAreValid = TexCoordsAreValid = ColorsAreValid =
false;
31 WordsPerVertex = WordsPerTexCoord = WordsPerColor = 0;
45bool CGeomManager::DoNormalize =
false;
49 , CurNormal(0.0f, 0.0f, 1.0f)
50 , Prim(GL_INVALID_VALUE)
51 , InsideBeginEnd(false)
52 , LastArrayAccessWasIndexed(false)
53 , LastArrayAccessIsValid(false)
54 , UserRenderContextChanged(false)
56 for (
unsigned int i = 0; i < kMaxUserPrimTypes; i++)
57 UserPrimTypes[i].requirements = 0xffffffff;
81 GLsizei stride,
const GLvoid* ptr)
83 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
86 mNotImplemented(
"stride must be 0");
89 if (type != GL_FLOAT) {
90 mNotImplemented(
"type must be float");
94 CVertArray& vertArray = pGLContext->GetGeomManager().GetVertArray();
95 vertArray.SetVertices((
void*)ptr);
96 vertArray.SetWordsPerVertex(size);
107 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
119 GLsizei stride,
const GLvoid* ptr)
121 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
124 mNotImplemented(
"stride must be 0");
127 if (type != GL_FLOAT) {
128 mNotImplemented(
"type must be float");
132 CVertArray& vertArray = pGLContext->GetGeomManager().GetVertArray();
133 vertArray.SetTexCoords((
void*)ptr);
134 vertArray.SetWordsPerTexCoord(size);
144 GLsizei stride,
const GLvoid* ptr)
146 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
149 mNotImplemented(
"stride must be 0");
152 if (type != GL_FLOAT) {
153 mNotImplemented(
"type must be float");
157 CVertArray& vertArray = pGLContext->GetGeomManager().GetVertArray();
158 vertArray.SetColors((
void*)ptr);
159 vertArray.SetWordsPerColor(size);
175 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
178 gmanager.DrawArrays(mode, first, count);
184void glDrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid* indices)
186 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
188 mError(
"glDrawElements is a placeholder ATM and should not be called");
196 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
198 mError(
"glInterleavedArrays is a placeholder ATM and should not be called");
206 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
208 mError(
"glArrayElement is a placeholder ATM and should not be called");
216 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
224void glEnableClientState(GLenum cap)
226 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
229 CVertArray& vertArray = gmanager.GetVertArray();
232 case GL_NORMAL_ARRAY:
233 vertArray.SetNormalsValid(
true);
235 case GL_VERTEX_ARRAY:
236 vertArray.SetVerticesValid(
true);
239 vertArray.SetColorsValid(
true);
241 case GL_TEXTURE_COORD_ARRAY:
242 vertArray.SetTexCoordsValid(
true);
246 case GL_EDGE_FLAG_ARRAY:
247 mNotImplemented(
"capability = %d", cap);
252void glDisableClientState(GLenum cap)
254 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
257 CVertArray& vertArray = gmanager.GetVertArray();
260 case GL_NORMAL_ARRAY:
261 vertArray.SetNormalsValid(
false);
263 case GL_VERTEX_ARRAY:
264 vertArray.SetVerticesValid(
false);
267 vertArray.SetColorsValid(
false);
269 case GL_TEXTURE_COORD_ARRAY:
270 vertArray.SetTexCoordsValid(
false);
274 case GL_EDGE_FLAG_ARRAY:
275 mNotImplemented(
"capability = %d", cap);
280void glBegin(GLenum mode)
282 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
285 gmanager.BeginGeom(mode);
288void glNormal3f(GLfloat x, GLfloat y, GLfloat z)
290 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
293 gmanager.Normal(cpu_vec_xyz(x, y, z));
296void glNormal3fv(
const GLfloat* v)
298 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
300 glNormal3f(v[0], v[1], v[2]);
303void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
305 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
308 gmanager.Vertex(cpu_vec_xyzw(x, y, z, w));
311void glVertex4fv(
const GLfloat* vertex)
313 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
315 glVertex4f(vertex[0], vertex[1], vertex[2], vertex[3]);
318void glVertex3f(GLfloat x, GLfloat y, GLfloat z)
320 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
322 glVertex4f(x, y, z, 1.0f);
325void glVertex3fv(
const GLfloat* vertex)
327 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
329 glVertex4f(vertex[0], vertex[1], vertex[2], 1.0f);
332void glVertex2f(GLfloat x, GLfloat y)
334 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
336 glVertex4f(x, y, 0.0f, 1.0f);
339void glVertex2i(GLint x, GLint y)
341 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
343 glVertex4f((GLfloat)x, (GLfloat)y, 0.0f, 1.0f);
346void glVertex2fv(
const GLfloat* vertex)
348 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
350 glVertex4f(vertex[0], vertex[1], 0.0f, 1.0f);
353void glTexCoord2f(GLfloat u, GLfloat v)
355 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
358 gmanager.TexCoord(u, v);
361void glTexCoord2fv(
const GLfloat* texCoord)
363 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
365 glTexCoord2f(texCoord[0], texCoord[1]);
368void glColor3f(GLfloat red, GLfloat green, GLfloat blue)
370 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
373 gmanager.Color(cpu_vec_xyzw(red, green, blue, 1.0f));
376void glColor3fv(
const GLfloat* color)
378 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
380 glColor3f(color[0], color[1], color[2]);
383void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
385 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
388 gmanager.Color(cpu_vec_xyzw(red, green, blue, alpha));
391void glColor4fv(
const GLfloat* color)
393 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
395 glColor4f(color[0], color[1], color[2], color[3]);
400 GL_FUNC_DEBUG(
"%s\n", __FUNCTION__);
421 GLsizei stride,
const GLvoid* ptr)
424 mNotImplemented(
"stride must be 0");
427 if (type != GL_FLOAT) {
428 mNotImplemented(
"type must be float");
432 CVertArray& vertArray = pGLContext->GetGeomManager().GetVertArray();
433 vertArray.SetNormals((
void*)ptr);
434 vertArray.SetWordsPerNormal(size);
437void pglDrawIndexedArrays(GLenum primType,
438 int numIndices,
const unsigned char* indices,
441 pGLContext->GetGeomManager().DrawIndexedArrays(primType, numIndices, indices, numVertices);
478 pglU64_t requirements, pglU64_t rendererReqMask,
int mergeContiguous)
480 mErrorIf(!CGeomManager::IsUserPrimType(primType),
"custom prim types must have bit 31 set");
481 CGeomManager::RegisterUserPrimType(primType, requirements, rendererReqMask, mergeContiguous);
492 flag &= ~(tU64)0xffffffff;
493 pGLContext->GetGeomManager().EnableCustom(flag);
504 flag &= ~(tU64)0xffffffff;
505 pGLContext->GetGeomManager().DisableCustom(flag);
508void pglUserRenderContextChanged()
510 pGLContext->GetGeomManager().SetUserRenderContextChanged();
void pglDisableCustom(pglU64_t flag)
void pglRegisterCustomPrimType(GLenum primType, pglU64_t requirements, pglU64_t rendererReqMask, int mergeContiguous)
void pglEnableCustom(pglU64_t flag)
void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
void glArrayElement(GLint i)
void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
void glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
void glDrawArrays(GLenum mode, GLint first, GLsizei count)
void pglNormalPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)