GX_REPEAT
Posted: Mon Apr 06, 2009 5:13 pm
Hi
I would like to render a 16x16 textured tile over the whole framebuffer (640x480), mainly to use as background texture
I was thinking about using GX_REPEAT mode but it does not seems to work properly (the texture is still "stretched" instead of being "repeated")
Here's the code I'm using, the png_texture holds the size of the texture (16x16 in my case), the parameters of the function are the final position & size on screen (0,0,640,480 in my case)
Is there something wrong with this code ? Is there someting more required to use the "REPEAT" mode ?
Thanks
I would like to render a 16x16 textured tile over the whole framebuffer (640x480), mainly to use as background texture
I was thinking about using GX_REPEAT mode but it does not seems to work properly (the texture is still "stretched" instead of being "repeated")
Here's the code I'm using, the png_texture holds the size of the texture (16x16 in my case), the parameters of the function are the final position & size on screen (0,0,640,480 in my case)
Code: Select all
void DrawTextureRepeat(png_texture *texture, int x, int y, int w, int h)
{
if (texture->data)
{
/* load texture object */
GXTexObj texObj;
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_InvalidateTexAll();
/* adjust coordinate system */
x -= (vmode->fbWidth/2);
y -= (vmode->efbHeight/2);
/* Draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(0.0, 1.0);
GX_Position2s16(x+w,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(1.0, 1.0);
GX_Position2s16(x+w,y);
GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(1.0, 0.0);
GX_Position2s16(x,y);
GX_Color4u8(0xff,0xff,0xff,0xff);
GX_TexCoord2f32(0.0, 0.0);
GX_End ();
GX_DrawDone();
}
}
Thanks