Problem displaying 2d on 3d

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Problem displaying 2d on 3d

Post by Ghoti »

Hi folks,

I try to render some 2d images on the side screen. The problem is however that only one of my images is shown and only after the second loop :S

So the first loop only shows the 3d model, the second loop shows only the 3d model and the second sprite.

here is my loop:

Code: Select all

int NumberOfObjects = 4;

		MeshD Objects[NumberOfObjects];
		int color[NumberOfObjects];
		float MaxDistance = 150;
		float distance;
		int i;


		sprintf(sBuffer, "Objects/box.obj");
		sprintf(sBufferB, "Objects/box.mtl");
		LoadObjectTriangles(sBuffer,sBufferB, &Objects[0]);
		sprintf(sBuffer, "Objects/cone.obj");
		sprintf(sBufferB, "Objects/cone.mtl");
		LoadObjectTriangles(sBuffer,sBufferB, &Objects[1]);
		sprintf(sBuffer, "Objects/sphere.obj");
		sprintf(sBufferB, "Objects/sphere.mtl");
		LoadObjectTriangles(sBuffer,sBufferB, &Objects[2]);
		sprintf(sBuffer, "Objects/complex.obj");
		sprintf(sBufferB, "Objects/complex.mtl");
		LoadObjectTriangles(sBuffer,sBufferB, &Objects[3]);


		for&#40;i=0;i<NumberOfObjects;i++&#41;&#123;
			distance = MaxDistance;
			
			while&#40;1&#41;&#123;



			//misc.
				distance -= 0.1f;

			//controls
				SceCtrlData pad;

				sceCtrlReadBufferPositive&#40;&pad, 1&#41;; 

				if &#40;pad.Buttons != 0&#41;&#123;
					if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
						// do next
						if &#40;iButtonX == FALSE&#41;&#123;
							iButtonX = TRUE;
							break;
						&#125;
					&#125;
				&#125;
				else &#123;
					iButtonX = FALSE;
				&#125;

			//render
				sceGuStart&#40;GU_DIRECT,list&#41;;
				sceGuClearColor&#40;0xff000000&#41;;
				sceGuClearDepth&#40;0&#41;;
				sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT&#41;;
				matrix_identity&#40;&#40;float*&#41;&projection&#41;;
				matrix_projection&#40;&#40;float*&#41;&projection,75.0f,16.0f/9.0f,4.0,1000.0f&#41;;
				sceGuSetMatrix&#40;GU_PROJECTION,&projection&#41;;
				matrix_identity&#40;&#40;float*&#41;&view&#41;;
				matrix_rotate&#40;&#40;float*&#41;&view, 0, 3.15f, 0&#41;;
				matrix_translate&#40;&#40;float*&#41;&view,0, 0, 0&#41;;
				sceGuSetMatrix&#40;GU_VIEW,&view&#41;;
				// set the ambient light
				// sceGuAmbient&#40;0x00ffffff&#41;;
				RenderObjectTriangles&#40;&Objects&#91;i&#93;, 0, 0, distance, 0&#41;;


				Punt Hoekie&#91;2&#93;;

				Hoekie&#91;0&#93;.x = 0.0f;
				Hoekie&#91;0&#93;.y = 0.0f;
				Hoekie&#91;0&#93;.u = 0.0f;
				Hoekie&#91;0&#93;.v = 0.0f;
				Hoekie&#91;1&#93;.x = 90.0f;
				Hoekie&#91;1&#93;.y = 90.0f;
				Hoekie&#91;1&#93;.u = 1.0f;
				Hoekie&#91;1&#93;.v = 1.0f;

				sceGuTexImage&#40;0, Choice&#91;0&#93;->textureWidth, Choice&#91;0&#93;->textureHeight, Choice&#91;0&#93;->textureWidth, &#40;void*&#41;Choice&#91;0&#93;->data&#41;;
				sceGuDrawArray&#40;GU_SPRITES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,Hoekie&#41;;

				Hoekie&#91;0&#93;.x = 0.0f;
				Hoekie&#91;0&#93;.y = 90.0f;
				Hoekie&#91;0&#93;.u = 0.0f;
				Hoekie&#91;0&#93;.v = 0.0f;
				Hoekie&#91;1&#93;.x = 90.0f;
				Hoekie&#91;1&#93;.y = 180.0f;
				Hoekie&#91;1&#93;.u = 1.0f;
				Hoekie&#91;1&#93;.v = 1.0f;

				sceGuTexImage&#40;0, Choice&#91;1&#93;->textureWidth, Choice&#91;1&#93;->textureHeight, Choice&#91;1&#93;->textureWidth, &#40;void*&#41;Choice&#91;1&#93;->data&#41;;
				sceGuDrawArray&#40;GU_SPRITES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,Hoekie&#41;;


				//blitImageToScreen&#40;0 ,0 ,90 , 90, Choice&#91;0&#93;, 0, 0&#41;;
				//blitImageToScreen&#40;0 ,0 ,90 , 90, Choice&#91;1&#93;, 0, 91&#41;;
				//blitImageToScreen&#40;0 ,0 ,90 , 90, Choice&#91;2&#93;, 0, 182&#41;;


				sceGuFinish&#40;&#41;;
				sceGuSync&#40;0,0&#41;;
				sceDisplayWaitVblankStart&#40;&#41;;
				sceGuSwapBuffers&#40;&#41;;
			&#125;


		&#125;

	&#125;

What i want it to do is show everything the first time the loop begins and everytime in the loop any ideas or suggestions?

greets ghoti

P.S. ohw and for some reason the texture which is fully red, shows gradient when rendered
Arwin
Posts: 426
Joined: Tue Jul 12, 2005 7:00 pm

Post by Arwin »

Sound like you may need to think about where you put the sceGuSwapBuffers() ?
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

how do you mean exactly?
Post Reply