Display list isn't working

Post Reply
ccfreak2k
Posts: 14
Joined: Sat Mar 06, 2010 1:11 pm

Display list isn't working

Post by ccfreak2k » 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:

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;
Both box and boxret are actually declared at file-level, but I have them here for clarity. When drawing, I use this block:

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
		}
	}
"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.

shagkur
Posts: 53
Joined: Thu Sep 08, 2005 8:40 pm

Re: Display list isn't working

Post by shagkur » Tue Mar 09, 2010 10:19 am

Hi,

as far as i can tell BeginDispList/EndDispList are working well.
GX_DrawDone most often locks because of an improper data stream.
Could you pastebin the whole code to this example somewhere?

regards
shagkur

ccfreak2k
Posts: 14
Joined: Sat Mar 06, 2010 1:11 pm

Re: Display list isn't working

Post by ccfreak2k » Tue Mar 09, 2010 6:33 pm

Here's the code: http://pastebin.ca/1830288

It's not very clean, as I'm trying to get it working. It doesn't hang at GX_DrawDone(), but nothing gets drawn on the screen.

EDIT: I fixed it. I set GX_BeginDispList() to have a size greater than what I expected the output size to be(768 instead of 672), as in the example in the above post. "top" had the same issue, so I set its size to be -larger- than the rounded-up size (256 instead of 160). In the case of top, GX_EndDispList() returned a large value rather than 0 (67108864), and that may have been the case for box too, but I didn't check.

dancinninja
Posts: 6
Joined: Thu Jun 10, 2010 3:08 am

Re: Display list isn't working

Post by dancinninja » Fri Jun 25, 2010 12:28 am

The pastebin link doesn't seem to work for me. I am trying to go through the nehe tutorials myself and I would LOVE to hear how you solved the color issue (how can you change the colors for the display list?)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests