mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-19 13:51:16 +00:00
Remove Citro3D init hacks
This commit is contained in:
parent
9dd3feac8e
commit
8a039a81f6
@ -48,15 +48,25 @@ static const vertex position_list[] = {
|
|||||||
int g_vertexCount = 0;
|
int g_vertexCount = 0;
|
||||||
_Static_assert(sizeof(vbo_data_pos) % 4 == 0, "vertex size not 4-byte aligned");
|
_Static_assert(sizeof(vbo_data_pos) % 4 == 0, "vertex size not 4-byte aligned");
|
||||||
|
|
||||||
static void sceneInit(void)
|
Citro3DRenderer::Citro3DRenderer(DWORD width, DWORD height)
|
||||||
{
|
{
|
||||||
// Load the vertex shader, create a shader program and bind it
|
m_width = 400;
|
||||||
|
m_height = 240;
|
||||||
|
m_virtualWidth = width;
|
||||||
|
m_virtualHeight = height;
|
||||||
|
|
||||||
|
gfxInitDefault();
|
||||||
|
consoleInit(GFX_BOTTOM, nullptr);
|
||||||
|
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||||
|
|
||||||
|
target = C3D_RenderTargetCreate(m_height, m_width, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||||
|
C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
||||||
|
|
||||||
vshader_dvlb = DVLB_ParseFile((u32*) vshader_shbin, vshader_shbin_size);
|
vshader_dvlb = DVLB_ParseFile((u32*) vshader_shbin, vshader_shbin_size);
|
||||||
shaderProgramInit(&program);
|
shaderProgramInit(&program);
|
||||||
shaderProgramSetVsh(&program, &vshader_dvlb->DVLE[0]);
|
shaderProgramSetVsh(&program, &vshader_dvlb->DVLE[0]);
|
||||||
C3D_BindProgram(&program);
|
C3D_BindProgram(&program);
|
||||||
|
|
||||||
// Get the location of the uniforms
|
|
||||||
uLoc_projection = shaderInstanceGetUniformLocation(program.vertexShader, "projection");
|
uLoc_projection = shaderInstanceGetUniformLocation(program.vertexShader, "projection");
|
||||||
uLoc_modelView = shaderInstanceGetUniformLocation(program.vertexShader, "modelView");
|
uLoc_modelView = shaderInstanceGetUniformLocation(program.vertexShader, "modelView");
|
||||||
uLoc_meshColor = shaderInstanceGetUniformLocation(program.vertexShader, "meshColor");
|
uLoc_meshColor = shaderInstanceGetUniformLocation(program.vertexShader, "meshColor");
|
||||||
@ -66,33 +76,6 @@ static void sceneInit(void)
|
|||||||
AttrInfo_AddLoader(attrInfo, 0, GPU_FLOAT, 3); // v0=position
|
AttrInfo_AddLoader(attrInfo, 0, GPU_FLOAT, 3); // v0=position
|
||||||
AttrInfo_AddLoader(attrInfo, 1, GPU_FLOAT, 2); // v1=texcoord
|
AttrInfo_AddLoader(attrInfo, 1, GPU_FLOAT, 2); // v1=texcoord
|
||||||
AttrInfo_AddLoader(attrInfo, 2, GPU_FLOAT, 3); // v2=normal
|
AttrInfo_AddLoader(attrInfo, 2, GPU_FLOAT, 3); // v2=normal
|
||||||
|
|
||||||
C3D_Mtx projection;
|
|
||||||
Mtx_OrthoTilt(&projection, 0.0, 400.0, 0.0, 240.0, 0.0, 1.0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Direct3DRMRenderer* Citro3DRenderer::Create(DWORD width, DWORD height)
|
|
||||||
{
|
|
||||||
gfxInitDefault();
|
|
||||||
consoleInit(GFX_BOTTOM, nullptr);
|
|
||||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
|
||||||
|
|
||||||
// Initialize the render target
|
|
||||||
target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
|
||||||
C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
|
|
||||||
|
|
||||||
sceneInit();
|
|
||||||
|
|
||||||
return new Citro3DRenderer(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
Citro3DRenderer::Citro3DRenderer(DWORD width, DWORD height)
|
|
||||||
{
|
|
||||||
SDL_Log("Citro3DRenderer %dx%d", width, height);
|
|
||||||
m_width = width;
|
|
||||||
m_height = height;
|
|
||||||
m_virtualWidth = width;
|
|
||||||
m_virtualHeight = height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Citro3DRenderer::~Citro3DRenderer()
|
Citro3DRenderer::~Citro3DRenderer()
|
||||||
@ -339,15 +322,6 @@ Uint32 Citro3DRenderer::GetMeshId(IDirect3DRMMesh* mesh, const MeshGroup* meshGr
|
|||||||
|
|
||||||
void Citro3DRenderer::GetDesc(D3DDEVICEDESC* halDesc, D3DDEVICEDESC* helDesc)
|
void Citro3DRenderer::GetDesc(D3DDEVICEDESC* halDesc, D3DDEVICEDESC* helDesc)
|
||||||
{
|
{
|
||||||
halDesc->dcmColorModel = D3DCOLORMODEL::RGB;
|
|
||||||
halDesc->dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
|
||||||
halDesc->dwDeviceZBufferBitDepth = DDBD_24;
|
|
||||||
halDesc->dwDeviceRenderBitDepth = DDBD_32;
|
|
||||||
halDesc->dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
|
||||||
halDesc->dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
|
||||||
halDesc->dpcTriCaps.dwTextureFilterCaps = D3DPTFILTERCAPS_LINEAR;
|
|
||||||
|
|
||||||
memset(helDesc, 0, sizeof(D3DDEVICEDESC));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Citro3DRenderer::GetName()
|
const char* Citro3DRenderer::GetName()
|
||||||
|
|||||||
@ -164,7 +164,7 @@ HRESULT Direct3DRMImpl::CreateDeviceFromSurface(
|
|||||||
#endif
|
#endif
|
||||||
#ifdef USE_CITRO3D
|
#ifdef USE_CITRO3D
|
||||||
else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = Citro3DRenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
@ -349,7 +349,7 @@ HRESULT DirectDrawImpl::CreateDevice(
|
|||||||
#endif
|
#endif
|
||||||
#ifdef USE_CITRO3D
|
#ifdef USE_CITRO3D
|
||||||
else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &Citro3D_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = Citro3DRenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = new Citro3DRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
@ -5,12 +5,11 @@
|
|||||||
#include "d3drmtexture_impl.h"
|
#include "d3drmtexture_impl.h"
|
||||||
#include "ddraw_impl.h"
|
#include "ddraw_impl.h"
|
||||||
|
|
||||||
#include <citro3d.h>
|
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <c3d/texture.h>
|
#include <citro3d.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
DEFINE_GUID(Citro3D_GUID, 0x682656F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07);
|
DEFINE_GUID(Citro3D_GUID, 0x682656F3, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x53);
|
||||||
|
|
||||||
struct C3DTextureCacheEntry {
|
struct C3DTextureCacheEntry {
|
||||||
IDirect3DRMTexture* texture;
|
IDirect3DRMTexture* texture;
|
||||||
@ -21,27 +20,23 @@ struct C3DTextureCacheEntry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct C3DMeshCacheEntry {
|
struct C3DMeshCacheEntry {
|
||||||
const MeshGroup* meshGroup = nullptr;
|
const MeshGroup* meshGroup = nullptr;
|
||||||
Uint32 version = 0;
|
Uint32 version = 0;
|
||||||
bool flat = false;
|
bool flat = false;
|
||||||
|
|
||||||
C3D_AttrInfo attrInfo;
|
C3D_AttrInfo attrInfo;
|
||||||
C3D_BufInfo bufInfo;
|
C3D_BufInfo bufInfo;
|
||||||
|
|
||||||
// CPU-side vertex data
|
// CPU-side vertex data
|
||||||
std::vector<D3DRMVERTEX> vertices;
|
std::vector<D3DRMVERTEX> vertices;
|
||||||
std::vector<D3DVECTOR> positions;
|
std::vector<D3DVECTOR> positions;
|
||||||
std::vector<D3DVECTOR> normals;
|
std::vector<D3DVECTOR> normals;
|
||||||
std::vector<TexCoord> texcoords; // Only if you have textures
|
std::vector<TexCoord> texcoords; // Only if you have textures
|
||||||
std::vector<uint16_t> indices; // Indices for indexed drawing
|
std::vector<uint16_t> indices; // Indices for indexed drawing
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Citro3DRenderer : public Direct3DRMRenderer {
|
class Citro3DRenderer : public Direct3DRMRenderer {
|
||||||
public:
|
public:
|
||||||
static Direct3DRMRenderer* Create(DWORD width, DWORD height);
|
|
||||||
|
|
||||||
// constructor parameters not finalized
|
|
||||||
Citro3DRenderer(DWORD width, DWORD height);
|
Citro3DRenderer(DWORD width, DWORD height);
|
||||||
~Citro3DRenderer() override;
|
~Citro3DRenderer() override;
|
||||||
|
|
||||||
@ -94,10 +89,21 @@ class Citro3DRenderer : public Direct3DRMRenderer {
|
|||||||
|
|
||||||
inline static void Citro3DRenderer_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
inline static void Citro3DRenderer_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||||
{
|
{
|
||||||
SDL_Log("Hello, enuming device");
|
GUID guid = Citro3D_GUID;
|
||||||
Direct3DRMRenderer* device = Citro3DRenderer::Create(400, 240);
|
char* deviceNameDup = SDL_strdup("Citro3D");
|
||||||
if (device) {
|
char* deviceDescDup = SDL_strdup("Miniwin driver");
|
||||||
EnumDevice(cb, ctx, device, Citro3D_GUID);
|
D3DDEVICEDESC halDesc = {};
|
||||||
delete device;
|
halDesc.dcmColorModel = D3DCOLOR_RGB;
|
||||||
}
|
halDesc.dwFlags = D3DDD_DEVICEZBUFFERBITDEPTH;
|
||||||
|
halDesc.dwDeviceZBufferBitDepth = DDBD_24;
|
||||||
|
halDesc.dwDeviceRenderBitDepth = DDBD_32;
|
||||||
|
halDesc.dpcTriCaps.dwTextureCaps = D3DPTEXTURECAPS_PERSPECTIVE;
|
||||||
|
halDesc.dpcTriCaps.dwShadeCaps = D3DPSHADECAPS_ALPHAFLATBLEND;
|
||||||
|
halDesc.dpcTriCaps.dwTextureFilterCaps = D3DPTFILTERCAPS_LINEAR;
|
||||||
|
D3DDEVICEDESC helDesc = {};
|
||||||
|
|
||||||
|
cb(&guid, deviceNameDup, deviceDescDup, &halDesc, &helDesc, ctx);
|
||||||
|
|
||||||
|
SDL_free(deviceDescDup);
|
||||||
|
SDL_free(deviceNameDup);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user