drawing a tiled floor. Can somebody help me?

Post Reply
wilco2009
Posts: 4
Joined: Fri Jan 21, 2011 11:05 pm

drawing a tiled floor. Can somebody help me?

Post by wilco2009 » Sat Jan 22, 2011 12:10 pm

First of all, I'm sorry for my English.

I'm learning to programming gx, and I've found a problem
that I cant understand.

I'm making a program to walk though a world like a quake.
I'm trying to draw a tiled floor doing two nested loops
calling a function who draw a simple textured tile.
If I draw some individual tiles I haven't troubles and
floor is drawed right but if I draw more than certain
number of tiles (no so much) the program hangs.

Can somebody helpme??
Bellow you can find a extract of my code. With theese
number of tiles program hangs:


void DibujaBaldosa(float x, float z, GXTexObj *texture)
#define tBaldosa 1.0f
{

//set number of textures to generate
GX_SetNumTexGens(1);

GX_SetTevOp(GX_TEVSTAGE0,GX_BLEND);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

GX_LoadTexObj(texture, GX_TEXMAP0);


guMtxIdentity(model);

guMtxTransApply(model, model, x,ySuelo,z);
guMtxConcat(view,model,modelview);


// load the modelview matrix into matrix memory
GX_LoadPosMtxImm(modelview, GX_PNMTX0);

guMtxInverse(modelview,mvi);
guMtxTranspose(mvi,modelview);
GX_LoadNrmMtxImm(modelview, GX_PNMTX0);


GX_Begin(GX_QUADS, GX_VTXFMT0, 4);

// Draw the floor
GX_Position3f32(tBaldosa, 0, -tBaldosa); // Top Right Of The Quad (Right)
GX_TexCoord2f32(10.0f,10.0f);
GX_Position3f32(-tBaldosa, 0, -tBaldosa); // Top Left Of The Quad (Right)
GX_TexCoord2f32(0.0f,10.0f);
GX_Position3f32(-tBaldosa, 0, tBaldosa); // Bottom Left Of The Quad (Right)
GX_TexCoord2f32(0.0f,0.0f);
GX_Position3f32(+tBaldosa, 0, tBaldosa); // Bottom Right Of The Quad (Right)
GX_TexCoord2f32(10.0f,0.0f);
GX_End(); // Done Drawing The Quad

}

void Dibujasuelo (GXTexObj *texture)
{
f32 x;
f32 z;

for (x = -4.0f; x < 6.0f;x = x + 2.0f)
for (z = -18.0f; z <= -6.0f; z = z + 2.0f)
DibujaBaldosa(x, z, texture);
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest