taking out functions, casting failures

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

Moderators: cheriff, TyRaNiD

Post Reply
ruspa
Posts: 19
Joined: Thu Sep 13, 2007 11:17 pm
Location: Gorizia, ITALY

taking out functions, casting failures

Post by ruspa »

why in my code, having:

Code: Select all

void DrawScene( void )
{
    sceGuStart( GU_DIRECT, dList );                   
    sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);     
    sceGumMatrixMode(GU_MODEL);                               

      //----- shape 1
     sceGumLoadIdentity();                                     
     {	
	ScePspFVector3 move = { 0.0f,-0.05f, -3.1f };
	sceGumTranslate( &move );  
        sceGumRotateZ( 0.00f );	
      }
       
       sceGuTexImage(...); 
       sceGumDrawArray(...);

      //----- shape 2

     sceGumLoadIdentity();                                     
     {	
	ScePspFVector3 move = { 0.0f,-0.05f, -3.1f };
	sceGumTranslate( &move );  
        sceGumRotateZ( 0.00f );	
      }
       
       sceGuTexImage(...); 
       sceGumDrawArray(...);
       
      //----- shape 3

     sceGumLoadIdentity();                                     
     {	
	ScePspFVector3 move = { 0.0f,-0.05f, -3.1f };
	sceGumTranslate( &move );  
        sceGumRotateZ( 0.00f );	
      }
       
       sceGuTexImage(...); 
       sceGumDrawArray(...);
       
	sceGuFinish();
	sceGuSync(0,0);
        	
}
and I decide this is not professional and I made a common function this way:

Code: Select all

void DrawScene( void )
{
    sceGuStart( GU_DIRECT, dList );                   
    sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);     
    sceGumMatrixMode(GU_MODEL);   

    ruspa_draw(shape1,texture1,0);  
    ruspa_draw(shape2,texture2,0);
    ruspa_draw(shape3,texture3,0);

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

void ruspa_draw(Vertex shape,Image* texture,float rotation){
    
    sceGumLoadIdentity();                                     
        sceGuTexFilter( GU_LINEAR, GU_LINEAR );
        
		sceGuTexFilter( GU_LINEAR, GU_LINEAR );		
 
        {
		ScePspFVector3 move = { -0.03f,0.0f, -3.0f };
		
		sceGumTranslate( &move );                        
                
                sceGumRotateZ( rotation);				
       }
       
       sceGuTexImage( 0, texture->textureWidth, texture->textureHeight, texture->textureWidth,texture->data ); 
       sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,3*2, 0, shape);
    
    
}

this is not gonna compile? says me that cannot convert Vertex* to nonscalar "Vertex"... (tried also to specify the full "Vertex __attribute__((aligned(16)))" in the prototype, same result)
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Code: Select all

void ruspa_draw(Vertex shape, ...
Surely you want

Code: Select all

void ruspa_draw(Vertex *shape, ...
plus you'll need a prototype somewhere.
Silly mistake, or are you trying to learn C on the PSP? :)

Jim
ruspa
Posts: 19
Joined: Thu Sep 13, 2007 11:17 pm
Location: Gorizia, ITALY

Post by ruspa »

of course I set the prototype, I was used to code in C++ but abandoned it for very long. Hmm... I thought that if that was a vector also its definition should have the asterisk while in the example code there are no asterisk and no &s. Better for me to have a review of these basics.
Post Reply