Advertisement
xerpi

draw rotate psp GU

Mar 14th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1. void ya2d_drawRotateTexture(ya2d_Texture *texp, int x, int y, float angle)
  2. {
  3.     if(!texp->data) return;
  4.  
  5.     sceGuEnable(GU_TEXTURE_2D);
  6.    
  7.     sceGumMatrixMode(GU_TEXTURE);
  8.     sceGumPushMatrix();
  9.     sceGumLoadIdentity();
  10.    
  11.     ScePspFVector3 trans = (ScePspFVector3){(float)x, (float)y, 0.0f};
  12.     sceGumTranslate(&trans);
  13.  
  14.     sceGumUpdateMatrix();
  15.  
  16.     if(texp->hasAlpha)
  17.         sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
  18.     else
  19.         sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
  20.  
  21.     sceGuTexImage(0, texp->textureWidth, texp->textureHeight, texp->textureWidth, texp->data);
  22.  
  23.     ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_TextureVertex));
  24.  
  25.     vertices[0] = (ya2d_TextureVertex){0, 0, 0, 0};
  26.     vertices[1] = (ya2d_TextureVertex){texp->textureWidth, 0, texp->textureWidth, 0};
  27.     vertices[2] = (ya2d_TextureVertex){0, texp->textureHeight, 0, texp->textureHeight};
  28.     vertices[3] = (ya2d_TextureVertex){texp->textureWidth, texp->textureHeight, texp->textureWidth, texp->textureHeight};
  29.  
  30.     sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices);
  31.  
  32.     sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_TextureVertex));
  33.     sceGumPopMatrix();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement