Advertisement
xerpi

Untitled

Jun 9th, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1. extern void blitRotateToScreen(Image* source, int dx, int dy, float sW, float sH);
  2.  
  3.  
  4.  
  5.  
  6.  
  7. extern void blitRotateToScreen(Image* source, int dx, int dy, float sW, float sH)
  8. {
  9.     if (!initialized) return;
  10.  
  11.     sceKernelDcacheWritebackInvalidateAll();
  12.     guStart();
  13.     sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
  14.     float u = 1.0f / ((float)source->textureWidth);
  15.     float v = 1.0f / ((float)source->textureHeight);
  16.     sceGuTexScale(u, v);
  17.    
  18.     int j = 0;
  19.     while (j < source->imageWidth) {
  20.         Vertex* vertices = (Vertex*) sceGuGetMemory(2 * sizeof(Vertex));
  21.         int sliceWidth = 64;
  22.         if (j + sliceWidth > source->imageWidth) sliceWidth = source->imageWidth - j;
  23.         vertices[0].u = j;
  24.         vertices[0].v = 0;
  25.         vertices[0].x = (dx + j)*sW;
  26.         vertices[0].y = dy*sH;
  27.         vertices[0].z = 0;
  28.         vertices[1].u = j + sliceWidth;
  29.         vertices[1].v = source->imageHeight;
  30.         vertices[1].x = (dx + j + sliceWidth)*sW;
  31.         vertices[1].y = (dy + source->imageHeight)*sH;
  32.         vertices[1].z = 0;
  33.         sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
  34.         j += sliceWidth;
  35.     }
  36.    
  37.     sceGuFinish();
  38.     sceGuSync(0, 0);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement