From 216c2ff3aefc9e0295ed9b1486935d65f6c13f55 Mon Sep 17 00:00:00 2001 From: iCatButler Date: Mon, 2 May 2016 15:01:27 +0100 Subject: Fix bugs from previous Fix stray triangles - Switch to full floating point RTPS/RTPT - Clamp w values to near plane Fix texture corruption in 1.78, copy 2.4 Tweak - Remove matrix replacement - Add W component to vertices - Wrap glVertex3fv calls - Use counter to call glVertex4fv for PGXP vertices only --- plugins/peopsxgl/pgxp_gpu.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'plugins/peopsxgl/pgxp_gpu.c') diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c index eedf7b8d..98b7a94d 100644 --- a/plugins/peopsxgl/pgxp_gpu.c +++ b/plugins/peopsxgl/pgxp_gpu.c @@ -47,6 +47,9 @@ const unsigned int primCountTable[] = { 3, 3, 4, 4, 3, 3, 4, 4, 0 }; PGXP_vertex* PGXP_Mem = NULL; // pointer to parallel memory unsigned int currentAddr = 0; // address of current DMA +unsigned int numVertices = 0; // iCB: Used for glVertex3fv fix +unsigned int vertexIdx = 0; + // Set current DMA address and pointer to parallel memory void CALLBACK GPUpgxpMemory(unsigned int addr, unsigned char* pVRAM) { @@ -99,6 +102,26 @@ void PGXP_SetMatrix(float left, float right, float bottom, float top, float zNea //glOrtho(left, right, bottom, top, zNear, zFar); } +// Wrap glVertex3fv/glVertex4fv +void PGXP_glVertexfv(GLfloat* pV) +{ + // If there are PGXP vertices expected + if (vertexIdx < numVertices) + { + // pre-multiply each element by w (to negate perspective divide) + for (unsigned int i = 0; i < 3; i++) + pV[i] *= pV[3]; + + // pass complete vertex to OpenGL + glVertex4fv(pV); + vertexIdx++; + } + else + { + glVertex3fv(pV); + } +} + // Get parallel vertex values int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs) { @@ -114,6 +137,10 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs) if (PGXP_Mem == NULL) return 0; + // Reset vertex count + numVertices = count; + vertexIdx = 0; + // Offset to start of primitive primStart = &PGXP_Mem[currentAddr + 1]; @@ -134,10 +161,10 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs) if (primStart[stride * i].valid) { - // Premultiply x,y coorindates by w because they've already been divided by w - pVertex[i].x = (primStart[stride * i].x + xOffs) * w; - pVertex[i].y = (primStart[stride * i].y + yOffs) * w; - pVertex[i].z = w; + pVertex[i].x = (primStart[stride * i].x + xOffs); + pVertex[i].y = (primStart[stride * i].y + yOffs); + pVertex[i].z = 0.95f; + pVertex[i].w = w; } } -- cgit v1.2.3