Advertisement
xerpi

Untitled

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