mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
Xbox: Fix coloured only vertices not being rendered
This commit is contained in:
parent
14d076c21d
commit
63aa34d2c2
@ -19,14 +19,14 @@ vOut main(
|
|||||||
|
|
||||||
position = float4(input.position.xyz, 1.0f);
|
position = float4(input.position.xyz, 1.0f);
|
||||||
position = mul(position, mvp);
|
position = mul(position, mvp);
|
||||||
//position.xyz = position.xyz / position.w;
|
position.xyz = position.xyz / position.w;
|
||||||
|
|
||||||
position.x = position.x * half_viewport.x + half_viewport.x;
|
position.x = position.x * half_viewport.x + half_viewport.x;
|
||||||
position.y = -position.y * half_viewport.y + half_viewport.y;
|
position.y = -position.y * half_viewport.y + half_viewport.y;
|
||||||
position.z = position.z * half_viewport.z + half_viewport.z;
|
position.z = position.z * half_viewport.z + half_viewport.z;
|
||||||
position.w = half_viewport.w;
|
//position.w = 1.0 / half_viewport.w;
|
||||||
|
|
||||||
result.col = input.color;
|
|
||||||
result.pos = position;
|
result.pos = position;
|
||||||
|
result.col = input.color;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
@ -28,8 +28,8 @@ vOut main(
|
|||||||
position.z = position.z * half_viewport.z + half_viewport.z;
|
position.z = position.z * half_viewport.z + half_viewport.z;
|
||||||
//position.w = 1.0 / half_viewport.w;
|
//position.w = 1.0 / half_viewport.w;
|
||||||
|
|
||||||
result.col = input.color;
|
|
||||||
result.pos = position;
|
result.pos = position;
|
||||||
|
result.col = input.color;
|
||||||
result.tex = input.tex;
|
result.tex = input.tex;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
@ -21,6 +21,7 @@
|
|||||||
// Current format and size of vertices
|
// Current format and size of vertices
|
||||||
static int gfx_stride, gfx_format = -1;
|
static int gfx_stride, gfx_format = -1;
|
||||||
|
|
||||||
|
|
||||||
static void LoadVertexShader(uint32_t* program, int programSize) {
|
static void LoadVertexShader(uint32_t* program, int programSize) {
|
||||||
uint32_t* p;
|
uint32_t* p;
|
||||||
|
|
||||||
@ -40,7 +41,23 @@ static void LoadVertexShader(uint32_t* program, int programSize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadFragmentShader(void) {
|
static uint32_t vs_coloured_program[] = {
|
||||||
|
#include "../misc/xbox/vs_coloured.inl"
|
||||||
|
};
|
||||||
|
static uint32_t vs_textured_program[] = {
|
||||||
|
#include "../misc/xbox/vs_textured.inl"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void LoadFragmentShader_Coloured(void) {
|
||||||
|
uint32_t* p;
|
||||||
|
|
||||||
|
p = pb_begin();
|
||||||
|
#include "../misc/xbox/ps_coloured.inl"
|
||||||
|
pb_end(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void LoadFragmentShader_Textured(void) {
|
||||||
uint32_t* p;
|
uint32_t* p;
|
||||||
|
|
||||||
p = pb_begin();
|
p = pb_begin();
|
||||||
@ -48,12 +65,6 @@ static void LoadFragmentShader(void) {
|
|||||||
pb_end(p);
|
pb_end(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t vs_coloured_program[] = {
|
|
||||||
#include "../misc/xbox/vs_colored.inl"
|
|
||||||
};
|
|
||||||
static uint32_t vs_textured_program[] = {
|
|
||||||
#include "../misc/xbox/vs_textured.inl"
|
|
||||||
};
|
|
||||||
|
|
||||||
static void SetupShaders(void) {
|
static void SetupShaders(void) {
|
||||||
uint32_t *p;
|
uint32_t *p;
|
||||||
@ -109,7 +120,7 @@ void Gfx_Create(void) {
|
|||||||
pb_show_front_screen();
|
pb_show_front_screen();
|
||||||
|
|
||||||
SetupShaders();
|
SetupShaders();
|
||||||
LoadFragmentShader();
|
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
||||||
ResetState();
|
ResetState();
|
||||||
|
|
||||||
// 1x1 dummy white texture
|
// 1x1 dummy white texture
|
||||||
@ -612,8 +623,10 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {
|
|||||||
|
|
||||||
if (fmt == VERTEX_FORMAT_TEXTURED) {
|
if (fmt == VERTEX_FORMAT_TEXTURED) {
|
||||||
LoadVertexShader(vs_textured_program, sizeof(vs_textured_program));
|
LoadVertexShader(vs_textured_program, sizeof(vs_textured_program));
|
||||||
|
LoadFragmentShader_Textured();
|
||||||
} else {
|
} else {
|
||||||
LoadVertexShader(vs_coloured_program, sizeof(vs_coloured_program));
|
LoadVertexShader(vs_coloured_program, sizeof(vs_coloured_program));
|
||||||
|
LoadFragmentShader_Coloured();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,8 +658,6 @@ void Gfx_DrawVb_Lines(int verticesCount) {
|
|||||||
#define MAX_BATCH 120
|
#define MAX_BATCH 120
|
||||||
static void DrawIndexedVertices(int verticesCount, int startVertex) {
|
static void DrawIndexedVertices(int verticesCount, int startVertex) {
|
||||||
// TODO switch to indexed rendering
|
// TODO switch to indexed rendering
|
||||||
if (gfx_format == VERTEX_FORMAT_COLOURED) return;
|
|
||||||
// TODO REMOVE REMOVE REMOVE
|
|
||||||
DrawArrays(NV097_SET_BEGIN_END_OP_QUADS, startVertex, verticesCount);
|
DrawArrays(NV097_SET_BEGIN_END_OP_QUADS, startVertex, verticesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ XBE_TITLE = ClassiCube
|
|||||||
GEN_XISO = $(XBE_TITLE).iso
|
GEN_XISO = $(XBE_TITLE).iso
|
||||||
SRCS = $(wildcard src/*.c)
|
SRCS = $(wildcard src/*.c)
|
||||||
NXDK_DIR = /home/test/Downloads/nxdk
|
NXDK_DIR = /home/test/Downloads/nxdk
|
||||||
SHADER_OBJS = misc/xbox/vs_colored.inl misc/xbox/ps_colored.inl
|
SHADER_OBJS = misc/xbox/vs_coloured.inl misc/xbox/vs_textured.inl misc/xbox/ps_coloured.inl misc/xbox/ps_textured.inl
|
||||||
NXDK_NET = y
|
NXDK_NET = y
|
||||||
NXDK_LDFLAGS = -stack:131072
|
NXDK_LDFLAGS = -stack:131072
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ Copyright 2014-2023 ClassiCube | Licensed under BSD-3
|
|||||||
struct DateTime;
|
struct DateTime;
|
||||||
|
|
||||||
enum Socket_PollMode { SOCKET_POLL_READ, SOCKET_POLL_WRITE };
|
enum Socket_PollMode { SOCKET_POLL_READ, SOCKET_POLL_WRITE };
|
||||||
#ifdef CC_BUILD_WIN
|
#if defined CC_BUILD_WIN || defined CC_BUILD_XBOX
|
||||||
typedef cc_uintptr cc_socket;
|
typedef cc_uintptr cc_socket;
|
||||||
typedef void* cc_file;
|
typedef void* cc_file;
|
||||||
#define _NL "\r\n"
|
#define _NL "\r\n"
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
|
const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
|
||||||
const cc_result ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
|
const cc_result ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
|
||||||
const cc_result ReturnCode_SocketInProgess = WSAEINPROGRESS;
|
const cc_result ReturnCode_SocketInProgess = EINPROGRESS;
|
||||||
const cc_result ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK;
|
const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK;
|
||||||
const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS;
|
const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS;
|
||||||
const char* Platform_AppNameSuffix = " XBox";
|
const char* Platform_AppNameSuffix = " XBox";
|
||||||
|
|
||||||
@ -306,80 +306,82 @@ static int ParseHost(union SocketAddress* addr, const char* host) {
|
|||||||
struct addrinfo hints = { 0 };
|
struct addrinfo hints = { 0 };
|
||||||
struct addrinfo* result;
|
struct addrinfo* result;
|
||||||
struct addrinfo* cur;
|
struct addrinfo* cur;
|
||||||
int family = 0, res;
|
int found = 0, res;
|
||||||
|
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_protocol = IPPROTO_TCP;
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
|
||||||
res = getaddrinfo(host, NULL, &hints, &result);
|
res = lwip_getaddrinfo(host, NULL, &hints, &result);
|
||||||
if (res) return 0;
|
if (res) return res;
|
||||||
|
|
||||||
for (cur = result; cur; cur = cur->ai_next) {
|
for (cur = result; cur; cur = cur->ai_next) {
|
||||||
if (cur->ai_family != AF_INET) continue;
|
if (cur->ai_family != AF_INET) continue;
|
||||||
family = AF_INET;
|
found = true;
|
||||||
|
|
||||||
Mem_Copy(addr, cur->ai_addr, cur->ai_addrlen);
|
Mem_Copy(addr, cur->ai_addr, cur->ai_addrlen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(result);
|
lwip_freeaddrinfo(result);
|
||||||
return family;
|
return found ? 0 : ERR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ParseAddress(union SocketAddress* addr, const cc_string* address) {
|
static int ParseAddress(union SocketAddress* addr, const cc_string* address) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
String_EncodeUtf8(str, address);
|
String_EncodeUtf8(str, address);
|
||||||
|
|
||||||
if (inet_pton(AF_INET, str, &addr->v4.sin_addr) > 0) return AF_INET;
|
if (inet_pton(AF_INET, str, &addr->v4.sin_addr) > 0) return 0;
|
||||||
return ParseHost(addr, str);
|
return ParseHost(addr, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Socket_ValidAddress(const cc_string* address) {
|
int Socket_ValidAddress(const cc_string* address) {
|
||||||
union SocketAddress addr;
|
union SocketAddress addr;
|
||||||
return ParseAddress(&addr, address);
|
return ParseAddress(&addr, address) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_Connect(cc_socket* s, const cc_string* address, int port, cc_bool nonblocking) {
|
cc_result Socket_Connect(cc_socket* s, const cc_string* address, int port, cc_bool nonblocking) {
|
||||||
int family, addrSize = 0;
|
int family, addrSize = 0;
|
||||||
union SocketAddress addr;
|
union SocketAddress addr;
|
||||||
cc_result res;
|
int res;
|
||||||
|
// TODO TODO TODO TODO TODO
|
||||||
|
// if 'addrSize = 0' is removed, then the game never gets past 'Fetching cdn.classicube.net...'
|
||||||
|
// so probably relying on undefined behaviour somewhere...
|
||||||
|
|
||||||
*s = -1;
|
*s = -1;
|
||||||
if (!(family = ParseAddress(&addr, address)))
|
res = ParseAddress(&addr, address);
|
||||||
return ERR_INVALID_ARGUMENT;
|
if (res) return res;
|
||||||
|
|
||||||
*s = socket(family, SOCK_STREAM, IPPROTO_TCP);
|
*s = lwip_socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (*s == -1) return errno;
|
if (*s == -1) return errno;
|
||||||
|
|
||||||
if (nonblocking) {
|
if (nonblocking) {
|
||||||
int blocking_raw = -1; /* non-blocking mode */
|
int blocking_raw = -1; /* non-blocking mode */
|
||||||
ioctl(*s, FIONBIO, &blocking_raw);
|
lwip_ioctl(*s, FIONBIO, &blocking_raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
addr.v4.sin_family = AF_INET;
|
addr.v4.sin_family = AF_INET;
|
||||||
addr.v4.sin_port = htons(port);
|
addr.v4.sin_port = htons(port);
|
||||||
addrSize = sizeof(addr.v4);
|
|
||||||
|
|
||||||
res = connect(*s, &addr.raw, addrSize);
|
res = lwip_connect(*s, &addr.raw, sizeof(addr.v4));
|
||||||
return res == -1 ? errno : 0;
|
return res == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
cc_result Socket_Read(cc_socket s, cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
||||||
int recvCount = recv(s, data, count, 0);
|
int recvCount = lwip_recv(s, data, count, 0);
|
||||||
if (recvCount != -1) { *modified = recvCount; return 0; }
|
if (recvCount != -1) { *modified = recvCount; return 0; }
|
||||||
*modified = 0; return errno;
|
*modified = 0; return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_Write(cc_socket s, const cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
cc_result Socket_Write(cc_socket s, const cc_uint8* data, cc_uint32 count, cc_uint32* modified) {
|
||||||
int sentCount = send(s, data, count, 0);
|
int sentCount = lwip_send(s, data, count, 0);
|
||||||
if (sentCount != -1) { *modified = sentCount; return 0; }
|
if (sentCount != -1) { *modified = sentCount; return 0; }
|
||||||
*modified = 0; return errno;
|
*modified = 0; return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket_Close(cc_socket s) {
|
void Socket_Close(cc_socket s) {
|
||||||
shutdown(s, SHUT_RDWR);
|
lwip_shutdown(s, SHUT_RDWR);
|
||||||
close(s);
|
lwip_close(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
||||||
@ -388,7 +390,7 @@ static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
|||||||
|
|
||||||
pfd.fd = s;
|
pfd.fd = s;
|
||||||
pfd.events = mode == SOCKET_POLL_READ ? POLLIN : POLLOUT;
|
pfd.events = mode == SOCKET_POLL_READ ? POLLIN : POLLOUT;
|
||||||
if (poll(&pfd, 1, 0) == -1) { *success = false; return errno; }
|
if (lwip_poll(&pfd, 1, 0) == -1) { *success = false; return errno; }
|
||||||
|
|
||||||
/* to match select, closed socket still counts as readable */
|
/* to match select, closed socket still counts as readable */
|
||||||
flags = mode == SOCKET_POLL_READ ? (POLLIN | POLLHUP) : POLLOUT;
|
flags = mode == SOCKET_POLL_READ ? (POLLIN | POLLHUP) : POLLOUT;
|
||||||
@ -406,7 +408,7 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
if (res || *writable) return res;
|
if (res || *writable) return res;
|
||||||
|
|
||||||
/* https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation */
|
/* https://stackoverflow.com/questions/29479953/so-error-value-after-successful-socket-operation */
|
||||||
getsockopt(s, SOL_SOCKET, SO_ERROR, &res, &resultSize);
|
lwip_getsockopt(s, SOL_SOCKET, SO_ERROR, &res, &resultSize);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +423,7 @@ cc_result Process_StartOpen(const cc_string* args) {
|
|||||||
static void InitHDD(void) {
|
static void InitHDD(void) {
|
||||||
hdd_mounted = nxMountDrive('E', "\\Device\\Harddisk0\\Partition1\\");
|
hdd_mounted = nxMountDrive('E', "\\Device\\Harddisk0\\Partition1\\");
|
||||||
if (!hdd_mounted) {
|
if (!hdd_mounted) {
|
||||||
Platform_LogConst("Failed to mount E:\ from Data partition");
|
Platform_LogConst("Failed to mount E:/ from Data partition");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Directory_Create(&String_Empty); // create root ClassiCube folder
|
Directory_Create(&String_Empty); // create root ClassiCube folder
|
||||||
|
Loading…
x
Reference in New Issue
Block a user