mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Xbox: Add splitscreen too
This commit is contained in:
parent
efa7558960
commit
0bc1b1c971
4 changed files with 41 additions and 21 deletions
|
@ -11,7 +11,8 @@ struct vOut {
|
|||
vOut main(
|
||||
vIn input,
|
||||
uniform float4x4 mvp,
|
||||
uniform float4 half_viewport
|
||||
uniform float4 vp_scale,
|
||||
uniform float4 vp_offset
|
||||
)
|
||||
{
|
||||
vOut result;
|
||||
|
@ -21,9 +22,9 @@ vOut main(
|
|||
position = mul(position, mvp);
|
||||
position.xyz = position.xyz / position.w;
|
||||
|
||||
position.x = position.x * half_viewport.x + half_viewport.x;
|
||||
position.y = -position.y * half_viewport.y + half_viewport.y;
|
||||
position.z = position.z * half_viewport.z + half_viewport.z;
|
||||
position.x = position.x * vp_scale.x + vp_offset.x;
|
||||
position.y = position.y * vp_scale.y + vp_offset.y;
|
||||
position.z = position.z * vp_scale.z + vp_offset.z;
|
||||
//position.w = 1.0 / half_viewport.w;
|
||||
|
||||
result.pos = position;
|
||||
|
|
|
@ -13,7 +13,8 @@ struct vOut {
|
|||
vOut main(
|
||||
vIn input,
|
||||
uniform float4x4 mvp,
|
||||
uniform float4 half_viewport
|
||||
uniform float4 vp_scale,
|
||||
uniform float4 vp_offset
|
||||
)
|
||||
{
|
||||
vOut result;
|
||||
|
@ -23,9 +24,9 @@ vOut main(
|
|||
position = mul(position, mvp);
|
||||
position.xyz = position.xyz / position.w;
|
||||
|
||||
position.x = position.x * half_viewport.x + half_viewport.x;
|
||||
position.y = -position.y * half_viewport.y + half_viewport.y;
|
||||
position.z = position.z * half_viewport.z + half_viewport.z;
|
||||
position.x = position.x * vp_scale.x + vp_offset.x;
|
||||
position.y = position.y * vp_scale.y + vp_offset.y;
|
||||
position.z = position.z * vp_scale.z + vp_offset.z;
|
||||
//position.w = 1.0 / half_viewport.w;
|
||||
|
||||
result.pos = position;
|
||||
|
|
|
@ -136,6 +136,7 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#elif defined XENON
|
||||
/* libxenon also defines __linux__ (yes, really) */
|
||||
#define CC_BUILD_XBOX360
|
||||
|
|
|
@ -106,6 +106,7 @@ static void ResetState(void) {
|
|||
}
|
||||
|
||||
static GfxResourceID white_square;
|
||||
|
||||
void Gfx_Create(void) {
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512; // TODO: 1024?
|
||||
|
@ -535,17 +536,11 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
|
|||
|
||||
void Gfx_OnWindowResize(void) { }
|
||||
|
||||
void Gfx_SetViewport(int x, int y, int w, int h) { }
|
||||
|
||||
static struct Vec4 vp_offset = { 320, -240, 8388608, 1 };
|
||||
static struct Vec4 vp_scale = { 320, 240, 8388608, 1 };
|
||||
static struct Matrix _view, _proj, _mvp;
|
||||
|
||||
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||
struct Matrix* dst = type == MATRIX_PROJECTION ? &_proj : &_view;
|
||||
*dst = *matrix;
|
||||
|
||||
struct Matrix combined;
|
||||
Matrix_Mul(&combined, &_view, &_proj);
|
||||
|
||||
static void UpdateVSConstants(void) {
|
||||
uint32_t* p;
|
||||
p = pb_begin();
|
||||
|
||||
|
@ -556,11 +551,11 @@ void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
|||
p = pb_push1(p, NV097_SET_TRANSFORM_CONSTANT_LOAD, 96);
|
||||
|
||||
// upload transformation matrix
|
||||
pb_push(p++, NV097_SET_TRANSFORM_CONSTANT, 4*4 + 4);
|
||||
Mem_Copy(p, &combined, 16 * 4); p += 16;
|
||||
pb_push(p++, NV097_SET_TRANSFORM_CONSTANT, 4*4 + 4 + 4);
|
||||
Mem_Copy(p, &_mvp, 16 * 4); p += 16;
|
||||
// Upload viewport too
|
||||
struct Vec4 viewport = { 320, 240, 8388608, 1 };
|
||||
Mem_Copy(p, &viewport, 4 * 4); p += 4;
|
||||
Mem_Copy(p, &vp_scale, 4 * 4); p += 4;
|
||||
Mem_Copy(p, &vp_offset, 4 * 4); p += 4;
|
||||
// Upload constants too
|
||||
//struct Vec4 v = { 1, 1, 1, 1 };
|
||||
//Mem_Copy(p, &v, 4 * 4); p += 4;
|
||||
|
@ -569,6 +564,14 @@ void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
|||
pb_end(p);
|
||||
}
|
||||
|
||||
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||
struct Matrix* dst = type == MATRIX_PROJECTION ? &_proj : &_view;
|
||||
*dst = *matrix;
|
||||
|
||||
Matrix_Mul(&_mvp, &_view, &_proj);
|
||||
UpdateVSConstants();
|
||||
}
|
||||
|
||||
void Gfx_LoadIdentityMatrix(MatrixType type) {
|
||||
Gfx_LoadMatrix(type, &Matrix_Identity);
|
||||
}
|
||||
|
@ -579,6 +582,20 @@ void Gfx_EnableTextureOffset(float x, float y) {
|
|||
void Gfx_DisableTextureOffset(void) {
|
||||
}
|
||||
|
||||
void Gfx_SetViewport(int x, int y, int w, int h) {
|
||||
vp_scale.x = w * 0.5f;
|
||||
vp_scale.y = h * -0.5f;
|
||||
vp_offset.x = x + w * 0.5f;
|
||||
vp_offset.y = y + h * 0.5f;
|
||||
|
||||
uint32_t* p;
|
||||
p = pb_begin();
|
||||
// NV097_SET_SURFACE_CLIP_HORIZONTAL followed by NV097_SET_SURFACE_CLIP_VERTICAL
|
||||
p = pb_push2(p, NV097_SET_SURFACE_CLIP_HORIZONTAL, x | (w << 16), y | (h << 16));
|
||||
pb_end(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
|
|
Loading…
Reference in a new issue