this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added GPU_BlitRect() and GPU_BlitRectX().

+108 -11
+33 -5
include/SDL_gpu.h
··· 441 441 #define GPU_BATCH_XY_ST_RGBA (GPU_BATCH_XY | GPU_BATCH_ST | GPU_BATCH_RGBA) 442 442 #define GPU_BATCH_XYZ_ST_RGBA (GPU_BATCH_XYZ | GPU_BATCH_ST | GPU_BATCH_RGBA) 443 443 444 + 445 + /*! Bit flags for blitting into a rectangular region. 446 + * \see GPU_BlitRect 447 + * \see GPU_BlitRectX 448 + */ 449 + typedef Uint32 GPU_FlipEnum; 450 + static const GPU_FlipEnum GPU_FLIP_NONE = 0x0; 451 + static const GPU_FlipEnum GPU_FLIP_HORIZONTAL = 0x1; 452 + static const GPU_FlipEnum GPU_FLIP_VERTICAL = 0x2; 453 + 454 + 444 455 /*! \ingroup ShaderInterface 445 456 * Type enumeration for GPU_AttributeFormat specifications. 446 457 */ ··· 1251 1262 DECLSPEC void SDLCALL GPU_ClearRGBA(GPU_Target* target, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 1252 1263 1253 1264 /*! Draws the given image to the given render target. 1254 - * \param src_rect The region of the source image to use. 1265 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1255 1266 * \param x Destination x-position 1256 1267 * \param y Destination y-position */ 1257 1268 DECLSPEC void SDLCALL GPU_Blit(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y); 1258 1269 1259 1270 /*! Rotates and draws the given image to the given render target. 1260 - * \param src_rect The region of the source image to use. 1271 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1261 1272 * \param x Destination x-position 1262 1273 * \param y Destination y-position 1263 1274 * \param degrees Rotation angle (in degrees) */ 1264 1275 DECLSPEC void SDLCALL GPU_BlitRotate(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees); 1265 1276 1266 1277 /*! Scales and draws the given image to the given render target. 1267 - * \param src_rect The region of the source image to use. 1278 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1268 1279 * \param x Destination x-position 1269 1280 * \param y Destination y-position 1270 1281 * \param scaleX Horizontal stretch factor ··· 1272 1283 DECLSPEC void SDLCALL GPU_BlitScale(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float scaleX, float scaleY); 1273 1284 1274 1285 /*! Scales, rotates, and draws the given image to the given render target. 1275 - * \param src_rect The region of the source image to use. 1286 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1276 1287 * \param x Destination x-position 1277 1288 * \param y Destination y-position 1278 1289 * \param degrees Rotation angle (in degrees) ··· 1281 1292 DECLSPEC void SDLCALL GPU_BlitTransform(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees, float scaleX, float scaleY); 1282 1293 1283 1294 /*! Scales, rotates around a pivot point, and draws the given image to the given render target. The drawing point (x, y) coincides with the pivot point on the src image (pivot_x, pivot_y). 1284 - * \param src_rect The region of the source image to use. 1295 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1285 1296 * \param x Destination x-position 1286 1297 * \param y Destination y-position 1287 1298 * \param pivot_x Pivot x-position (in image coordinates) ··· 1290 1301 * \param scaleX Horizontal stretch factor 1291 1302 * \param scaleY Vertical stretch factor */ 1292 1303 DECLSPEC void SDLCALL GPU_BlitTransformX(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float pivot_x, float pivot_y, float degrees, float scaleX, float scaleY); 1304 + 1305 + /*! Draws the given image to the given render target, scaling it to fit the destination region. 1306 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1307 + * \param dest_rect The region of the destination target image to draw upon. Pass NULL for the entire target. 1308 + */ 1309 + DECLSPEC void SDLCALL GPU_BlitRect(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, GPU_Rect* dest_rect); 1310 + 1311 + /*! Draws the given image to the given render target, scaling it to fit the destination region. 1312 + * \param src_rect The region of the source image to use. Pass NULL for the entire image. 1313 + * \param dest_rect The region of the destination target image to draw upon. Pass NULL for the entire target. 1314 + * \param degrees Rotation angle (in degrees) 1315 + * \param pivot_x Pivot x-position (in image coordinates) 1316 + * \param pivot_y Pivot y-position (in image coordinates) 1317 + * \param flip_direction A GPU_FlipEnum value (or bitwise OR'd combination) that specifies which direction the image should be flipped. 1318 + */ 1319 + DECLSPEC void SDLCALL GPU_BlitRectX(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, GPU_Rect* dest_rect, float degrees, float pivot_x, float pivot_y, GPU_FlipEnum flip_direction); 1320 + 1293 1321 1294 1322 /*! Renders triangles from the given set of vertices. This lets you render arbitrary 2D geometry. It is a direct path to the GPU, so the format is different than typical SDL_gpu calls. 1295 1323 * \param values A tightly-packed array of vertex position (e.g. x,y), texture coordinates (e.g. s,t), and color (e.g. r,g,b,a) values. Texture coordinates and color values are expected to be already normalized to 0.0 - 1.0. Pass NULL to render with only custom shader attributes.
+75 -6
src/SDL_gpu.c
··· 1279 1279 } 1280 1280 1281 1281 1282 - void GPU_BlitRotate(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float angle) 1282 + void GPU_BlitRotate(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees) 1283 1283 { 1284 1284 if(!CHECK_RENDERER) 1285 1285 RETURN_ERROR(GPU_ERROR_USER_ERROR, "NULL renderer"); ··· 1292 1292 if(target == NULL) 1293 1293 RETURN_ERROR(GPU_ERROR_NULL_ARGUMENT, "target"); 1294 1294 1295 - _gpu_current_renderer->impl->BlitRotate(_gpu_current_renderer, image, src_rect, target, x, y, angle); 1295 + _gpu_current_renderer->impl->BlitRotate(_gpu_current_renderer, image, src_rect, target, x, y, degrees); 1296 1296 } 1297 1297 1298 1298 void GPU_BlitScale(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float scaleX, float scaleY) ··· 1311 1311 _gpu_current_renderer->impl->BlitScale(_gpu_current_renderer, image, src_rect, target, x, y, scaleX, scaleY); 1312 1312 } 1313 1313 1314 - void GPU_BlitTransform(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float angle, float scaleX, float scaleY) 1314 + void GPU_BlitTransform(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees, float scaleX, float scaleY) 1315 1315 { 1316 1316 if(!CHECK_RENDERER) 1317 1317 RETURN_ERROR(GPU_ERROR_USER_ERROR, "NULL renderer"); ··· 1324 1324 if(target == NULL) 1325 1325 RETURN_ERROR(GPU_ERROR_NULL_ARGUMENT, "target"); 1326 1326 1327 - _gpu_current_renderer->impl->BlitTransform(_gpu_current_renderer, image, src_rect, target, x, y, angle, scaleX, scaleY); 1327 + _gpu_current_renderer->impl->BlitTransform(_gpu_current_renderer, image, src_rect, target, x, y, degrees, scaleX, scaleY); 1328 1328 } 1329 1329 1330 - void GPU_BlitTransformX(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float pivot_x, float pivot_y, float angle, float scaleX, float scaleY) 1330 + void GPU_BlitTransformX(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float pivot_x, float pivot_y, float degrees, float scaleX, float scaleY) 1331 1331 { 1332 1332 if(!CHECK_RENDERER) 1333 1333 RETURN_ERROR(GPU_ERROR_USER_ERROR, "NULL renderer"); ··· 1340 1340 if(target == NULL) 1341 1341 RETURN_ERROR(GPU_ERROR_NULL_ARGUMENT, "target"); 1342 1342 1343 - _gpu_current_renderer->impl->BlitTransformX(_gpu_current_renderer, image, src_rect, target, x, y, pivot_x, pivot_y, angle, scaleX, scaleY); 1343 + _gpu_current_renderer->impl->BlitTransformX(_gpu_current_renderer, image, src_rect, target, x, y, pivot_x, pivot_y, degrees, scaleX, scaleY); 1344 + } 1345 + 1346 + void GPU_BlitRect(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, GPU_Rect* dest_rect) 1347 + { 1348 + float w = 0.0f; 1349 + float h = 0.0f; 1350 + 1351 + if(image == NULL) 1352 + return; 1353 + 1354 + if(src_rect == NULL) 1355 + { 1356 + w = image->w; 1357 + h = image->h; 1358 + } 1359 + else 1360 + { 1361 + w = src_rect->w; 1362 + h = src_rect->h; 1363 + } 1364 + 1365 + GPU_BlitRectX(image, src_rect, target, dest_rect, 0.0f, w*0.5f, h*0.5f, GPU_FLIP_NONE); 1366 + } 1367 + 1368 + void GPU_BlitRectX(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, GPU_Rect* dest_rect, float degrees, float pivot_x, float pivot_y, GPU_FlipEnum flip_direction) 1369 + { 1370 + float w, h; 1371 + float dx, dy; 1372 + float dw, dh; 1373 + float scale_x, scale_y; 1374 + 1375 + if(image == NULL || target == NULL) 1376 + return; 1377 + 1378 + if(src_rect == NULL) 1379 + { 1380 + w = image->w; 1381 + h = image->h; 1382 + } 1383 + else 1384 + { 1385 + w = src_rect->w; 1386 + h = src_rect->h; 1387 + } 1388 + 1389 + if(dest_rect == NULL) 1390 + { 1391 + dx = 0.0f; 1392 + dy = 0.0f; 1393 + dw = target->w; 1394 + dh = target->h; 1395 + } 1396 + else 1397 + { 1398 + dx = dest_rect->x; 1399 + dy = dest_rect->y; 1400 + dw = dest_rect->w; 1401 + dh = dest_rect->h; 1402 + } 1403 + 1404 + scale_x = dw / w; 1405 + scale_y = dh / h; 1406 + 1407 + if(flip_direction & GPU_FLIP_HORIZONTAL) 1408 + scale_x = -scale_x; 1409 + if(flip_direction & GPU_FLIP_VERTICAL) 1410 + scale_y = -scale_y; 1411 + 1412 + GPU_BlitTransformX(image, src_rect, target, dx + pivot_x, dy + pivot_y, pivot_x, pivot_y, degrees, scale_x, scale_y); 1344 1413 } 1345 1414 1346 1415 void GPU_TriangleBatch(GPU_Image* image, GPU_Target* target, unsigned short num_vertices, float* values, unsigned int num_indices, unsigned short* indices, GPU_BatchFlagEnum flags)