forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem displaying 2d on 3d

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Wed Oct 25, 2006 12:57 am    Post subject: Problem displaying 2d on 3d Reply with quote

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:
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(i=0;i<NumberOfObjects;i++){
         distance = MaxDistance;
         
         while(1){



         //misc.
            distance -= 0.1f;

         //controls
            SceCtrlData pad;

            sceCtrlReadBufferPositive(&pad, 1);

            if (pad.Buttons != 0){
               if (pad.Buttons & PSP_CTRL_CROSS){
                  // do next
                  if (iButtonX == FALSE){
                     iButtonX = TRUE;
                     break;
                  }
               }
            }
            else {
               iButtonX = FALSE;
            }

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


            Punt Hoekie[2];

            Hoekie[0].x = 0.0f;
            Hoekie[0].y = 0.0f;
            Hoekie[0].u = 0.0f;
            Hoekie[0].v = 0.0f;
            Hoekie[1].x = 90.0f;
            Hoekie[1].y = 90.0f;
            Hoekie[1].u = 1.0f;
            Hoekie[1].v = 1.0f;

            sceGuTexImage(0, Choice[0]->textureWidth, Choice[0]->textureHeight, Choice[0]->textureWidth, (void*)Choice[0]->data);
            sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,Hoekie);

            Hoekie[0].x = 0.0f;
            Hoekie[0].y = 90.0f;
            Hoekie[0].u = 0.0f;
            Hoekie[0].v = 0.0f;
            Hoekie[1].x = 90.0f;
            Hoekie[1].y = 180.0f;
            Hoekie[1].u = 1.0f;
            Hoekie[1].v = 1.0f;

            sceGuTexImage(0, Choice[1]->textureWidth, Choice[1]->textureHeight, Choice[1]->textureWidth, (void*)Choice[1]->data);
            sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,Hoekie);


            //blitImageToScreen(0 ,0 ,90 , 90, Choice[0], 0, 0);
            //blitImageToScreen(0 ,0 ,90 , 90, Choice[1], 0, 91);
            //blitImageToScreen(0 ,0 ,90 , 90, Choice[2], 0, 182);


            sceGuFinish();
            sceGuSync(0,0);
            sceDisplayWaitVblankStart();
            sceGuSwapBuffers();
         }


      }

   }



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
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Arwin



Joined: 12 Jul 2005
Posts: 426

PostPosted: Wed Oct 25, 2006 1:02 am    Post subject: Reply with quote

Sound like you may need to think about where you put the sceGuSwapBuffers() ?
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Wed Oct 25, 2006 10:58 pm    Post subject: Reply with quote

how do you mean exactly?
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group