Skip to content

Commit a9d361d

Browse files
committed
Use display_get_zbuf everywhere
1 parent 1bd5da3 commit a9d361d

File tree

14 files changed

+14
-29
lines changed

14 files changed

+14
-29
lines changed

examples/00_quad/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ int main()
1414
debug_init_usblog();
1515

1616
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE);
17-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
1817
rdpq_init();
1918

2019
t3d_init((T3DInitParams){}); // Init library itself, use empty params for default settings
@@ -23,7 +22,6 @@ int main()
2322
t3d_mat4_identity(&modelMat);
2423
// Now allocate a fixed-point matrix, this is what t3d uses internally.
2524
T3DMat4FP* modelMatFP = malloc_uncached(sizeof(T3DMat4FP));
26-
T3DMat4FP* modelMatScale = malloc_uncached(sizeof(T3DMat4FP));
2725

2826
const T3DVec3 camPos = {{0,0,-18}};
2927
const T3DVec3 camTarget = {{0,0,0}};
@@ -74,7 +72,7 @@ int main()
7472
t3d_mat4_to_fixed(modelMatFP, &modelMat);
7573

7674
// ======== Draw (3D) ======== //
77-
rdpq_attach(display_get(), &depthBuffer); // set the target to draw to
75+
rdpq_attach(display_get(), display_get_zbuf()); // set the target to draw to
7876
t3d_frame_start(); // call this once per frame at the beginning of your draw function
7977

8078
t3d_viewport_attach(&viewport); // now use the viewport, this applies proj/view matrices and sets scissoring

examples/01_model/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ int main()
2323
dfs_init(DFS_DEFAULT_LOCATION);
2424

2525
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
26-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
2726

2827
rdpq_init();
2928

@@ -72,7 +71,7 @@ int main()
7271
t3d_mat4_to_fixed(modelMatFP, &modelMat);
7372

7473
// ======== Draw ======== //
75-
rdpq_attach(display_get(), &depthBuffer);
74+
rdpq_attach(display_get(), display_get_zbuf());
7675
t3d_frame_start();
7776
t3d_viewport_attach(&viewport);
7877

examples/02_lighting/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ int main()
2020
dfs_init(DFS_DEFAULT_LOCATION);
2121

2222
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS_DEDITHER);
23-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
2423

2524
rdpq_init();
2625
t3d_init((T3DInitParams){});
@@ -107,7 +106,7 @@ int main()
107106
if(lightCount > 4)lightCount = 4;
108107

109108
// ======== Draw ======== //
110-
rdpq_attach(display_get(), &depthBuffer);
109+
rdpq_attach(display_get(), display_get_zbuf());
111110
t3d_frame_start(); // call this once per frame at the beginning of your draw function
112111
t3d_viewport_attach(&viewport);
113112

examples/03_objects/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ int main()
8181
dfs_init(DFS_DEFAULT_LOCATION);
8282

8383
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
84-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
8584

8685
rdpq_init();
8786
joypad_init();
@@ -149,7 +148,7 @@ int main()
149148
t3d_viewport_look_at(&viewport, &camPos, &camTarget, &(T3DVec3){{0,1,0}});
150149

151150
// ======== Draw (3D) ======== //
152-
rdpq_attach(display_get(), &depthBuffer);
151+
rdpq_attach(display_get(), display_get_zbuf());
153152
t3d_frame_start();
154153
t3d_viewport_attach(&viewport);
155154

examples/04_dynamic/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ int main()
3030
dfs_init(DFS_DEFAULT_LOCATION);
3131

3232
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
33-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
3433

3534
rdpq_init();
3635
joypad_init();
@@ -125,7 +124,7 @@ int main()
125124
}
126125

127126
// ======== Draw (3D) ======== //
128-
rdpq_attach(display_get(), &depthBuffer);
127+
rdpq_attach(display_get(), display_get_zbuf());
129128
t3d_frame_start();
130129
t3d_viewport_attach(&viewport);
131130

examples/05_splitscreen/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ int main()
3333
dfs_init(DFS_DEFAULT_LOCATION);
3434

3535
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
36-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
3736

3837
rdpq_init();
3938

@@ -115,7 +114,7 @@ int main()
115114
}
116115

117116
// ======== Draw (3D) ======== //
118-
rdpq_attach(display_get(), &depthBuffer);
117+
rdpq_attach(display_get(), display_get_zbuf());
119118

120119
t3d_frame_start();
121120
rdpq_mode_fog(RDPQ_FOG_STANDARD);

examples/06_offscreen/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ int main()
4141

4242
// Allocate our normal screen and depth buffer...
4343
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
44-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
4544

4645
//... then a smaller additional buffer (color + depth) for offscreen rendering
4746
surface_t offscreenSurf = surface_alloc(FMT_RGBA16, OFFSCREEN_SIZE, OFFSCREEN_SIZE);
@@ -171,7 +170,7 @@ int main()
171170
// ======== Draw (Onscreen) ======== //
172171
// For our main scene we now attach the screen buffer again,
173172
// from now one everything is the same as in other examples
174-
rdpq_attach(display_get(), &depthBuffer);
173+
rdpq_attach(display_get(), display_get_zbuf());
175174

176175
t3d_frame_start();
177176
t3d_viewport_attach(&viewport);

examples/07_skeleton/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ int main()
3333
dfs_init(DFS_DEFAULT_LOCATION);
3434

3535
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 2, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
36-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
3736

3837
rdpq_init();
3938
joypad_init();
@@ -162,7 +161,7 @@ int main()
162161
);
163162

164163
// ======== Draw (3D) ======== //
165-
rdpq_attach(display_get(), &depthBuffer);
164+
rdpq_attach(display_get(), display_get_zbuf());
166165
t3d_frame_start();
167166
t3d_viewport_attach(&viewport);
168167

examples/08_animation/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ int main()
2424
dfs_init(DFS_DEFAULT_LOCATION);
2525

2626
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 3, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
27-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
2827

2928
rdpq_init();
3029
joypad_init();
@@ -189,7 +188,7 @@ int main()
189188
);
190189

191190
// ======== Draw (3D) ======== //
192-
rdpq_attach(display_get(), &depthBuffer);
191+
rdpq_attach(display_get(), display_get_zbuf());
193192
t3d_frame_start();
194193
t3d_viewport_attach(&viewport);
195194

examples/09_anim_viewer/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ int main()
5454
dfs_init(DFS_DEFAULT_LOCATION);
5555

5656
display_init(RESOLUTION_320x240, DEPTH_16_BPP, 2, GAMMA_NONE, FILTERS_RESAMPLE_ANTIALIAS);
57-
surface_t depthBuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
5857

5958
rdpq_init();
6059
joypad_init();
@@ -195,7 +194,7 @@ int main()
195194
);
196195

197196
// ======== Draw (3D) ======== //
198-
rdpq_attach(display_get(), &depthBuffer);
197+
rdpq_attach(display_get(), display_get_zbuf());
199198
t3d_frame_start();
200199
t3d_viewport_attach(&viewport);
201200

0 commit comments

Comments
 (0)