mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-20 14:11:16 +00:00
its been awhile (no actions today)
This commit is contained in:
parent
1abee1eee3
commit
ac0eaae17f
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.25...4.0 FATAL_ERROR)
|
|||||||
project(isle LANGUAGES CXX C VERSION 0.1)
|
project(isle LANGUAGES CXX C VERSION 0.1)
|
||||||
|
|
||||||
if(WIIU)
|
if(WIIU)
|
||||||
add_library(libstdc_WiiU STATIC IMPORTED)
|
add_library(libstdc_WiiU STATIC IMPORTED)
|
||||||
set_target_properties(libstdc_WiiU PROPERTIES
|
set_target_properties(libstdc_WiiU PROPERTIES
|
||||||
IMPORTED_LOCATION /opt/devkitpro/devkitPPC/powerpc-eabi/lib/libstdc++.a
|
IMPORTED_LOCATION /opt/devkitpro/devkitPPC/powerpc-eabi/lib/libstdc++.a
|
||||||
INTERFACE_INCLUDE_DIRECTORIES /opt/devkitpro/devkitPPC/powerpc-eabi/include/c++/15.1.0
|
INTERFACE_INCLUDE_DIRECTORIES /opt/devkitpro/devkitPPC/powerpc-eabi/include/c++/15.1.0
|
||||||
@ -597,6 +597,9 @@ if (ISLE_BUILD_APP)
|
|||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(isle PRIVATE winmm)
|
target_link_libraries(isle PRIVATE winmm)
|
||||||
endif()
|
endif()
|
||||||
|
if (WIIU)
|
||||||
|
target_sources(isle PRIVATE 3rdparty/atomic-dummy/atomic.c)
|
||||||
|
endif()
|
||||||
# Link LEGO1
|
# Link LEGO1
|
||||||
target_link_libraries(isle PRIVATE lego1)
|
target_link_libraries(isle PRIVATE lego1)
|
||||||
if(ISLE_DEBUG)
|
if(ISLE_DEBUG)
|
||||||
@ -649,7 +652,7 @@ if (ISLE_BUILD_APP)
|
|||||||
endif()
|
endif()
|
||||||
if (WIIU)
|
if (WIIU)
|
||||||
target_sources(isle PRIVATE
|
target_sources(isle PRIVATE
|
||||||
ISLE/wiiu/config.cpp
|
ISLE/wiiu/config.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(Python3_FOUND)
|
if(Python3_FOUND)
|
||||||
|
|||||||
@ -294,13 +294,6 @@ void IsleApp::SetupVideoFlags(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WUT__
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
||||||
{
|
{
|
||||||
*appstate = NULL;
|
*appstate = NULL;
|
||||||
|
|||||||
@ -90,6 +90,14 @@ if(NINTENDO_3DS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WIIU)
|
||||||
|
message(STATUS "Enabling GX2 renderer")
|
||||||
|
target_sources(miniwin PRIVATE src/d3drm/backends/gx2/renderer.cpp)
|
||||||
|
list(APPEND GRAPHICS_BACKENDS USE_GX2)
|
||||||
|
else()
|
||||||
|
message(STATUS "🧩 GX2 support not enabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32 AND NOT WINDOWS_STORE)
|
if(WIN32 AND NOT WINDOWS_STORE)
|
||||||
target_sources(miniwin PRIVATE
|
target_sources(miniwin PRIVATE
|
||||||
src/d3drm/backends/directx9/actual.cpp
|
src/d3drm/backends/directx9/actual.cpp
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
|
#include "d3drmrenderer_gx2.h"
|
||||||
#include <coreinit/systeminfo.h>
|
#include <coreinit/systeminfo.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <coreinit/time.h>
|
#include <coreinit/time.h>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <gfd.h>
|
#include <gfd.h>
|
||||||
#include <gx2/draw.h>
|
#include <gx2/draw.h>
|
||||||
#include <gx2/mem.h>
|
#include <gx2/mem.h>
|
||||||
@ -12,98 +10,124 @@
|
|||||||
#include <whb/proc.h>
|
#include <whb/proc.h>
|
||||||
#include <whb/sdcard.h>
|
#include <whb/sdcard.h>
|
||||||
|
|
||||||
struct IsleGX2Backend {
|
#ifndef D3D_OK
|
||||||
GX2RBuffer positionBuffer;
|
#define D3D_OK S_OK
|
||||||
GX2RBuffer colourBuffer;
|
#endif
|
||||||
WHBGfxShaderGroup shaderGroup;
|
|
||||||
bool rendering = false;
|
|
||||||
|
|
||||||
void Init(const char* shaderPath)
|
static struct IsleGX2Backend {
|
||||||
{
|
bool initialized = false;
|
||||||
WHBLogUdpInit();
|
bool rendering = false;
|
||||||
WHBProcInit();
|
|
||||||
WHBGfxInit();
|
|
||||||
WHBMountSdCard();
|
|
||||||
char path[256];
|
|
||||||
sprintf(path, "%s/%s", WHBGetSdCardMountPath(), shaderPath);
|
|
||||||
FILE* f = fopen(path, "rb");
|
|
||||||
if (!f) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
size_t fsize = ftell(f);
|
|
||||||
rewind(f);
|
|
||||||
char* data = (char*) malloc(fsize);
|
|
||||||
fread(data, 1, fsize, f);
|
|
||||||
WHBGfxLoadGFDShaderGroup(&shaderGroup, 0, data);
|
|
||||||
free(data);
|
|
||||||
WHBGfxInitShaderAttribute(&shaderGroup, "aPosition", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32);
|
|
||||||
WHBGfxInitShaderAttribute(&shaderGroup, "aColour", 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32_32);
|
|
||||||
WHBGfxInitFetchShader(&shaderGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartFrame()
|
void Init(const char* shaderPath)
|
||||||
{
|
{
|
||||||
if (rendering) {
|
if (initialized) return;
|
||||||
return;
|
WHBLogUdpInit();
|
||||||
}
|
WHBProcInit();
|
||||||
WHBGfxBeginRender();
|
WHBGfxInit();
|
||||||
WHBGfxBeginRenderTV();
|
WHBMountSdCard();
|
||||||
rendering = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndFrame()
|
void StartFrame()
|
||||||
{
|
{
|
||||||
if (!rendering) {
|
if (rendering) return;
|
||||||
return;
|
WHBGfxBeginRender();
|
||||||
}
|
WHBGfxBeginRenderTV();
|
||||||
WHBGfxFinishRenderTV();
|
rendering = true;
|
||||||
WHBGfxBeginRenderDRC();
|
}
|
||||||
WHBGfxFinishRenderDRC();
|
|
||||||
WHBGfxFinishRender();
|
|
||||||
rendering = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clear(float r, float g, float b)
|
void EndFrame()
|
||||||
{
|
{
|
||||||
StartFrame();
|
if (!rendering) return;
|
||||||
WHBGfxClearColor(r, g, b, 1.0f);
|
WHBGfxFinishRenderTV();
|
||||||
}
|
WHBGfxBeginRenderDRC();
|
||||||
|
WHBGfxFinishRenderDRC();
|
||||||
|
WHBGfxFinishRender();
|
||||||
|
rendering = false;
|
||||||
|
}
|
||||||
|
|
||||||
void Flip() { EndFrame(); }
|
void Clear(float r, float g, float b)
|
||||||
|
{
|
||||||
|
StartFrame();
|
||||||
|
WHBGfxClearColor(r, g, b, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Flip()
|
||||||
{
|
{
|
||||||
WHBUnmountSdCard();
|
EndFrame();
|
||||||
WHBGfxShutdown();
|
}
|
||||||
WHBProcShutdown();
|
|
||||||
WHBLogUdpDeinit();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static IsleGX2Backend g_backend;
|
void Shutdown()
|
||||||
|
{
|
||||||
|
if (!initialized) return;
|
||||||
|
WHBUnmountSdCard();
|
||||||
|
WHBGfxShutdown();
|
||||||
|
WHBProcShutdown();
|
||||||
|
WHBLogUdpDeinit();
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void IsleBackendInit(const char* shaderPath)
|
} g_backend;
|
||||||
|
|
||||||
|
// ------------------------------------
|
||||||
|
// GX2Renderer Implementation
|
||||||
|
// ------------------------------------
|
||||||
|
|
||||||
|
GX2Renderer::GX2Renderer(DWORD width, DWORD height)
|
||||||
{
|
{
|
||||||
g_backend.Init(shaderPath);
|
m_width = width;
|
||||||
|
m_height = height;
|
||||||
|
m_virtualWidth = width;
|
||||||
|
m_virtualHeight = height;
|
||||||
|
|
||||||
|
g_backend.Init("content/renderer.gsh");
|
||||||
}
|
}
|
||||||
extern "C" void IsleBackendStartFrame()
|
|
||||||
|
GX2Renderer::~GX2Renderer()
|
||||||
{
|
{
|
||||||
g_backend.StartFrame();
|
g_backend.Shutdown();
|
||||||
}
|
}
|
||||||
extern "C" void IsleBackendEndFrame()
|
|
||||||
|
HRESULT GX2Renderer::BeginFrame()
|
||||||
{
|
{
|
||||||
g_backend.EndFrame();
|
g_backend.StartFrame();
|
||||||
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
extern "C" void IsleBackendClear(float r, float g, float b)
|
|
||||||
|
void GX2Renderer::EnableTransparency()
|
||||||
{
|
{
|
||||||
g_backend.Clear(r, g, b);
|
// GX2 blending can be configured here if needed
|
||||||
}
|
}
|
||||||
extern "C" void IsleBackendFlip()
|
|
||||||
|
HRESULT GX2Renderer::FinalizeFrame()
|
||||||
{
|
{
|
||||||
g_backend.Flip();
|
g_backend.EndFrame();
|
||||||
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
extern "C" void IsleBackendShutdown()
|
|
||||||
|
void GX2Renderer::Clear(float r, float g, float b)
|
||||||
{
|
{
|
||||||
g_backend.Shutdown();
|
g_backend.Clear(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GX2Renderer::Flip()
|
||||||
|
{
|
||||||
|
g_backend.Flip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GX2Renderer::Resize(int width, int height, const ViewportTransform& viewportTransform)
|
||||||
|
{
|
||||||
|
m_width = width;
|
||||||
|
m_height = height;
|
||||||
|
m_viewportTransform = viewportTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GX2Renderer::PushLights(const SceneLight* vertices, size_t count) {}
|
||||||
|
void GX2Renderer::SetProjection(const D3DRMMATRIX4D&, D3DVALUE, D3DVALUE) {}
|
||||||
|
void GX2Renderer::SetFrustumPlanes(const Plane*) {}
|
||||||
|
Uint32 GX2Renderer::GetTextureId(IDirect3DRMTexture*, bool, float, float) { return 0; }
|
||||||
|
Uint32 GX2Renderer::GetMeshId(IDirect3DRMMesh*, const MeshGroup*) { return 0; }
|
||||||
|
void GX2Renderer::SubmitDraw(DWORD, const D3DRMMATRIX4D&, const D3DRMMATRIX4D&, const D3DRMMATRIX4D&, const Matrix3x3&, const Appearance&) {}
|
||||||
|
void GX2Renderer::Draw2DImage(Uint32, const SDL_Rect&, const SDL_Rect&, FColor) {}
|
||||||
|
void GX2Renderer::Download(SDL_Surface*) {}
|
||||||
|
void GX2Renderer::SetDither(bool) {}
|
||||||
|
|||||||
@ -11,6 +11,9 @@
|
|||||||
#ifdef USE_CITRO3D
|
#ifdef USE_CITRO3D
|
||||||
#include "d3drmrenderer_citro3d.h"
|
#include "d3drmrenderer_citro3d.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_GX2
|
||||||
|
#include "d3drmrenderer_gx2.h"
|
||||||
|
#endif
|
||||||
#ifdef USE_DIRECTX9
|
#ifdef USE_DIRECTX9
|
||||||
#include "d3drmrenderer_directx9.h"
|
#include "d3drmrenderer_directx9.h"
|
||||||
#endif
|
#endif
|
||||||
@ -62,6 +65,11 @@ Direct3DRMRenderer* CreateDirect3DRMRenderer(
|
|||||||
return new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
return new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_GX2
|
||||||
|
if (SDL_memcmp(guid, &GX2_GUID, sizeof(GUID)) == 0) {
|
||||||
|
return new GX2Renderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef USE_DIRECTX9
|
#ifdef USE_DIRECTX9
|
||||||
if (SDL_memcmp(guid, &DirectX9_GUID, sizeof(GUID)) == 0) {
|
if (SDL_memcmp(guid, &DirectX9_GUID, sizeof(GUID)) == 0) {
|
||||||
return DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
return DirectX9Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
@ -87,6 +95,9 @@ void Direct3DRMRenderer_EnumDevices(const IDirect3DMiniwin* d3d, LPD3DENUMDEVICE
|
|||||||
#ifdef USE_CITRO3D
|
#ifdef USE_CITRO3D
|
||||||
Citro3DRenderer_EnumDevice(cb, ctx);
|
Citro3DRenderer_EnumDevice(cb, ctx);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_GX2
|
||||||
|
GX2Renderer_EnumDevice(cb, ctx);
|
||||||
|
#endif
|
||||||
#ifdef USE_DIRECTX9
|
#ifdef USE_DIRECTX9
|
||||||
DirectX9Renderer_EnumDevice(cb, ctx);
|
DirectX9Renderer_EnumDevice(cb, ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,30 +1,57 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "d3drmrenderer.h"
|
#include "d3drmrenderer.h"
|
||||||
|
#include "ddraw_impl.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <wut.h>
|
#include <wut.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
DEFINE_GUID(GX2_GUID, 0xA12B56F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x53);
|
DEFINE_GUID(GX2_GUID, 0xA12B56F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x53);
|
||||||
|
|
||||||
class GX2Renderer : public Direct3DRMRenderer {
|
class GX2Renderer : public Direct3DRMRenderer {
|
||||||
public:
|
public:
|
||||||
GX2Renderer(DWORD width, DWORD height);
|
GX2Renderer(DWORD width, DWORD height);
|
||||||
~GX2Renderer() override;
|
~GX2Renderer() override;
|
||||||
|
|
||||||
|
// --- Overrides from Direct3DRMRenderer ---
|
||||||
|
void PushLights(const SceneLight* vertices, size_t count) override;
|
||||||
|
void SetProjection(const D3DRMMATRIX4D& projection, D3DVALUE front, D3DVALUE back) override;
|
||||||
|
void SetFrustumPlanes(const Plane* frustumPlanes) override;
|
||||||
|
Uint32 GetTextureId(IDirect3DRMTexture* texture, bool isUI = false, float scaleX = 0, float scaleY = 0) override;
|
||||||
|
Uint32 GetMeshId(IDirect3DRMMesh* mesh, const MeshGroup* meshGroup) override;
|
||||||
|
HRESULT BeginFrame() override;
|
||||||
|
void EnableTransparency() override;
|
||||||
|
void SubmitDraw(
|
||||||
|
DWORD meshId,
|
||||||
|
const D3DRMMATRIX4D& modelViewMatrix,
|
||||||
|
const D3DRMMATRIX4D& worldMatrix,
|
||||||
|
const D3DRMMATRIX4D& viewMatrix,
|
||||||
|
const Matrix3x3& normalMatrix,
|
||||||
|
const Appearance& appearance
|
||||||
|
) override;
|
||||||
|
HRESULT FinalizeFrame() override;
|
||||||
|
void Resize(int width, int height, const ViewportTransform& viewportTransform) override;
|
||||||
|
void Clear(float r, float g, float b) override;
|
||||||
|
void Flip() override;
|
||||||
|
void Draw2DImage(Uint32 textureId, const SDL_Rect& srcRect, const SDL_Rect& dstRect, FColor color) override;
|
||||||
|
void Download(SDL_Surface* target) override;
|
||||||
|
void SetDither(bool dither) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- Enum device helper ---
|
||||||
inline static void GX2Renderer_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
inline static void GX2Renderer_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||||
{
|
{
|
||||||
D3DDEVICEDESC halDesc = {};
|
D3DDEVICEDESC halDesc = {};
|
||||||
halDesc.dcmColorModel = D3DCOLOR_RGB;
|
halDesc.dcmColorModel = D3DCOLOR_RGB;
|
||||||
halDesc.dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
halDesc.dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
||||||
halDesc.dwDeviceZBufferBitDepth = DDBD_24;
|
halDesc.dwDeviceZBufferBitDepth = DDBD_24;
|
||||||
halDesc.dwDeviceRenderBitDepth = DDBD_32;
|
halDesc.dwDeviceRenderBitDepth = DDBD_32;
|
||||||
halDesc.dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
halDesc.dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
||||||
halDesc.dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
halDesc.dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
||||||
halDesc.dpcTriCaps.dwTextureFilterCaps = D3DPTFILTERCAPS_LINEAR;
|
halDesc.dpcTriCaps.dwTextureFilterCaps = D3DPTFILTERCAPS_LINEAR;
|
||||||
|
|
||||||
D3DDEVICEDESC helDesc = {};
|
D3DDEVICEDESC helDesc = {};
|
||||||
|
|
||||||
EnumDevice(cb, ctx, "GX2", &halDesc, &helDesc, GX2_GUID);
|
EnumDevice(cb, ctx, "GX2", &halDesc, &helDesc, GX2_GUID);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user