[CHG] InitVideo() and GRRLIB_Render() merge into GRRLIB_Init().

This commit is contained in:
Crayon2000 2009-01-19 23:08:45 +00:00
parent 2f9443033d
commit 6bc15252a7
3 changed files with 42 additions and 40 deletions

View file

@ -75,7 +75,9 @@ inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color){
* @param filled * @param filled
*/ */
inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled) { inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled) {
Vector v[] = {{x,y,0.0f}, {x+width,y,0.0f}, {x+width,y+height,0.0f}, {x,y+height,0.0f}, {x,y,0.0f}}; f32 x2 = x+width;
f32 y2 = y+height;
Vector v[] = {{x,y,0.0f}, {x2,y,0.0f}, {x2,y2,0.0f}, {x,y2,0.0f}, {x,y,0.0f}};
if(!filled) { if(!filled) {
GRRLIB_NGone(v, color, 5); GRRLIB_NGone(v, color, 5);
@ -184,7 +186,7 @@ static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int
/** /**
* Load a texture from a buffer. * Load a texture from a buffer.
* Take Care to have a JPG Finnishing by 0xFF 0xD9 !!!! * Take Care to have a JPG finnishing by 0xFF 0xD9 !!!!
* @author DrTwox * @author DrTwox
* @param my_jpg the JPEG buffer to load. * @param my_jpg the JPEG buffer to load.
* @return A GRRLIB_texImg structure filled with PNG informations. * @return A GRRLIB_texImg structure filled with PNG informations.
@ -313,7 +315,7 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees,
} }
/** /**
* * Draw a tile on the screen.
* @param xpos * @param xpos
* @param ypos * @param ypos
* @param tex * @param tex
@ -376,7 +378,7 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees
} }
/** /**
* * Print formatted output to the screen.
* @param xpos * @param xpos
* @param ypos * @param ypos
* @param tex * @param tex
@ -417,32 +419,33 @@ void GRRLIB_GXEngine(Vector v[], u32 color, long n, u8 fmt){
} }
/** /**
* * Initialize GRRLIB.
*/ */
void GRRLIB_InitVideo () { void GRRLIB_Init () {
f32 yscale;
u32 xfbHeight;
Mtx perspective;
VIDEO_Init(); VIDEO_Init();
rmode = VIDEO_GetPreferredMode(NULL); rmode = VIDEO_GetPreferredMode(NULL);
if(rmode == NULL)
return;
VIDEO_Configure (rmode); VIDEO_Configure (rmode);
xfb[0] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[0] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
xfb[1] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[1] = (u32 *)MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
if(xfb[0] == NULL || xfb[1] == NULL)
return;
VIDEO_SetNextFramebuffer(xfb[fb]); VIDEO_SetNextFramebuffer(xfb[fb]);
VIDEO_SetBlack(FALSE); VIDEO_SetBlack(FALSE);
VIDEO_Flush(); VIDEO_Flush();
VIDEO_WaitVSync(); VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE)
VIDEO_WaitVSync();
gp_fifo = (u8 *) memalign(32, DEFAULT_FIFO_SIZE); gp_fifo = (u8 *) memalign(32, DEFAULT_FIFO_SIZE);
} if(gp_fifo == NULL)
return;
/**
*
*/
void GRRLIB_Start(){
f32 yscale;
u32 xfbHeight;
Mtx perspective;
GX_Init (gp_fifo, DEFAULT_FIFO_SIZE); GX_Init (gp_fifo, DEFAULT_FIFO_SIZE);
// clears the bg to color and clears the z buffer // clears the bg to color and clears the z buffer
@ -503,7 +506,7 @@ void GRRLIB_Start(){
} }
/** /**
* * Call this function after drawing.
*/ */
void GRRLIB_Render () { void GRRLIB_Render () {
GX_DrawDone (); GX_DrawDone ();

View file

@ -66,8 +66,8 @@ void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, c
void GRRLIB_GXEngine(Vector v[], u32 color, long count, u8 fmt); void GRRLIB_GXEngine(Vector v[], u32 color, long count, u8 fmt);
void GRRLIB_InitVideo (); void GRRLIB_Init ();
void GRRLIB_Start();
void GRRLIB_Render (); void GRRLIB_Render ();
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -23,9 +23,9 @@ Mtx GXmodelView2D;
int main(){ int main(){
int rot = 0; int rot = 0;
ir_t ir1;
GRRLIB_InitVideo(); GRRLIB_Init();
GRRLIB_Start();
fatInitDefault(); fatInitDefault();
WPAD_Init(); WPAD_Init();
@ -52,7 +52,6 @@ int main(){
u32 wpaddown = WPAD_ButtonsDown(0); u32 wpaddown = WPAD_ButtonsDown(0);
u32 wpadheld = WPAD_ButtonsHeld(0); u32 wpadheld = WPAD_ButtonsHeld(0);
ir_t ir1;
WPAD_IR(WPAD_CHAN_0, &ir1); WPAD_IR(WPAD_CHAN_0, &ir1);
GRRLIB_FillScreen(0x000000FF); GRRLIB_FillScreen(0x000000FF);