NDS: Implement water translucency partially

This commit is contained in:
UnknownShadow200 2025-03-02 14:17:10 +11:00
parent eb84b2e607
commit fe086a089d
2 changed files with 8 additions and 9 deletions

View File

@ -101,7 +101,7 @@ void ResetGPU(void) {
GFX_ALPHA_TEST = 7; // Alpha threshold ranges from 0 to 15
GFX_CONTROL = GL_ANTIALIAS | GL_TEXTURE_2D | GL_FOG;
GFX_CONTROL = GL_ANTIALIAS | GL_TEXTURE_2D | GL_FOG | GL_BLEND;
GFX_CLEAR_DEPTH = GL_MAX_DEPTH;
GFX_TEX_FORMAT = 0;
@ -703,14 +703,16 @@ void Gfx_DeleteDynamicVb(GfxResourceID* vb) { Gfx_DeleteVb(vb); }
*#########################################################################################################################*/
static cc_bool skipRendering;
static cc_bool backfaceCull;
static cc_bool alphaBlend;
static cc_bool fogEnabled;
static FogFunc fogMode;
static float fogDensityEnd;
static void SetPolygonMode() {
int blend = !gfx_rendering2D && alphaBlend;
u32 fmt =
POLY_ALPHA(31) |
POLY_ALPHA(blend ? 14 : 31) |
(backfaceCull ? POLY_CULL_BACK : POLY_CULL_NONE) |
(fogEnabled ? POLY_FOG : 0) |
POLY_RENDER_FAR_POLYS |
@ -725,11 +727,8 @@ void Gfx_SetFaceCulling(cc_bool enabled) {
}
static void SetAlphaBlend(cc_bool enabled) {
/*if (enabled) {
glEnable(GL_BLEND);
} else {
glDisable(GL_BLEND);
}*/
alphaBlend = enabled;
SetPolygonMode();
}
void Gfx_SetAlphaArgBlend(cc_bool enabled) { }

View File

@ -243,6 +243,7 @@ void Gfx_Make2DQuad(const struct Texture* tex, PackedCol color, struct VertexTex
static cc_bool gfx_hadFog;
void Gfx_Begin2D(int width, int height) {
gfx_rendering2D = true;
struct Matrix ortho;
/* intentionally biased more towards positive Z to reduce 2D clipping issues on the DS */
Gfx_CalcOrthoMatrix(&ortho, (float)width, (float)height, -100.0f, 1000.0f);
@ -255,16 +256,15 @@ void Gfx_Begin2D(int width, int height) {
gfx_hadFog = Gfx_GetFog();
if (gfx_hadFog) Gfx_SetFog(false);
gfx_rendering2D = true;
}
void Gfx_End2D(void) {
gfx_rendering2D = false;
Gfx_SetDepthTest(true);
Gfx_SetDepthWrite(true);
Gfx_SetAlphaBlending(false);
if (gfx_hadFog) Gfx_SetFog(true);
gfx_rendering2D = false;
}
#endif