Dreamcast: WIP on split screen support

This commit is contained in:
UnknownShadow200 2024-04-25 22:07:33 +10:00
parent b478c486a0
commit 6f5500d4e8
3 changed files with 13 additions and 13 deletions

View File

@ -559,6 +559,12 @@ void Gfx_OnWindowResize(void) {
}
void Gfx_SetViewport(int x, int y, int w, int h) {
if (x == 0 && y == 0 && w == Game.Width && h == Game.Height) {
glDisable(GL_SCISSOR_TEST);
} else {
glEnable(GL_SCISSOR_TEST);
}
glViewport(x, y, w, h);
glScissor (x, y, w, h);
}

View File

@ -45,8 +45,8 @@ GL_FORCE_INLINE void _glPerspectiveDivideVertex(Vertex* vertex) {
const float f = _glFastInvert(vertex->w);
/* Convert to NDC and apply viewport */
vertex->xyz[0] = (vertex->xyz[0] * f * 320) + 320;
vertex->xyz[1] = (vertex->xyz[1] * f * -240) + 240;
vertex->xyz[0] = (vertex->xyz[0] * f * VIEWPORT.hwidth) + VIEWPORT.x_plus_hwidth;
vertex->xyz[1] = (vertex->xyz[1] * f * VIEWPORT.hheight) + VIEWPORT.y_plus_hheight;
/* Orthographic projections need to use invZ otherwise we lose
the depth information. As w == 1, and clip-space range is -w to +w

View File

@ -253,20 +253,14 @@ void APIENTRY glGetIntegerv(GLenum pname, GLint *params) {
}
Viewport VIEWPORT = {
0, 0, 640, 480, 320.0f, 240.0f, 320.0f, 240.0f
};
Viewport VIEWPORT;
/* Set the GL viewport */
void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
VIEWPORT.x = x;
VIEWPORT.y = y;
VIEWPORT.width = width;
VIEWPORT.height = height;
VIEWPORT.hwidth = ((GLfloat) VIEWPORT.width) * 0.5f;
VIEWPORT.hheight = ((GLfloat) VIEWPORT.height) * 0.5f;
VIEWPORT.x_plus_hwidth = VIEWPORT.x + VIEWPORT.hwidth;
VIEWPORT.y_plus_hheight = VIEWPORT.y + VIEWPORT.hheight;
VIEWPORT.hwidth = ((GLfloat)width) * 0.5f;
VIEWPORT.hheight = ((GLfloat)height) * -0.5f;
VIEWPORT.x_plus_hwidth = x + VIEWPORT.hwidth;
VIEWPORT.y_plus_hheight = y + VIEWPORT.hheight;
}