Being new to this, and new to C in general (being primarily a C# programmer, with a little C++), I'm sure it's some dumb obvious mistake. But I just can't figure it out.
Here's my code:
Code: Select all
#include<sys/types.h>
#include<libgte.h>
#include<libgpu.h>
#include<libetc.h>
#define x_res 320 /* Screen Width */
#define y_res 240 /* Screen Height */
DRAWENV draw[2];
DISPENV disp[2];
RECT clearRect[2];
int dispId = 0;
POLY_F3 tri;
/* Function Declarations */
void InitDispDrawEnvs();
void RenderAndSwap(); /* Handles rendering and swapping buffers */
int main()
{
InitDispDrawEnvs();
SetPolyF3(&tri);
setRGB0(&tri, 200, 0, 255);
setXY3(&tri, (x_res / 2), (y_res / 2) - 15, (x_res / 2) + 15, (y_res / 2) + 15, (x_res / 2) - 15, (y_res / 2) + 15);
while(1) /* Main Loop */
{
RenderAndSwap();
}
return 0;
}
void InitDispDrawEnvs()
{
SetDefDrawEnv(&draw[0], 0, y_res, x_res, y_res); /* Sets the drawing env */
SetDefDrawEnv(&draw[1], 0, 0, x_res, y_res);
SetDefDispEnv(&disp[0], 0, 0, x_res, y_res); /* Sets the display env */
SetDefDispEnv(&disp[1], 0, y_res, x_res, y_res);
PutDrawEnv(&draw[0]);
PutDispEnv(&disp[0]);
setRECT(&clearRect[0], 0, y_res, x_res, y_res);
setRECT(&clearRect[1], 0, 0, x_res, y_res);
}
void RenderAndSwap()
{
/* Clear only the drawing enviornment */
ClearImage(&clearRect[dispId], 75, 75, 150);
/* Draw Primitives */
DrawPrim(&tri);
/* Swap the draw and disp envs */
VSync(0);
dispId = (dispId + 1) % 2;
PutDrawEnv(&draw[dispId]);
PutDispEnv(&disp[dispId]);
}