@@ -260,37 +260,39 @@ static int calculateBestSliceSizeForTexture(SDL_Texture *texture, SliceSize *uvS
260
260
static void fillSpriteVertices (VertTV * vertices , SliceSize * dimensions , SliceSize * sliceSize ,
261
261
const SDL_Rect * srcrect , const SDL_FRect * dstrect ) {
262
262
int i , j ;
263
- float dstrectSlizeWidth = dstrect -> w / dimensions -> width ;
264
- float dstrectSlizeHeight = dstrect -> h / dimensions -> height ;
265
263
int remainingWidth = srcrect -> w % sliceSize -> width ;
266
264
int remainingHeight = srcrect -> h % sliceSize -> height ;
267
265
int hasRemainingWidth = remainingWidth > 0 ;
268
266
int hasRemainingHeight = remainingHeight > 0 ;
267
+ float dstrectRateWidth = (float )(abs (dstrect -> w - dimensions -> width )) / (float )(abs (srcrect -> w - dimensions -> width ));
268
+ float dstrectRateHeight = (float )(abs (dstrect -> h - dimensions -> height )) / (float )(abs (srcrect -> h - dimensions -> height ));
269
269
270
270
int verticesCount = dimensions -> width * dimensions -> height * 2 ;
271
271
for (i = 0 ; i < dimensions -> width ; i ++ ) {
272
272
for (j = 0 ; j < dimensions -> height ; j ++ ) {
273
273
uint8_t currentIndex = (i * dimensions -> height + j ) * 2 ;
274
274
vertices [currentIndex ].u = srcrect -> x + i * sliceSize -> width ;
275
275
vertices [currentIndex ].v = srcrect -> y + j * sliceSize -> height ;
276
- vertices [currentIndex ].x = dstrect -> x + i * dstrectSlizeWidth ;
277
- vertices [currentIndex ].y = dstrect -> y + j * dstrectSlizeHeight ;
276
+ vertices [currentIndex ].x = dstrect -> x + i * sliceSize -> width * dstrectRateWidth ;
277
+ vertices [currentIndex ].y = dstrect -> y + j * sliceSize -> height * dstrectRateHeight ;
278
278
vertices [currentIndex ].z = 0 ;
279
279
280
280
if (i == dimensions -> width - 1 && hasRemainingWidth ) {
281
281
vertices [currentIndex + 1 ].u = srcrect -> x + i * sliceSize -> width + remainingWidth ;
282
+ vertices [currentIndex + 1 ].x = dstrect -> x + i * (sliceSize -> width * dstrectRateWidth ) + remainingWidth * dstrectRateWidth ;
282
283
} else {
283
284
vertices [currentIndex + 1 ].u = (srcrect -> x + (i + 1 ) * sliceSize -> width );
285
+ vertices [currentIndex + 1 ].x = dstrect -> x + (i + 1 ) * sliceSize -> width * dstrectRateWidth ;
284
286
}
285
287
286
288
if (j == dimensions -> height - 1 && hasRemainingHeight ) {
287
289
vertices [currentIndex + 1 ].v = srcrect -> y + j * sliceSize -> height + remainingHeight ;
290
+ vertices [currentIndex + 1 ].y = dstrect -> y + j * sliceSize -> height * dstrectRateHeight + remainingHeight * dstrectRateHeight ;
288
291
} else {
289
292
vertices [currentIndex + 1 ].v = (srcrect -> y + (j + 1 ) * sliceSize -> height );
293
+ vertices [currentIndex + 1 ].y = dstrect -> y + (j + 1 ) * sliceSize -> height * dstrectRateHeight ;
290
294
}
291
295
292
- vertices [currentIndex + 1 ].x = dstrect -> x + (i + 1 ) * dstrectSlizeWidth ;
293
- vertices [currentIndex + 1 ].y = dstrect -> y + (j + 1 ) * dstrectSlizeHeight ;
294
296
vertices [currentIndex + 1 ].z = 0 ;
295
297
}
296
298
}
@@ -518,8 +520,8 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
518
520
// We need to split in slices because we have a texture bigger than 64 pixel width
519
521
if (texture ) {
520
522
SliceSize sliceSize , sliceDimension , uvSize ;
521
- uvSize .width = abs (u1 ) - abs ( u0 );
522
- uvSize .height = abs (v1 ) - abs ( v0 );
523
+ uvSize .width = abs (u1 - u0 );
524
+ uvSize .height = abs (v1 - v0 );
523
525
if (calculateBestSliceSizeForTexture (texture , & uvSize , & sliceSize , & sliceDimension ))
524
526
return -1 ;
525
527
0 commit comments