Skip to content

Commit e756c4c

Browse files
authored
Merge pull request #293 from fjtrujy/fix_mipmapping
Fix mipmapping sample
2 parents 01cde97 + 162f34c commit e756c4c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/samples/gu/mipmapping/Makefile.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TARGET = MIPMAPPING
2-
OBJS = mipmapping.o mip0.o mip1.o mip2.o
2+
OBJS = mipmapping.o mip0.o mip1.o mip2.o ../common/callbacks.o
33

44
INCDIR =
55
CFLAGS = -Wall -O2

src/samples/gu/mipmapping/mipmapping.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <pspgu.h>
1919
#include <pspgum.h>
2020

21+
#include "../common/callbacks.h"
2122

2223
PSP_MODULE_INFO("MIP Mapping Sample", 0, 1, 1);
2324
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
@@ -34,7 +35,8 @@ struct Vertex{
3435
};
3536

3637
//A plane
37-
struct Vertex __attribute__((aligned(16))) vertices[2*3] =
38+
#define VERTICES_COUNT (2*3)
39+
struct Vertex __attribute__((aligned(16))) vertices[VERTICES_COUNT] =
3840
{
3941
{0, 0, -1, 1, 0}, // 0
4042
{1, 0, 1, 1, 0}, // 4
@@ -52,27 +54,25 @@ struct Vertex __attribute__((aligned(16))) vertices[2*3] =
5254

5355
int main(int argc, char* argv[])
5456
{
57+
setupCallbacks();
58+
5559
// setup GU
5660
void* fbp0 = (void*)(4 * 480 * 272);
5761
void* fbp1 = (void*)(4 * 480 * 272);
58-
void* zbp = (void*)(2 * 480 * 272);
5962

6063
sceGuInit();
6164
sceGuStart(GU_DIRECT,list);
6265
sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
6366
sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
64-
sceGuDepthBuffer(zbp,BUF_WIDTH);
6567
sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
6668
sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
6769
sceGuDepthRange(65535,0);
6870
sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
6971
sceGuEnable(GU_SCISSOR_TEST);
7072
sceGuDepthFunc(GU_GEQUAL);
71-
sceGuEnable(GU_DEPTH_TEST);
7273
sceGuShadeModel(GU_SMOOTH);
7374
sceGuDisable(GU_CULL_FACE);
7475
sceGuEnable(GU_TEXTURE_2D);
75-
//sceGuEnable(GU_CLIP_PLANES);
7676
sceGuFinish();
7777
sceGuSync(GU_SYNC_FINISH, GU_SYNC_WHAT_DONE);
7878

@@ -82,14 +82,13 @@ int main(int argc, char* argv[])
8282
// run sample
8383
float pos_z = -2.5;
8484
int zoom = -1;
85-
while(1){
85+
while(running()){
8686
sceGuStart(GU_DIRECT,list);
8787

8888
// clear screen
8989

9090
sceGuClearColor(0xff554433);
91-
sceGuClearDepth(0);
92-
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
91+
sceGuClear(GU_COLOR_BUFFER_BIT);
9392

9493
// setup matrices for cube
9594
//Projection
@@ -133,7 +132,7 @@ int main(int argc, char* argv[])
133132

134133
sceGuColor(0xffffffff);
135134
sceGuAmbientColor(0xffffffff);
136-
sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,2*3,0,vertices);
135+
sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,VERTICES_COUNT,0,vertices);
137136

138137
sceGuFinish();
139138
sceGuSync(GU_SYNC_FINISH, GU_SYNC_WHAT_DONE);

0 commit comments

Comments
 (0)