Skip to content

Commit 2e31c8d

Browse files
Warioware64AntonioND
authored andcommitted
general: Add depth buffering configuration function
Add depth buffering configuration.
1 parent 097111e commit 2e31c8d

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

include/NEGeneral.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,21 @@ void NE_ClippingPlanesSetI(int znear, int zfar);
227227
/// @param value true enables antialiasing, false disables it.
228228
void NE_AntialiasEnable(bool value);
229229

230+
/// Depth buffering configuration for the 3D engine.
231+
typedef enum{
232+
NE_ZBUFFERING = 0,
233+
NE_WBUFFERING = (1 << 1)
234+
} NE_BufferingMode;
235+
236+
/// Set the active depth buffering mode for 3D render.
237+
/// Z-buffering is default.
238+
///
239+
/// @param mode NE_ZBUFFERING or NE_WBUFFERING.
240+
void NE_SetDepthBufferingMode(NE_BufferingMode mode);
241+
242+
/// Return the active depth buffering mode for 3D render.
243+
NE_BufferingMode NE_GetDepthBufferingMode(void)
244+
230245
/// Returns the number of polygons drawn since the last glFlush().
231246
///
232247
/// @return Returns the number of polygons (0 - 2048).

source/NEGeneral.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ static int fov;
3232

3333
static int ne_main_screen = 1; // 1 = top, 0 = bottom
3434

35+
static NE_BufferingMode ne_depth_buffering_mode = NE_ZBUFFERING; // Z_BUFFERING by default
36+
3537
static uint32_t ne_dma_enabled = 0;
3638
static uint32_t ne_dma_src = 0;
3739
static uint32_t ne_dma_dst = 0;
@@ -245,6 +247,8 @@ static void ne_init_registers(void)
245247
GFX_FLUSH = 0;
246248
GFX_FLUSH = 0;
247249

250+
ne_depth_buffering_mode = NE_ZBUFFERING; // Set default Z-buffering
251+
248252
NE_MainScreenSetOnTop();
249253
lcdMainOnTop();
250254

@@ -314,6 +318,16 @@ void NE_UpdateInput(void)
314318
touchRead(&ne_input.touch);
315319
}
316320

321+
void NE_SetDepthBufferingMode(NE_BufferingMode mode)
322+
{
323+
ne_depth_buffering_mode = mode;
324+
}
325+
326+
NE_BufferingMode NE_GetDepthBufferingMode(void)
327+
{
328+
return ne_depth_buffering_mode;
329+
}
330+
317331
int NE_Init3D(void)
318332
{
319333
NE_End();
@@ -622,7 +636,7 @@ void NE_Process(NE_Voidfunc drawscene)
622636
NE_AssertPointer(drawscene, "NULL function pointer");
623637
drawscene();
624638

625-
GFX_FLUSH = GL_TRANS_MANUALSORT;
639+
GFX_FLUSH = GL_TRANS_MANUALSORT | ne_depth_buffering_mode;
626640
}
627641

628642
void NE_ProcessArg(NE_VoidArgfunc drawscene, void *arg)
@@ -632,7 +646,7 @@ void NE_ProcessArg(NE_VoidArgfunc drawscene, void *arg)
632646
NE_AssertPointer(drawscene, "NULL function pointer");
633647
drawscene(arg);
634648

635-
GFX_FLUSH = GL_TRANS_MANUALSORT;
649+
GFX_FLUSH = GL_TRANS_MANUALSORT | ne_depth_buffering_mode;
636650
}
637651

638652
static void ne_process_dual_3d_common_start(void)
@@ -688,7 +702,7 @@ static void ne_process_dual_3d_common_start(void)
688702

689703
static void ne_process_dual_3d_common_end(void)
690704
{
691-
GFX_FLUSH = GL_TRANS_MANUALSORT;
705+
GFX_FLUSH = GL_TRANS_MANUALSORT | ne_depth_buffering_mode;
692706

693707
NE_Screen ^= 1;
694708
}
@@ -768,7 +782,7 @@ static void ne_process_dual_3d_fb_common_start(void)
768782

769783
static void ne_process_dual_3d_fb_common_end(void)
770784
{
771-
GFX_FLUSH = GL_TRANS_MANUALSORT;
785+
GFX_FLUSH = GL_TRANS_MANUALSORT | ne_depth_buffering_mode;
772786

773787
NE_Screen ^= 1;
774788
}
@@ -937,7 +951,7 @@ static void ne_process_dual_3d_dma_common_start(void)
937951

938952
static void ne_process_dual_3d_dma_common_end(void)
939953
{
940-
GFX_FLUSH = GL_TRANS_MANUALSORT;
954+
GFX_FLUSH = GL_TRANS_MANUALSORT | ne_depth_buffering_mode;
941955

942956
NE_Screen ^= 1;
943957

0 commit comments

Comments
 (0)