Square with changing colors
This commit is contained in:
parent
74d678d0bb
commit
e7ae07ae13
29
main.c
29
main.c
@ -76,10 +76,13 @@ int gs_init(int width, int height, int psm, int psmz, int vmode, int gmode) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tri[] = {
|
static int verts[] = {
|
||||||
10, 10, 0,
|
100, 100, 0,
|
||||||
600, 200, 0,
|
300, 100, 0,
|
||||||
20, 400, 0
|
100, 300, 0,
|
||||||
|
300, 100, 0,
|
||||||
|
300, 300, 0,
|
||||||
|
100, 300, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SHIFT_AS_I64(x, b) (((uint64_t)x)<<b);
|
#define SHIFT_AS_I64(x, b) (((uint64_t)x)<<b);
|
||||||
@ -96,8 +99,8 @@ int draw() {
|
|||||||
q = draw_clear(q, 0, 2048.0f - 320, 2048.0f - 244, VID_W, VID_H, 20, 20, 20);
|
q = draw_clear(q, 0, 2048.0f - 320, 2048.0f - 244, VID_W, VID_H, 20, 20, 20);
|
||||||
//q = draw_enable_tests(q, 0, z);
|
//q = draw_enable_tests(q, 0, z);
|
||||||
// GIFTag header - 3x(col, pos)
|
// GIFTag header - 3x(col, pos)
|
||||||
q->dw[0] = 0x7000000000000001;
|
q->dw[0] = 0xD000000000000001;
|
||||||
q->dw[1] = 0x0000000005151510;
|
q->dw[1] = 0x0005151515151510;
|
||||||
q++;
|
q++;
|
||||||
|
|
||||||
q->dw[0] = GS_PRIM_TRIANGLE;
|
q->dw[0] = GS_PRIM_TRIANGLE;
|
||||||
@ -107,15 +110,15 @@ int draw() {
|
|||||||
int cx = myftoi4(2048 - (VID_W/2));
|
int cx = myftoi4(2048 - (VID_W/2));
|
||||||
int cy = myftoi4(2048 - (VID_H/2));
|
int cy = myftoi4(2048 - (VID_H/2));
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 6; i++){
|
||||||
q->dw[0] = (red&0xff) | (green&0xff)<<32;
|
q->dw[0] = (red&0xff) | (green&0xff)<<32;
|
||||||
q->dw[1] = (blue&0xff) | SHIFT_AS_I64(0x80, 32);
|
q->dw[1] = (blue&0xff) | SHIFT_AS_I64(0x80, 32);
|
||||||
q++;
|
q++;
|
||||||
|
|
||||||
int base = i*3;
|
int base = i*3;
|
||||||
int x = myftoi4(tri[base+0]) + cx;
|
int x = myftoi4(verts[base+0]) + cx;
|
||||||
int y = myftoi4(tri[base+1]) + cy;
|
int y = myftoi4(verts[base+1]) + cy;
|
||||||
int z = myftoi4(tri[base+2]);
|
int z = myftoi4(verts[base+2]);
|
||||||
q->dw[0] = x | SHIFT_AS_I64(y, 32);
|
q->dw[0] = x | SHIFT_AS_I64(y, 32);
|
||||||
q->dw[1] = z;
|
q->dw[1] = z;
|
||||||
q++;
|
q++;
|
||||||
@ -148,9 +151,9 @@ int main() {
|
|||||||
z = malloc(sizeof(zbuffer_t));
|
z = malloc(sizeof(zbuffer_t));
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
tri[0]++;
|
red++;
|
||||||
if(tri[0] > 480) {
|
if(red > 0xFF) {
|
||||||
tri[0] = 0;
|
red = 0;
|
||||||
}
|
}
|
||||||
draw();
|
draw();
|
||||||
graph_wait_vsync();
|
graph_wait_vsync();
|
||||||
|
Loading…
Reference in New Issue
Block a user