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) { 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); glViewport(x, y, w, h);
glScissor (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); const float f = _glFastInvert(vertex->w);
/* Convert to NDC and apply viewport */ /* Convert to NDC and apply viewport */
vertex->xyz[0] = (vertex->xyz[0] * f * 320) + 320; vertex->xyz[0] = (vertex->xyz[0] * f * VIEWPORT.hwidth) + VIEWPORT.x_plus_hwidth;
vertex->xyz[1] = (vertex->xyz[1] * f * -240) + 240; vertex->xyz[1] = (vertex->xyz[1] * f * VIEWPORT.hheight) + VIEWPORT.y_plus_hheight;
/* Orthographic projections need to use invZ otherwise we lose /* Orthographic projections need to use invZ otherwise we lose
the depth information. As w == 1, and clip-space range is -w to +w 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 = { Viewport VIEWPORT;
0, 0, 640, 480, 320.0f, 240.0f, 320.0f, 240.0f
};
/* Set the GL viewport */ /* Set the GL viewport */
void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
VIEWPORT.x = x; VIEWPORT.hwidth = ((GLfloat)width) * 0.5f;
VIEWPORT.y = y; VIEWPORT.hheight = ((GLfloat)height) * -0.5f;
VIEWPORT.width = width; VIEWPORT.x_plus_hwidth = x + VIEWPORT.hwidth;
VIEWPORT.height = height; VIEWPORT.y_plus_hheight = y + VIEWPORT.hheight;
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;
} }