mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
Be more consistent with depth write enabling/disabling
This commit is contained in:
parent
8800578b65
commit
dfd12d8c9f
@ -403,28 +403,38 @@ void EntityNames_Render(void) {
|
|||||||
|
|
||||||
void EntityNames_RenderHovered(void) {
|
void EntityNames_RenderHovered(void) {
|
||||||
struct LocalPlayer* p = Entities.CurPlayer;
|
struct LocalPlayer* p = Entities.CurPlayer;
|
||||||
|
struct Entity* e;
|
||||||
cc_bool allNames, hadFog;
|
cc_bool allNames, hadFog;
|
||||||
|
cc_bool setupState = false;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (Entities.NamesMode == NAME_MODE_NONE) return;
|
if (Entities.NamesMode == NAME_MODE_NONE) return;
|
||||||
allNames = !(Entities.NamesMode == NAME_MODE_HOVERED || Entities.NamesMode == NAME_MODE_ALL)
|
allNames = !(Entities.NamesMode == NAME_MODE_HOVERED || Entities.NamesMode == NAME_MODE_ALL)
|
||||||
&& p->Hacks.CanSeeAllNames;
|
&& p->Hacks.CanSeeAllNames;
|
||||||
|
|
||||||
Gfx_SetAlphaTest(true);
|
|
||||||
Gfx_SetDepthTest(false);
|
|
||||||
hadFog = Gfx_GetFog();
|
|
||||||
if (hadFog) Gfx_SetFog(false);
|
|
||||||
|
|
||||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++)
|
for (i = 0; i < ENTITIES_MAX_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (!Entities.List[i]) continue;
|
e = Entities.List[i];
|
||||||
if ((i == closestEntityId || allNames) && Entities.List[i] != &p->Base) {
|
if (!e || e == &p->Base) continue;
|
||||||
DrawName(Entities.List[i]);
|
if (!allNames && i != closestEntityId) continue;
|
||||||
|
|
||||||
|
/* Only alter the GPU state when actually necessary */
|
||||||
|
if (!setupState) {
|
||||||
|
Gfx_SetAlphaTest(true);
|
||||||
|
Gfx_SetDepthTest(false);
|
||||||
|
Gfx_SetDepthWrite(false);
|
||||||
|
|
||||||
|
setupState = true;
|
||||||
|
hadFog = Gfx_GetFog();
|
||||||
|
if (hadFog) Gfx_SetFog(false);
|
||||||
}
|
}
|
||||||
|
DrawName(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!setupState) return;
|
||||||
Gfx_SetAlphaTest(false);
|
Gfx_SetAlphaTest(false);
|
||||||
Gfx_SetDepthTest(true);
|
Gfx_SetDepthTest(true);
|
||||||
|
Gfx_SetDepthWrite(true);
|
||||||
if (hadFog) Gfx_SetFog(true);
|
if (hadFog) Gfx_SetFog(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,9 +212,7 @@ static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
|||||||
|
|
||||||
static cc_bool depth_write = true, depth_test = true;
|
static cc_bool depth_write = true, depth_test = true;
|
||||||
static void UpdateDepthState(void) {
|
static void UpdateDepthState(void) {
|
||||||
// match Desktop behaviour, where disabling depth testing also disables depth writing
|
GX_SetZMode(depth_test, GX_LEQUAL, depth_write);
|
||||||
// TODO do we actually need to & here?
|
|
||||||
GX_SetZMode(depth_test, GX_LEQUAL, depth_write & depth_test);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetDepthWrite(cc_bool enabled) {
|
void Gfx_SetDepthWrite(cc_bool enabled) {
|
||||||
|
@ -299,21 +299,12 @@ void Gfx_ClearColor(PackedCol color) {
|
|||||||
clearColor = B | (G << 8) | (R << 16) | (0xFF << 24);
|
clearColor = B | (G << 8) | (R << 16) | (0xFF << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool depth_write = true, depth_test = true;
|
|
||||||
static void UpdateDepthState(void) {
|
|
||||||
// match Desktop behaviour, where disabling depth testing also disables depth writing
|
|
||||||
rsxSetDepthWriteEnable(context, depth_write & depth_test);
|
|
||||||
rsxSetDepthTestEnable(context, depth_test);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Gfx_SetDepthWrite(cc_bool enabled) {
|
void Gfx_SetDepthWrite(cc_bool enabled) {
|
||||||
depth_write = enabled;
|
rsxSetDepthWriteEnable(context, enabled);
|
||||||
UpdateDepthState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetDepthTest(cc_bool enabled) {
|
void Gfx_SetDepthTest(cc_bool enabled) {
|
||||||
depth_test = enabled;
|
rsxSetDepthTestEnable(context, enabled);
|
||||||
UpdateDepthState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetAlphaTest(cc_bool enabled) {
|
static void SetAlphaTest(cc_bool enabled) {
|
||||||
|
@ -993,34 +993,18 @@ static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool depth_write = true, depth_test = true;
|
void Gfx_SetDepthWrite(cc_bool enabled) {
|
||||||
static void UpdateDepthWrite(void) {
|
|
||||||
// match Desktop behaviour, where disabling depth testing also disables depth writing
|
|
||||||
// TODO do we actually need to & here?
|
|
||||||
cc_bool enabled = depth_write & depth_test;
|
|
||||||
|
|
||||||
int mode = enabled ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED;
|
int mode = enabled ? SCE_GXM_DEPTH_WRITE_ENABLED : SCE_GXM_DEPTH_WRITE_DISABLED;
|
||||||
sceGxmSetFrontDepthWriteEnable(gxm_context, mode);
|
sceGxmSetFrontDepthWriteEnable(gxm_context, mode);
|
||||||
sceGxmSetBackDepthWriteEnable(gxm_context, mode);
|
sceGxmSetBackDepthWriteEnable(gxm_context, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateDepthFunction(void) {
|
void Gfx_SetDepthTest(cc_bool enabled) {
|
||||||
int func = depth_test ? SCE_GXM_DEPTH_FUNC_LESS_EQUAL : SCE_GXM_DEPTH_FUNC_ALWAYS;
|
int func = enabled ? SCE_GXM_DEPTH_FUNC_LESS_EQUAL : SCE_GXM_DEPTH_FUNC_ALWAYS;
|
||||||
sceGxmSetFrontDepthFunc(gxm_context, func);
|
sceGxmSetFrontDepthFunc(gxm_context, func);
|
||||||
sceGxmSetBackDepthFunc(gxm_context, func);
|
sceGxmSetBackDepthFunc(gxm_context, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetDepthWrite(cc_bool enabled) {
|
|
||||||
depth_write = enabled;
|
|
||||||
UpdateDepthWrite();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Gfx_SetDepthTest(cc_bool enabled) {
|
|
||||||
depth_test = enabled;
|
|
||||||
UpdateDepthWrite();
|
|
||||||
UpdateDepthFunction();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
||||||
@ -1116,8 +1100,7 @@ void Gfx_ClearBuffers(GfxBuffers buffers) {
|
|||||||
clear_vertices[3] = (struct VertexColoured){-1.0f, 1.0f, 1.0f, clear_color };
|
clear_vertices[3] = (struct VertexColoured){-1.0f, 1.0f, 1.0f, clear_color };
|
||||||
|
|
||||||
Gfx_SetAlphaTest(false);
|
Gfx_SetAlphaTest(false);
|
||||||
// can't use Gfx_SetDepthTest because that also affects depth writing
|
Gfx_SetDepthTest(false);
|
||||||
depth_test = false; UpdateDepthFunction();
|
|
||||||
|
|
||||||
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
||||||
Gfx_LoadIdentityMatrix(MATRIX_VIEW);
|
Gfx_LoadIdentityMatrix(MATRIX_VIEW);
|
||||||
@ -1125,6 +1108,6 @@ void Gfx_ClearBuffers(GfxBuffers buffers) {
|
|||||||
Gfx_BindVb(clearVB);
|
Gfx_BindVb(clearVB);
|
||||||
Gfx_DrawVb_IndexedTris(4);
|
Gfx_DrawVb_IndexedTris(4);
|
||||||
|
|
||||||
depth_test = true; UpdateDepthFunction();
|
Gfx_SetDepthTest(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -339,8 +339,8 @@ static void DrawTriangle(Vertex* V0, Vertex* V1, Vertex* V2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reject triangles completely outside
|
// Reject triangles completely outside
|
||||||
if ((minX < 0 && maxX < 0) || (minX > fb_maxX && maxX > fb_maxX)) return;
|
if (maxX < 0 || minX > fb_maxX) return;
|
||||||
if ((minY < 0 && maxY < 0) || (minY > fb_maxY && maxY > fb_maxY)) return;
|
if (maxY < 0 || minY > fb_maxY) return;
|
||||||
|
|
||||||
// Perform scissoring
|
// Perform scissoring
|
||||||
minX = max(minX, 0); maxX = min(maxX, fb_maxX);
|
minX = max(minX, 0); maxX = min(maxX, fb_maxX);
|
||||||
|
@ -36,6 +36,7 @@ static void HeldBlockRenderer_RenderModel(void) {
|
|||||||
|
|
||||||
Gfx_SetFaceCulling(true);
|
Gfx_SetFaceCulling(true);
|
||||||
Gfx_SetDepthTest(false);
|
Gfx_SetDepthTest(false);
|
||||||
|
Gfx_SetDepthWrite(false);
|
||||||
/* TODO: Need to properly reallocate per model VB here */
|
/* TODO: Need to properly reallocate per model VB here */
|
||||||
|
|
||||||
if (Blocks.Draw[held_block] == DRAW_GAS) {
|
if (Blocks.Draw[held_block] == DRAW_GAS) {
|
||||||
@ -56,6 +57,7 @@ static void HeldBlockRenderer_RenderModel(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Gfx_SetDepthTest(true);
|
Gfx_SetDepthTest(true);
|
||||||
|
Gfx_SetDepthWrite(true);
|
||||||
Gfx_SetFaceCulling(false);
|
Gfx_SetFaceCulling(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,6 +284,7 @@ void Gfx_Begin2D(int width, int height) {
|
|||||||
Gfx_LoadIdentityMatrix(MATRIX_VIEW);
|
Gfx_LoadIdentityMatrix(MATRIX_VIEW);
|
||||||
|
|
||||||
Gfx_SetDepthTest(false);
|
Gfx_SetDepthTest(false);
|
||||||
|
Gfx_SetDepthWrite(false);
|
||||||
Gfx_SetAlphaBlending(true);
|
Gfx_SetAlphaBlending(true);
|
||||||
|
|
||||||
gfx_hadFog = Gfx_GetFog();
|
gfx_hadFog = Gfx_GetFog();
|
||||||
@ -293,6 +294,7 @@ void Gfx_Begin2D(int width, int height) {
|
|||||||
|
|
||||||
void Gfx_End2D(void) {
|
void Gfx_End2D(void) {
|
||||||
Gfx_SetDepthTest(true);
|
Gfx_SetDepthTest(true);
|
||||||
|
Gfx_SetDepthWrite(true);
|
||||||
Gfx_SetAlphaBlending(false);
|
Gfx_SetAlphaBlending(false);
|
||||||
|
|
||||||
if (gfx_hadFog) Gfx_SetFog(true);
|
if (gfx_hadFog) Gfx_SetFog(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user