summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoriCatButler <i.am.catbutler@gmail.com>2016-05-10 21:34:27 +0100
committeriCatButler <i.am.catbutler@gmail.com>2016-05-10 21:34:27 +0100
commitb5a738748175a460f856a1ed8a2e29fa26ebfb14 (patch)
tree8cc060819d9433940859de000bbb986cc45d7458 /plugins
parent1a30cfb9510d4e46960010735d26a344f75cb328 (diff)
Add PGXP visual debug mode
Toggles using F11 Red = low precision Blue = high precision Yellow = Sprite
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/peopsxgl/externals.h2
-rwxr-xr-xplugins/peopsxgl/gpu.c1
-rw-r--r--plugins/peopsxgl/pgxp_gpu.c184
-rw-r--r--plugins/peopsxgl/pgxp_gpu.h11
-rwxr-xr-xplugins/peopsxgl/prim.c68
5 files changed, 256 insertions, 10 deletions
diff --git a/plugins/peopsxgl/externals.h b/plugins/peopsxgl/externals.h
index a3f0a20f..89c19743 100755
--- a/plugins/peopsxgl/externals.h
+++ b/plugins/peopsxgl/externals.h
@@ -193,6 +193,8 @@ typedef struct OGLVertexTag
unsigned char col[4];
unsigned int lcol;
} c;
+
+ unsigned int PGXP_flag;
} OGLVertex;
typedef union EXShortTag
diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c
index fd784c51..5becb698 100755
--- a/plugins/peopsxgl/gpu.c
+++ b/plugins/peopsxgl/gpu.c
@@ -2986,6 +2986,7 @@ ENDVRAM:
vertex[i].x = vertex[i].y = 0.f;
vertex[i].z = 0.95f;
vertex[i].w = 1.f;
+ vertex[i].PGXP_flag = 0;
}
primFunc[gpuCommand]((unsigned char *)gpuDataM);
diff --git a/plugins/peopsxgl/pgxp_gpu.c b/plugins/peopsxgl/pgxp_gpu.c
index e8191e48..ece50795 100644
--- a/plugins/peopsxgl/pgxp_gpu.c
+++ b/plugins/peopsxgl/pgxp_gpu.c
@@ -106,25 +106,25 @@ void PGXP_SetMatrix(float left, float right, float bottom, float top, float zNea
void PGXP_glVertexfv(GLfloat* pV)
{
// If there are PGXP vertices expected
- //if (vertexIdx < numVertices)
- //{
+ if (1)//(vertexIdx < numVertices)
+ {
float temp[4];
memcpy(temp, pV, sizeof(float) * 4);
- // pre-multiply each element by w (to negate perspective divide)
+ //pre-multiply each element by w (to negate perspective divide)
for (unsigned int i = 0; i < 3; i++)
temp[i] *= temp[3];
- // pass complete vertex to OpenGL
+ //pass complete vertex to OpenGL
glVertex4fv(temp);
vertexIdx++;
- // pV[3] = 1.f;
- //}
- //else
- //{
- // glVertex3fv(pV);
- //}
+ //pV[3] = 1.f;
+ }
+ else
+ {
+ glVertex3fv(pV);
+ }
}
// Get parallel vertex values
@@ -170,9 +170,173 @@ int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs)
pVertex[i].y = (primStart[stride * i].y + yOffs);
pVertex[i].z = 0.95f;
pVertex[i].w = w;
+ pVertex[i].PGXP_flag = 1;
}
+ else
+ pVertex[i].PGXP_flag = 2;
}
return 1;
}
+/////////////////////////////////
+//// Visual Debugging Functions
+/////////////////////////////////
+unsigned int PGXP_vDebug = 0;
+
+const char blue[4] = { 0, 0, 255, 255 };
+const char red[4] = { 255, 0, 0, 255 };
+const char black[4] = { 0, 0, 0, 255 };
+const char yellow[4] = { 255, 255, 0, 255 };
+
+void CALLBACK GPUtoggleDebug(void)
+{
+ if (PGXP_vDebug)
+ PGXP_vDebug = 0;
+ else
+ PGXP_vDebug = 1;
+}
+
+const char* PGXP_colour(unsigned int flag)
+{
+ switch (flag)
+ {
+ case 0:
+ return yellow;
+ case 1:
+ return blue;
+ case 2:
+ return red;
+ default:
+ return black;
+ }
+}
+
+void PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
+{
+ GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
+ GLfloat fColour[4];
+ glGetFloatv(GL_CURRENT_COLOR, fColour);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(PGXP_colour(vertex1->PGXP_flag));
+ PGXP_glVertexfv(&vertex1->x);
+
+ glColor4ubv(PGXP_colour(vertex2->PGXP_flag));
+ PGXP_glVertexfv(&vertex2->x);
+
+ glColor4ubv(PGXP_colour(vertex3->PGXP_flag));
+ PGXP_glVertexfv(&vertex3->x);
+
+ glColor4ubv(PGXP_colour(vertex4->PGXP_flag));
+ PGXP_glVertexfv(&vertex4->x);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(black);
+ PGXP_glVertexfv(&vertex1->x);
+ PGXP_glVertexfv(&vertex2->x);
+ PGXP_glVertexfv(&vertex3->x);
+ PGXP_glVertexfv(&vertex4->x);
+
+ glColor4fv(fColour);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glPolygonMode(GL_BACK, GL_FILL);
+
+ if(bTexture == GL_TRUE)
+ glEnable(GL_TEXTURE_2D);
+}
+
+void PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
+{
+ GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
+ GLfloat fColour[4];
+ glGetFloatv(GL_CURRENT_COLOR, fColour);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_TRIANGLES);
+
+ glColor4ubv(PGXP_colour(vertex1->PGXP_flag));
+ PGXP_glVertexfv(&vertex1->x);
+
+ glColor4ubv(PGXP_colour(vertex2->PGXP_flag));
+ PGXP_glVertexfv(&vertex2->x);
+
+ glColor4ubv(PGXP_colour(vertex3->PGXP_flag));
+ PGXP_glVertexfv(&vertex3->x);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(black);
+ PGXP_glVertexfv(&vertex1->x);
+ PGXP_glVertexfv(&vertex2->x);
+ PGXP_glVertexfv(&vertex3->x);
+
+ glColor4fv(fColour);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glPolygonMode(GL_BACK, GL_FILL);
+
+ if (bTexture == GL_TRUE)
+ glEnable(GL_TEXTURE_2D);
+}
+
+void PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4)
+{
+ GLboolean bTexture = glIsEnabled(GL_TEXTURE_2D);
+ GLfloat fColour[4];
+ glGetFloatv(GL_CURRENT_COLOR, fColour);
+ glDisable(GL_TEXTURE_2D);
+
+ glBegin(GL_QUADS);
+ glColor4ubv(PGXP_colour(vertex1->PGXP_flag));
+ PGXP_glVertexfv(&vertex1->x);
+
+ glColor4ubv(PGXP_colour(vertex2->PGXP_flag));
+ PGXP_glVertexfv(&vertex2->x);
+
+ glColor4ubv(PGXP_colour(vertex3->PGXP_flag));
+ PGXP_glVertexfv(&vertex3->x);
+
+ glColor4ubv(PGXP_colour(vertex4->PGXP_flag));
+ PGXP_glVertexfv(&vertex4->x);
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ glBegin(GL_TRIANGLE_STRIP);
+
+ glColor4ubv(black);
+ PGXP_glVertexfv(&vertex1->x);
+ PGXP_glVertexfv(&vertex2->x);
+ PGXP_glVertexfv(&vertex3->x);
+ PGXP_glVertexfv(&vertex4->x);
+
+ glColor4fv(fColour);
+
+ glEnd();
+
+ glPolygonMode(GL_FRONT, GL_FILL);
+ glPolygonMode(GL_BACK, GL_FILL);
+
+ if (bTexture == GL_TRUE)
+ glEnable(GL_TEXTURE_2D);
+} \ No newline at end of file
diff --git a/plugins/peopsxgl/pgxp_gpu.h b/plugins/peopsxgl/pgxp_gpu.h
index 97c5b615..df07ff46 100644
--- a/plugins/peopsxgl/pgxp_gpu.h
+++ b/plugins/peopsxgl/pgxp_gpu.h
@@ -30,9 +30,20 @@
#include "stdafx.h"
+//struct OGLVertex;
+
+struct OGLVertexTag;
+typedef struct OGLVertexTag OGLVertex;
+
void PGXP_SetMatrix(float left, float right, float bottom, float top, float zNear, float zFar);
void PGXP_SetAddress(unsigned int addr);
int PGXP_GetVertices(unsigned int* addr, void* pOutput, int xOffs, int yOffs);
void PGXP_glVertexfv(GLfloat* pVertex);
+extern unsigned int PGXP_vDebug;
+extern unsigned int PGXP_debugFlags[4];
+void PGXP_DrawDebugTriQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4);
+void PGXP_DrawDebugTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3);
+void PGXP_DrawDebugQuad(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3, OGLVertex* vertex4);
+
#endif // _PGXP_GPU_H_
diff --git a/plugins/peopsxgl/prim.c b/plugins/peopsxgl/prim.c
index ffa3fcf3..eb4b7f01 100755
--- a/plugins/peopsxgl/prim.c
+++ b/plugins/peopsxgl/prim.c
@@ -25,6 +25,7 @@
#include "draw.h"
#include "soft.h"
#include "texture.h"
+#include "PGXP_gpu.h"
////////////////////////////////////////////////////////////////////////
// defines
@@ -149,6 +150,13 @@ unsigned short BGR24to16 (uint32_t BGR)
static __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3);
+ return;
+ }
+
+
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2fv(&vertex1->sow);
PGXP_glVertexfv(&vertex1->x);
@@ -169,6 +177,12 @@ static __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2
static __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
glTexCoord2fv(&vertex1->sow);
PGXP_glVertexfv(&vertex1->x);
@@ -186,6 +200,12 @@ static __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
static __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
SETPCOL(vertex1);
@@ -207,6 +227,12 @@ static __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* v
static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex2, vertex4, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLE_STRIP);
SETPCOL(vertex1);
glTexCoord2fv(&vertex1->sow);
@@ -230,6 +256,12 @@ static __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVerte
static __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
PGXP_glVertexfv(&vertex1->x);
PGXP_glVertexfv(&vertex2->x);
@@ -242,6 +274,12 @@ static __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVert
static __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4);
+ return;
+ }
+
glBegin(GL_TRIANGLE_STRIP);
PGXP_glVertexfv(&vertex1->x);
PGXP_glVertexfv(&vertex3->x);
@@ -255,6 +293,12 @@ static __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
static __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTri(vertex1, vertex2, vertex3);
+ return;
+ }
+
glBegin(GL_TRIANGLES);
SETPCOL(vertex1);
PGXP_glVertexfv(&vertex1->x);
@@ -272,6 +316,12 @@ static __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vert
static __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugTriQuad(vertex1, vertex3, vertex2, vertex4);
+ return;
+ }
+
glBegin(GL_TRIANGLE_STRIP);
SETPCOL(vertex1);
PGXP_glVertexfv(&vertex1->x);
@@ -291,6 +341,12 @@ static __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* ver
static __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ return;
+ }
+
glBegin(GL_QUADS);
SETPCOL(vertex1);
@@ -306,6 +362,12 @@ static __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGL
static __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ return;
+ }
+
glBegin(GL_QUADS);
SETPCOL(vertex1);
@@ -327,6 +389,12 @@ static __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,
static __inline void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,
OGLVertex* vertex3, OGLVertex* vertex4)
{
+ if (PGXP_vDebug)
+ {
+ PGXP_DrawDebugQuad(vertex1, vertex2, vertex3, vertex4);
+ return;
+ }
+
glBegin(GL_QUADS);
PGXP_glVertexfv(&vertex1->x);
PGXP_glVertexfv(&vertex2->x);