Display list isn't working
Posted: Mon Mar 08, 2010 9:58 pm
I've been trying to convert nehe's OpenGL lesson 12 (display lists) to GX, but I'm having a hard time getting display lists to work. I have this code in a separate function:
Both box and boxret are actually declared at file-level, but I have them here for clarity. When drawing, I use this block:
"view" comes from the caller, and the other vars are floats or ints and aren't really consequential (they work fine). Unfortunately, this code causes GX_DrawDone() to hang, and I am at my wit's end as to why. If required, I can provide the full source code.
EDIT: The display list shape has a missing side (the top) intentionally.
Code: Select all
void *box;
u32 boxret;
box = memalign(32,1024);
GX_BeginDispList(box,672);
GX_Begin(GX_QUADS,GX_VTXFMT0,20); // Start drawing
// Bottom face
GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32( 1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom right
// Front face
GX_Position3f32(-1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Bottom right
GX_Position3f32( 1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32(-1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
// Back face
GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Bottom right
GX_Position3f32(-1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32( 1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
GX_Position3f32( 1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
// Right face
GX_Position3f32( 1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Bottom right
GX_Position3f32( 1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top right
GX_Position3f32( 1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Top left
GX_Position3f32( 1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom left
// Left face
GX_Position3f32(-1.0f,-1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,0.0f); // Bottom right
GX_Position3f32(-1.0f,-1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,0.0f); // Top right
GX_Position3f32(-1.0f, 1.0f, 1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(1.0f,1.0f); // Top left
GX_Position3f32(-1.0f, 1.0f,-1.0f); GX_Normal3f32((f32)0,(f32)0,(f32)1); GX_TexCoord2f32(0.0f,1.0f); // Bottom left
GX_End(); // Done drawing quads
boxret = GX_EndDispList(); // Done building the box list
if (boxret == 0) return 1;
Code: Select all
Mtx model,view,modelview;
for (yloop = 1; yloop < 6; yloop++) { // Loop through the y plane
for (xloop = 0; xloop < yloop; xloop++) { // Loop through the x plane
// Position the cubes on the screen
guMtxIdentity(model);
axis.x = 1.0f;
axis.y = 0;
axis.z = 0;
guMtxRotAxisDeg(model,&axis,(45.0f-(2.0f*yloop)+xrot)); // Tilt the cubes up and down
axis.x = 0;
axis.y = 1.0f;
guMtxRotAxisDeg(model,&axis,(45.0f+yrot)); // Spin cubes left and right
guMtxTransApply(model,model,(1.4f+((float)xloop*2.8f)-((float)yloop*1.4f)),(((6.0f-(float)yloop)*2.4f)-7.0f),-20.0f);
guMtxConcat(model,view,modelview);
GX_LoadPosMtxImm(modelview, GX_PNMTX0);
GX_CallDispList(box,boxret); // Draw the box
}
}
EDIT: The display list shape has a missing side (the top) intentionally.