mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Wii U WIP stuff
This commit is contained in:
parent
44ce6561ea
commit
8c78f66cc5
2 changed files with 301 additions and 28 deletions
286
src/Graphics_WiiU.c
Normal file
286
src/Graphics_WiiU.c
Normal file
|
@ -0,0 +1,286 @@
|
|||
#include "Core.h"
|
||||
#ifdef CC_BUILD_WIIU
|
||||
#include "_GraphicsBase.h"
|
||||
#include "Errors.h"
|
||||
#include "Window.h"
|
||||
#include <gx2r/buffer.h>
|
||||
|
||||
void Gfx_Create(void) {
|
||||
|
||||
Gfx.Created = true;
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
}
|
||||
|
||||
cc_bool Gfx_TryRestoreContext(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Gfx_Free(void) {
|
||||
Gfx_FreeState();
|
||||
}
|
||||
|
||||
static void Gfx_FreeState(void) {
|
||||
FreeDefaultResources();
|
||||
}
|
||||
|
||||
static void Gfx_RestoreState(void) {
|
||||
Gfx_SetFaceCulling(false);
|
||||
InitDefaultResources();
|
||||
gfx_format = -1;
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||
return (void*)1;
|
||||
}
|
||||
|
||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||
}
|
||||
|
||||
void Gfx_UpdateTexturePart(GfxResourceID texId, int x, int y, struct Bitmap* part, cc_bool mipmaps) {
|
||||
}
|
||||
|
||||
void Gfx_BindTexture(GfxResourceID texId) {
|
||||
}
|
||||
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
}
|
||||
|
||||
void Gfx_SetTexturing(cc_bool enabled) { }
|
||||
|
||||
void Gfx_EnableMipmaps(void) { } // TODO
|
||||
|
||||
void Gfx_DisableMipmaps(void) { } // TODO
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------State management----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||
}
|
||||
|
||||
void Gfx_SetFog(cc_bool enabled) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_SetFogCol(PackedCol color) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_SetFogDensity(float value) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_SetFogEnd(float value) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_SetFogMode(FogFunc func) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_SetAlphaTest(cc_bool enabled) {
|
||||
}
|
||||
|
||||
void Gfx_SetAlphaBlending(cc_bool enabled) {
|
||||
}
|
||||
|
||||
void Gfx_SetAlphaArgBlend(cc_bool enabled) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_ClearCol(PackedCol color) {
|
||||
}
|
||||
|
||||
void Gfx_SetColWriteMask(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_SetDepthTest(cc_bool enabled) {
|
||||
}
|
||||
|
||||
void Gfx_SetDepthWrite(cc_bool enabled) {
|
||||
}
|
||||
|
||||
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------Index buffers-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
GfxResourceID Gfx_CreateIb2(int count, Gfx_FillIBFunc fillFunc, void* obj) {
|
||||
return (void*)1; // don't need index buffers.. ?
|
||||
}
|
||||
|
||||
void Gfx_BindIb(GfxResourceID ib) {
|
||||
}
|
||||
|
||||
void Gfx_DeleteIb(GfxResourceID* ib) {
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Vertex buffers-----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static GfxResourceID Gfx_AllocStaticVb(VertexFormat fmt, int count) {
|
||||
GX2RBuffer* buf = Mem_TryAllocCleared(1, sizeof(GX2RBuffer));
|
||||
if (!buf) return NULL;
|
||||
|
||||
buf->flags = GX2R_RESOURCE_BIND_VERTEX_BUFFER | GX2R_RESOURCE_USAGE_CPU_READ | GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ;
|
||||
buf->elemSize = strideSizes[fmt];
|
||||
buf->elemCount = count;
|
||||
|
||||
if (GX2RCreateBuffer(buf)) return buf;
|
||||
// Something went wrong ?? TODO
|
||||
Mem_Free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Gfx_DeleteVb(GfxResourceID* vb) {
|
||||
GX2RBuffer* buf = *vb;
|
||||
if (!buf) return;
|
||||
|
||||
GX2RDestroyBufferEx(buf, 0);
|
||||
Mem_Free(buf);
|
||||
*vb = NULL;
|
||||
}
|
||||
|
||||
void Gfx_BindVb(GfxResourceID vb) {
|
||||
}
|
||||
|
||||
void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
||||
GX2RBuffer* buf = (GX2RBuffer*)vb;
|
||||
return GX2RLockBufferEx(buf, 0);
|
||||
}
|
||||
|
||||
void Gfx_UnlockVb(GfxResourceID vb) {
|
||||
GX2RBuffer* buf = (GX2RBuffer*)vb;
|
||||
GX2RUnlockBufferEx(buf, 0);
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*--------------------------------------------------Dynamic vertex buffers-------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices) {
|
||||
return Gfx_AllocStaticVb(fmt, maxVertices);
|
||||
}
|
||||
|
||||
void Gfx_DeleteDynamicVb(GfxResourceID* vb) { Gfx_DeleteVb(vb); }
|
||||
|
||||
void Gfx_BindDynamicVb(GfxResourceID vb) { Gfx_BindVb(vb); }
|
||||
|
||||
void* Gfx_LockDynamicVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
||||
return Gfx_LockVb(vb, fmt, count);
|
||||
}
|
||||
|
||||
void Gfx_UnlockDynamicVb(GfxResourceID vb) { Gfx_UnlockVb(vb); }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Vertex rendering----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
||||
}
|
||||
|
||||
void Gfx_DrawVb_Lines(int verticesCount) {
|
||||
}
|
||||
|
||||
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
||||
}
|
||||
|
||||
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
||||
}
|
||||
|
||||
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_LoadIdentityMatrix(MatrixType type) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_EnableTextureOffset(float x, float y) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_DisableTextureOffset(void) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Gfx_CalcOrthoMatrix(struct Matrix* matrix, float width, float height, float zNear, float zFar) {
|
||||
// TODO verify this
|
||||
*matrix = Matrix_Identity;
|
||||
|
||||
matrix->row1.x = 2.0f / width;
|
||||
matrix->row2.y = -2.0f / height;
|
||||
matrix->row3.z = 1.0f / (zNear - zFar);
|
||||
|
||||
matrix->row4.x = -1.0f;
|
||||
matrix->row4.y = 1.0f;
|
||||
matrix->row4.z = zNear / (zNear - zFar);
|
||||
}
|
||||
|
||||
static double Cotangent(double x) { return Math_Cos(x) / Math_Sin(x); }
|
||||
void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, float zFar) {
|
||||
// TODO verify this
|
||||
float zNear = 0.1f;
|
||||
float c = (float)Cotangent(0.5f * fov);
|
||||
*matrix = Matrix_Identity;
|
||||
|
||||
matrix->row1.x = c / aspect;
|
||||
matrix->row2.y = c;
|
||||
matrix->row3.z = zFar / (zNear - zFar);
|
||||
matrix->row3.w = -1.0f;
|
||||
matrix->row4.z = (zNear * zFar) / (zNear - zFar);
|
||||
matrix->row4.w = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------------Misc----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
cc_result Gfx_TakeScreenshot(struct Stream* output) {
|
||||
return ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
gfx_minFrameMs = minFrameMs;
|
||||
gfx_vsync = vsync;
|
||||
}
|
||||
|
||||
void Gfx_BeginFrame(void) {
|
||||
}
|
||||
|
||||
void Gfx_Clear(void) {
|
||||
}
|
||||
|
||||
void Gfx_EndFrame(void) {
|
||||
|
||||
if (gfx_minFrameMs) LimitFPS();
|
||||
}
|
||||
|
||||
cc_bool Gfx_WarnIfNecessary(void) { return false; }
|
||||
|
||||
void Gfx_GetApiInfo(cc_string* info) {
|
||||
String_AppendConst(info, "-- Using Wii U --\n");
|
||||
PrintMaxTextureInfo(info);
|
||||
}
|
||||
|
||||
void Gfx_OnWindowResize(void) {
|
||||
|
||||
}
|
||||
#endif
|
|
@ -30,11 +30,13 @@
|
|||
#include <stdio.h>
|
||||
#include <poll.h>
|
||||
#include <netdb.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <coreinit/event.h>
|
||||
#include <coreinit/fastmutex.h>
|
||||
#include <coreinit/thread.h>
|
||||
#include <coreinit/systeminfo.h>
|
||||
#include <coreinit/time.h>
|
||||
#include <whb/proc.h>
|
||||
#include "_PlatformConsole.h"
|
||||
|
||||
const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */
|
||||
|
@ -56,21 +58,22 @@ void Platform_Log(const char* msg, int len) {
|
|||
|
||||
OSReport("%s\n", tmp);
|
||||
}
|
||||
#define WIIU_EPOCH_ADJUST 946684800000ULL // Wii U time epoch is year 2000, not 1970
|
||||
|
||||
#define UnixTime_TotalMS(time) ((cc_uint64)time.tv_sec * 1000 + UNIX_EPOCH + (time.tv_usec / 1000))
|
||||
TimeMS DateTime_CurrentUTC_MS(void) {
|
||||
struct timeval cur;
|
||||
gettimeofday(&cur, NULL);
|
||||
return UnixTime_TotalMS(cur);
|
||||
OSTime time = OSGetTime();
|
||||
// avoid overflow in time calculation
|
||||
cc_int64 secs = (time_t)OSTicksToSeconds(time);
|
||||
time -= OSSecondsToTicks(secs);
|
||||
cc_uint64 msecs = OSTicksToMilliseconds(time);
|
||||
return (secs * 1000 + msecs) + UNIX_EPOCH + WIIU_EPOCH_ADJUST;
|
||||
}
|
||||
|
||||
void DateTime_CurrentLocal(struct DateTime* t) {
|
||||
struct timeval cur;
|
||||
struct tm loc_time;
|
||||
gettimeofday(&cur, NULL);
|
||||
localtime_r(&cur.tv_sec, &loc_time);
|
||||
struct OSCalendarTime loc_time;
|
||||
OSTicksToCalendarTime(OSGetTime(), &loc_time);
|
||||
|
||||
t->year = loc_time.tm_year + 1900;
|
||||
t->year = loc_time.tm_year;
|
||||
t->month = loc_time.tm_mon + 1;
|
||||
t->day = loc_time.tm_mday;
|
||||
t->hour = loc_time.tm_hour;
|
||||
|
@ -83,7 +86,7 @@ void DateTime_CurrentLocal(struct DateTime* t) {
|
|||
*--------------------------------------------------------Stopwatch--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
cc_uint64 Stopwatch_Measure(void) {
|
||||
return OSGetSystemTime(); // TODO OSGetTick ??
|
||||
return OSGetSystemTime(); // TODO OSGetSystemTick ??
|
||||
}
|
||||
|
||||
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
||||
|
@ -304,14 +307,9 @@ void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) {
|
|||
*#########################################################################################################################*/
|
||||
union SocketAddress {
|
||||
struct sockaddr raw;
|
||||
struct sockaddr_in v4;
|
||||
#ifdef AF_INET6
|
||||
struct sockaddr_in6 v6;
|
||||
struct sockaddr_in v4;
|
||||
struct sockaddr_storage total;
|
||||
#endif
|
||||
};
|
||||
/* Sanity check to ensure cc_sockaddr struct is large enough to contain all socket addresses supported by this platform */
|
||||
static char sockaddr_size_check[sizeof(union SocketAddress) < CC_SOCKETADDR_MAXSIZE ? 1 : -1];
|
||||
|
||||
static cc_result ParseHost(const char* host, int port, cc_sockaddr* addrs, int* numValidAddrs) {
|
||||
char portRaw[32]; cc_string portStr;
|
||||
|
@ -332,6 +330,7 @@ static cc_result ParseHost(const char* host, int port, cc_sockaddr* addrs, int*
|
|||
if (res) return res;
|
||||
|
||||
/* Prefer IPv4 addresses first */
|
||||
// TODO: Wii U has no ipv6 support anyways?
|
||||
for (cur = result; cur && i < SOCKET_MAX_ADDRS; cur = cur->ai_next)
|
||||
{
|
||||
if (cur->ai_family != AF_INET) continue;
|
||||
|
@ -366,18 +365,6 @@ cc_result Socket_ParseAddress(const cc_string* address, int port, cc_sockaddr* a
|
|||
*numValidAddrs = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef AF_INET6
|
||||
if (inet_pton(AF_INET6, str, &addr->v6.sin6_addr) > 0) {
|
||||
addr->v6.sin6_family = AF_INET6;
|
||||
addr->v6.sin6_port = htons(port);
|
||||
|
||||
addrs[0].size = sizeof(addr->v6);
|
||||
*numValidAddrs = 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ParseHost(str, port, addrs, numValidAddrs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue