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 

sceGuGetMemory Question

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



Joined: 11 Feb 2006
Posts: 13

PostPosted: Sun Apr 30, 2006 11:01 pm    Post subject: sceGuGetMemory Question Reply with quote

Hi

I was wondering if anyone here could help me..

I am trying to draw 40x22 Faces on the Screen and I can not get it to work.. It works fine with 32x18 and I strongly think I am simply having Memory allocation Problems:

Code:


#define FACE_MAX_W 40
#define FACE_MAX_H 22

typedef struct Vertex_Color
{
   unsigned int color;
   float x,y,z;
} Vertex_Color;

face_horizGridStep = FACE_MAX_W;
face_vertiGridStep = FACE_MAX_H;

   int res_horizStep = SCR_WIDTH/face_horizGridStep;
   int res_vertiStep = SCR_HEIGHT/face_vertiGridStep;

   Vertex_Color * faces = (struct Vertex_Color*)sceGuGetMemory(face_horizGridStep*face_vertiGridStep*6*sizeof(Vertex_Color));

   // Build the grid
   int counter = 0;
   int intcnt = 0;

   for (x = 0; x < face_horizGridStep; x++)
   {
      for (y = 0; y < face_vertiGridStep; y++)
      {                 
         faces[counter].color = GU_ABGR(0xff,0,0,0);
         faces[counter].x = (x * res_horizStep)+(intensity_map[intcnt]/4);
         faces[counter].y = (y * res_vertiStep)+(intensity_map[intcnt]/4);
         faces[counter++].z = 0;

         faces[counter].color = GU_ABGR(0xff,0,0,0);
         faces[counter].x = ((x + 1) * res_horizStep)-(intensity_map[intcnt]/4);
         faces[counter].y = (y * res_vertiStep)+(intensity_map[intcnt]/4);
         faces[counter++].z = 0;

         faces[counter].color = GU_ABGR(0xff,0,0,0);
         faces[counter].x = (x * res_horizStep)+(intensity_map[intcnt]/4);
         faces[counter].y = ((y + 1) * res_vertiStep)-(intensity_map[intcnt]/4);
         faces[counter++].z = 0;


         faces[counter].color = GU_ABGR(0xff,0,0,0);
         faces[counter].x = ((x + 1) * res_horizStep)-(intensity_map[intcnt]/4);
         faces[counter].y = (y * res_vertiStep)+(intensity_map[intcnt]/4);
         faces[counter++].z = 0;

         faces[counter].color = GU_ABGR(0xff,0,0,0);
         faces[counter].x = ((x + 1) * res_horizStep)-(intensity_map[intcnt]/4);
         faces[counter].y = ((y + 1) * res_vertiStep)-(intensity_map[intcnt]/4);
         faces[counter++].z = 0;

         faces[counter].color = GU_ABGR(0xff,0,0,0);
         faces[counter].x = (x * res_horizStep)+(intensity_map[intcnt]/4);
         faces[counter].y = ((y +1) * res_vertiStep)-(intensity_map[intcnt]/4);
         faces[counter++].z = 0;
         intcnt++;
      }
   }

   sceGumDrawArray(GU_TRIANGLES,GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,counter,0,faces);



sceGuGetMemory in this case is allocting 40*22*6*16 = 84480 Bytes which should by ok right?!?

The Max List Size (if that is of any concern here, I am quite unsure!) is the usual with 262144 (from the Samples)..

is sceGuGetMemory allocating in VRAM or standard RAM? How much is there to allocate and what's the maximum that can be done!?

Your help is greatly appreciated

Roland
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Mon May 01, 2006 3:51 pm    Post subject: Reply with quote

Code:
Vertex_Color * faces = (struct Vertex_Color*)sceGuGetMemory(face_horizGridStep*face_vertiGridStep*6*sizeof(Vertex_Color));

you define as a new type of Vertex_Color so you do not need the struct keyword for above casting

and just some notes:
Code:
void* sceGuGetMemory ( int size );

Note:
This function is NOT for permanent memory allocation, the memory will be invalid as soon as you start filling the same display list again.
_________________
10011011 00101010 11010111 10001001 10111010
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