2 #include "SDL_platform.h"
5 #include <android/log.h>
9 #define __func__ __FUNCTION__
14 #ifdef SDL_GPU_USE_SDL2
15 #define GET_ALPHA(sdl_color) ((sdl_color).a)
17 #define GET_ALPHA(sdl_color) ((sdl_color).unused)
20 #define CHECK_RENDERER (current_renderer != NULL)
21 #define CHECK_CONTEXT (current_renderer->current_context_target != NULL)
22 #define CHECK_FUNCTION_POINTER(fn) (current_renderer->fn != NULL)
23 #define RETURN_ERROR(code, details) do{ GPU_PushErrorCode(__func__, code, "%s", details); return; } while(0)
31 #define GPU_MAX_NUM_ERRORS 20
32 #define GPU_ERROR_FUNCTION_STRING_MAX 128
33 #define GPU_ERROR_DETAILS_STRING_MAX 512
45 #define GPU_INITIAL_WINDOW_MAPPINGS_SIZE 10
60 if(current_renderer != NULL && current_renderer->
SetAsCurrent != NULL)
82 va_start(args, format);
94 va_start(args, format);
106 va_start(args, format);
108 __android_log_vprint(ANDROID_LOG_ERROR,
"APPLICATION", format, args);
110 vfprintf(stderr, format, args);
120 Uint32 subsystems = SDL_WasInit(SDL_INIT_EVERYTHING);
124 if(SDL_Init(SDL_INIT_VIDEO) < 0)
130 else if(!(subsystems & SDL_INIT_VIDEO))
133 if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
183 if(window_mappings == NULL)
196 if(window_mappings == NULL)
199 if(target == NULL || target->
context == NULL)
209 if(window_mappings[i].windowID == windowID)
211 if(window_mappings[i].target != target)
224 memcpy(new_array, window_mappings, num_window_mappings *
sizeof(
GPU_WindowMapping));
225 free(window_mappings);
226 window_mappings = new_array;
234 num_window_mappings++;
241 if(window_mappings == NULL)
250 if(window_mappings[i].windowID == windowID)
258 num_window_mappings--;
259 num_to_move = num_window_mappings -
i;
261 memmove(&window_mappings[i], &window_mappings[i+1], num_to_move *
sizeof(
GPU_WindowMapping));
273 if(window_mappings == NULL)
276 if(target == NULL || target->
context == NULL)
289 if(window_mappings[i].target == target)
293 num_window_mappings--;
294 num_to_move = num_window_mappings -
i;
296 memmove(&window_mappings[i], &window_mappings[i+1], num_to_move *
sizeof(
GPU_WindowMapping));
309 if(window_mappings == NULL)
318 if(window_mappings[i].windowID == windowID)
319 return window_mappings[
i].
target;
338 renderer_order_size = 0;
369 if(renderer == NULL || renderer->
Init == NULL)
374 screen = renderer->
Init(renderer, renderer_request, w, h, SDL_flags);
416 current_renderer->
MakeCurrent(current_renderer, target, windowID);
424 return current_renderer->
ToggleFullscreen(current_renderer, use_desktop_resolution);
454 if(current_renderer == NULL)
457 if(current_renderer->
Quit != NULL)
458 current_renderer->
Quit(current_renderer);
460 current_renderer = NULL;
472 free(error_code_stack[i].
function);
474 free(error_code_stack[i].details);
480 if(current_renderer == NULL)
483 if(current_renderer->
Quit != NULL)
484 current_renderer->
Quit(current_renderer);
512 va_start(lst, details);
537 va_start(lst, details);
563 return "BACKEND ERROR";
569 return "UNSUPPORTED FUNCTION";
571 return "NULL ARGUMENT";
573 return "FILE NOT FOUND";
575 return "UNKNOWN ERROR";
591 else if(target->
image != NULL)
594 *x = (displayX*target->
w)/target->
image->
w;
596 *y = (displayY*target->
h)/target->
image->
h;
615 SDL_Color
c = {
r,
g,
b, a};
633 GPU_Camera cam = {0.0f, 0.0f, -10.0f, 0.0f, 1.0f};
649 return current_renderer->
SetCamera(current_renderer, target, cam);
657 return current_renderer->
CreateImage(current_renderer, w, h, format);
665 return current_renderer->
LoadImage(current_renderer, filename);
681 return current_renderer->
SaveImage(current_renderer, image, filename);
689 return current_renderer->
CopyImage(current_renderer, image);
697 current_renderer->
UpdateImage(current_renderer, image, surface, surface_rect);
705 current_renderer->
UpdateSubImage(current_renderer, image, image_rect, surface, surface_rect);
713 current_renderer->
UpdateImageBytes(current_renderer, image, image_rect, bytes, bytes_per_row);
719 Uint32 Rmask, Gmask, Bmask, Amask = 0;
730 if(strlen(filename) > 0 && filename[0] !=
'/')
733 SDL_RWops* rwops = SDL_RWFromFile(filename,
"r");
736 int data_bytes = SDL_RWseek(rwops, 0, SEEK_END);
737 SDL_RWseek(rwops, 0, SEEK_SET);
738 unsigned char* c_data = (
unsigned char*)malloc(data_bytes);
739 SDL_RWread(rwops, c_data, 1, data_bytes);
747 data =
stbi_load(filename, &width, &height, &channels, 0);
750 data =
stbi_load(filename, &width, &height, &channels, 0);
758 if(channels < 1 || channels > 4)
768 Rmask = Gmask = Bmask = 0;
771 Rmask = Gmask = Bmask = 0;
775 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
793 result = SDL_CreateRGBSurfaceFrom(data, width, height, channels*8, width*channels, Rmask, Gmask, Bmask, Amask);
804 const char *dot = strrchr(filename,
'.');
805 if(!dot || dot == filename)
812 const char* extension;
816 if(surface == NULL || filename == NULL ||
817 surface->w < 1 || surface->h < 1)
824 data = surface->pixels;
826 if(SDL_strcasecmp(extension,
"png") == 0)
827 result =
stbi_write_png(filename, surface->w, surface->h, surface->format->BytesPerPixel, (
const unsigned char *
const)data, 0);
828 else if(SDL_strcasecmp(extension,
"bmp") == 0)
829 result =
stbi_write_bmp(filename, surface->w, surface->h, surface->format->BytesPerPixel, (
void*)data);
830 else if(SDL_strcasecmp(extension,
"tga") == 0)
831 result =
stbi_write_tga(filename, surface->w, surface->h, surface->format->BytesPerPixel, (
void*)data);
878 current_renderer->
FreeImage(current_renderer, image);
884 if(current_renderer == NULL)
896 return current_renderer->
LoadTarget(current_renderer, image);
906 current_renderer->
FreeTarget(current_renderer, target);
925 current_renderer->
Blit(current_renderer, image, src_rect, target, x, y);
943 current_renderer->
BlitRotate(current_renderer, image, src_rect, target, x, y, angle);
960 current_renderer->
BlitScale(current_renderer, image, src_rect, target, x, y, scaleX, scaleY);
977 current_renderer->
BlitTransform(current_renderer, image, src_rect, target, x, y, angle, scaleX, scaleY);
994 current_renderer->
BlitTransformX(current_renderer, image, src_rect, target, x, y, pivot_x, pivot_y, angle, scaleX, scaleY);
1011 if(matrix3x3 == NULL)
1014 current_renderer->
BlitTransformMatrix(current_renderer, image, src_rect, target, x, y, matrix3x3);
1019 int src_position_floats_per_sprite;
1020 int src_rect_floats_per_sprite;
1021 int src_color_floats_per_sprite;
1026 Uint8 pass_vertices;
1027 Uint8 pass_texcoords;
1030 int src_floats_per_sprite;
1045 int floats_per_vertex;
1065 if(num_sprites == 0)
1071 current_renderer->
BlitBatch(current_renderer, image, target, num_sprites, values, flags);
1081 src_position_floats_per_sprite = 2;
1082 src_rect_floats_per_sprite = 4;
1083 src_color_floats_per_sprite = 4;
1100 src_position_floats_per_sprite = 8;
1102 src_rect_floats_per_sprite = 8;
1104 src_color_floats_per_sprite = 16;
1106 src_position_floats_per_sprite = 0;
1108 src_rect_floats_per_sprite = 0;
1110 src_color_floats_per_sprite = 0;
1112 src_floats_per_sprite = src_position_floats_per_sprite + src_rect_floats_per_sprite + src_color_floats_per_sprite;
1114 size = num_sprites*(8 + 8 + 16);
1115 new_values = (
float*)malloc(
sizeof(
float)*
size);
1119 rect_n = src_position_floats_per_sprite;
1120 color_n = src_position_floats_per_sprite + src_rect_floats_per_sprite;
1126 floats_per_vertex = 8;
1134 for(n = 0; n < num_sprites; n++)
1138 new_values[texcoord_i] = 0.0f;
1139 new_values[texcoord_i+1] = 0.0f;
1140 texcoord_i += floats_per_vertex;
1141 new_values[texcoord_i] = 1.0f;
1142 new_values[texcoord_i+1] = 0.0f;
1143 texcoord_i += floats_per_vertex;
1144 new_values[texcoord_i] = 1.0f;
1145 new_values[texcoord_i+1] = 1.0f;
1146 texcoord_i += floats_per_vertex;
1147 new_values[texcoord_i] = 0.0f;
1148 new_values[texcoord_i+1] = 1.0f;
1149 texcoord_i += floats_per_vertex;
1155 float s1 = values[rect_n]/tex_w;
1156 float t1 = values[rect_n+1]/tex_h;
1157 float s3 = s1 + values[rect_n+2]/tex_w;
1158 float t3 = t1 + values[rect_n+3]/tex_h;
1159 rect_n += src_floats_per_sprite;
1161 new_values[texcoord_i] = s1;
1162 new_values[texcoord_i+1] = t1;
1163 texcoord_i += floats_per_vertex;
1164 new_values[texcoord_i] = s3;
1165 new_values[texcoord_i+1] = t1;
1166 texcoord_i += floats_per_vertex;
1167 new_values[texcoord_i] = s3;
1168 new_values[texcoord_i+1] = t3;
1169 texcoord_i += floats_per_vertex;
1170 new_values[texcoord_i] = s1;
1171 new_values[texcoord_i+1] = t3;
1172 texcoord_i += floats_per_vertex;
1176 w2 = 0.5f*(s3-s1)*image->
w;
1177 h2 = 0.5f*(t3-t1)*image->
h;
1183 float s1, t1, s3, t3;
1184 s1 = new_values[texcoord_i] = values[rect_n];
1185 t1 = new_values[texcoord_i+1] = values[rect_n+1];
1186 texcoord_i += floats_per_vertex;
1187 new_values[texcoord_i] = values[rect_n+2];
1188 new_values[texcoord_i+1] = values[rect_n+3];
1189 texcoord_i += floats_per_vertex;
1190 s3 = new_values[texcoord_i] = values[rect_n+4];
1191 t3 = new_values[texcoord_i+1] = values[rect_n+5];
1192 texcoord_i += floats_per_vertex;
1193 new_values[texcoord_i] = values[rect_n+6];
1194 new_values[texcoord_i+1] = values[rect_n+7];
1195 texcoord_i += floats_per_vertex;
1196 rect_n += src_floats_per_sprite;
1200 w2 = 0.5f*(s3-s1)*image->
w;
1201 h2 = 0.5f*(t3-t1)*image->
h;
1208 new_values[vert_i] = 0.0f;
1209 new_values[vert_i+1] = 0.0f;
1210 vert_i += floats_per_vertex;
1211 new_values[vert_i] = 0.0f;
1212 new_values[vert_i+1] = 0.0f;
1213 vert_i += floats_per_vertex;
1214 new_values[vert_i] = 0.0f;
1215 new_values[vert_i+1] = 0.0f;
1216 vert_i += floats_per_vertex;
1217 new_values[vert_i] = 0.0f;
1218 new_values[vert_i+1] = 0.0f;
1219 vert_i += floats_per_vertex;
1226 float x = values[pos_n];
1227 float y = values[pos_n+1];
1228 pos_n += src_floats_per_sprite;
1230 new_values[vert_i] = x - w2;
1231 new_values[vert_i+1] = y - h2;
1232 vert_i += floats_per_vertex;
1233 new_values[vert_i] = x + w2;
1234 new_values[vert_i+1] = y - h2;
1235 vert_i += floats_per_vertex;
1236 new_values[vert_i] = x + w2;
1237 new_values[vert_i+1] = y + h2;
1238 vert_i += floats_per_vertex;
1239 new_values[vert_i] = x - w2;
1240 new_values[vert_i+1] = y + h2;
1241 vert_i += floats_per_vertex;
1246 new_values[vert_i] = values[pos_n];
1247 new_values[vert_i+1] = values[pos_n+1];
1248 vert_i += floats_per_vertex;
1249 new_values[vert_i] = values[pos_n+2];
1250 new_values[vert_i+1] = values[pos_n+3];
1251 vert_i += floats_per_vertex;
1252 new_values[vert_i] = values[pos_n+4];
1253 new_values[vert_i+1] = values[pos_n+5];
1254 vert_i += floats_per_vertex;
1255 new_values[vert_i] = values[pos_n+6];
1256 new_values[vert_i+1] = values[pos_n+7];
1257 vert_i += floats_per_vertex;
1258 pos_n += src_floats_per_sprite;
1264 new_values[color_i] = 1.0f;
1265 new_values[color_i+1] = 1.0f;
1266 new_values[color_i+2] = 1.0f;
1267 new_values[color_i+3] = 1.0f;
1268 color_i += floats_per_vertex;
1269 new_values[color_i] = 1.0f;
1270 new_values[color_i+1] = 1.0f;
1271 new_values[color_i+2] = 1.0f;
1272 new_values[color_i+3] = 1.0f;
1273 color_i += floats_per_vertex;
1274 new_values[color_i] = 1.0f;
1275 new_values[color_i+1] = 1.0f;
1276 new_values[color_i+2] = 1.0f;
1277 new_values[color_i+3] = 1.0f;
1278 color_i += floats_per_vertex;
1279 new_values[color_i] = 1.0f;
1280 new_values[color_i+1] = 1.0f;
1281 new_values[color_i+2] = 1.0f;
1282 new_values[color_i+3] = 1.0f;
1283 color_i += floats_per_vertex;
1289 float r = values[color_n]/255.0f;
1290 float g = values[color_n+1]/255.0f;
1291 float b = values[color_n+2]/255.0f;
1292 float a = values[color_n+3]/255.0f;
1293 color_n += src_floats_per_sprite;
1295 new_values[color_i] =
r;
1296 new_values[color_i+1] =
g;
1297 new_values[color_i+2] =
b;
1298 new_values[color_i+3] =
a;
1299 color_i += floats_per_vertex;
1300 new_values[color_i] =
r;
1301 new_values[color_i+1] =
g;
1302 new_values[color_i+2] =
b;
1303 new_values[color_i+3] =
a;
1304 color_i += floats_per_vertex;
1305 new_values[color_i] =
r;
1306 new_values[color_i+1] =
g;
1307 new_values[color_i+2] =
b;
1308 new_values[color_i+3] =
a;
1309 color_i += floats_per_vertex;
1310 new_values[color_i] =
r;
1311 new_values[color_i+1] =
g;
1312 new_values[color_i+2] =
b;
1313 new_values[color_i+3] =
a;
1314 color_i += floats_per_vertex;
1319 new_values[color_i] = values[color_n];
1320 new_values[color_i+1] = values[color_n+1];
1321 new_values[color_i+2] = values[color_n+2];
1322 new_values[color_i+3] = values[color_n+3];
1323 color_i += floats_per_vertex;
1324 new_values[color_i] = values[color_n+4];
1325 new_values[color_i+1] = values[color_n+5];
1326 new_values[color_i+2] = values[color_n+6];
1327 new_values[color_i+3] = values[color_n+7];
1328 color_i += floats_per_vertex;
1329 new_values[color_i] = values[color_n+8];
1330 new_values[color_i+1] = values[color_n+9];
1331 new_values[color_i+2] = values[color_n+10];
1332 new_values[color_i+3] = values[color_n+11];
1333 color_i += floats_per_vertex;
1334 new_values[color_i] = values[color_n+12];
1335 new_values[color_i+1] = values[color_n+13];
1336 new_values[color_i+2] = values[color_n+14];
1337 new_values[color_i+3] = values[color_n+15];
1338 color_i += floats_per_vertex;
1339 color_n += src_floats_per_sprite;
1344 current_renderer->
BlitBatch(current_renderer, image, target, num_sprites, new_values, flags | GPU_PASSTHROUGH_ALL);
1351 Uint8 pass_vertices;
1352 Uint8 pass_texcoords;
1368 int floats_per_vertex;
1388 if(num_sprites == 0)
1392 if(positions == NULL && src_rects == NULL && colors == NULL)
1394 current_renderer->
BlitBatch(current_renderer, image, target, num_sprites, NULL, flags);
1405 size = num_sprites*(8 + 8 + 16);
1406 values = (
float*)malloc(
sizeof(
float)*
size);
1417 floats_per_vertex = 8;
1425 for(n = 0; n < num_sprites; n++)
1429 if(src_rects == NULL)
1431 values[texcoord_i] = 0.0f;
1432 values[texcoord_i+1] = 0.0f;
1433 texcoord_i += floats_per_vertex;
1434 values[texcoord_i] = 1.0f;
1435 values[texcoord_i+1] = 0.0f;
1436 texcoord_i += floats_per_vertex;
1437 values[texcoord_i] = 1.0f;
1438 values[texcoord_i+1] = 1.0f;
1439 texcoord_i += floats_per_vertex;
1440 values[texcoord_i] = 0.0f;
1441 values[texcoord_i+1] = 1.0f;
1442 texcoord_i += floats_per_vertex;
1448 float s1 = src_rects[rect_n++]/tex_w;
1449 float t1 = src_rects[rect_n++]/tex_h;
1450 float s3 = s1 + src_rects[rect_n++]/tex_w;
1451 float t3 = t1 + src_rects[rect_n++]/tex_h;
1453 values[texcoord_i] = s1;
1454 values[texcoord_i+1] = t1;
1455 texcoord_i += floats_per_vertex;
1456 values[texcoord_i] = s3;
1457 values[texcoord_i+1] = t1;
1458 texcoord_i += floats_per_vertex;
1459 values[texcoord_i] = s3;
1460 values[texcoord_i+1] = t3;
1461 texcoord_i += floats_per_vertex;
1462 values[texcoord_i] = s1;
1463 values[texcoord_i+1] = t3;
1464 texcoord_i += floats_per_vertex;
1468 w2 = 0.5f*(s3-s1)*image->
w;
1469 h2 = 0.5f*(t3-t1)*image->
h;
1475 float s1, t1, s3, t3;
1476 s1 = values[texcoord_i] = src_rects[rect_n++];
1477 t1 = values[texcoord_i+1] = src_rects[rect_n++];
1478 texcoord_i += floats_per_vertex;
1479 values[texcoord_i] = src_rects[rect_n++];
1480 values[texcoord_i+1] = src_rects[rect_n++];
1481 texcoord_i += floats_per_vertex;
1482 s3 = values[texcoord_i] = src_rects[rect_n++];
1483 t3 = values[texcoord_i+1] = src_rects[rect_n++];
1484 texcoord_i += floats_per_vertex;
1485 values[texcoord_i] = src_rects[rect_n++];
1486 values[texcoord_i+1] = src_rects[rect_n++];
1487 texcoord_i += floats_per_vertex;
1491 w2 = 0.5f*(s3-s1)*image->
w;
1492 h2 = 0.5f*(t3-t1)*image->
h;
1497 if(positions == NULL)
1499 values[vert_i] = 0.0f;
1500 values[vert_i+1] = 0.0f;
1501 vert_i += floats_per_vertex;
1502 values[vert_i] = 0.0f;
1503 values[vert_i+1] = 0.0f;
1504 vert_i += floats_per_vertex;
1505 values[vert_i] = 0.0f;
1506 values[vert_i+1] = 0.0f;
1507 vert_i += floats_per_vertex;
1508 values[vert_i] = 0.0f;
1509 values[vert_i+1] = 0.0f;
1510 vert_i += floats_per_vertex;
1517 float x = positions[pos_n++];
1518 float y = positions[pos_n++];
1519 values[vert_i] = x - w2;
1520 values[vert_i+1] = y - h2;
1521 vert_i += floats_per_vertex;
1522 values[vert_i] = x + w2;
1523 values[vert_i+1] = y - h2;
1524 vert_i += floats_per_vertex;
1525 values[vert_i] = x + w2;
1526 values[vert_i+1] = y + h2;
1527 vert_i += floats_per_vertex;
1528 values[vert_i] = x - w2;
1529 values[vert_i+1] = y + h2;
1530 vert_i += floats_per_vertex;
1535 values[vert_i] = positions[pos_n++];
1536 values[vert_i+1] = positions[pos_n++];
1537 vert_i += floats_per_vertex;
1538 values[vert_i] = positions[pos_n++];
1539 values[vert_i+1] = positions[pos_n++];
1540 vert_i += floats_per_vertex;
1541 values[vert_i] = positions[pos_n++];
1542 values[vert_i+1] = positions[pos_n++];
1543 vert_i += floats_per_vertex;
1544 values[vert_i] = positions[pos_n++];
1545 values[vert_i+1] = positions[pos_n++];
1546 vert_i += floats_per_vertex;
1552 values[color_i] = 1.0f;
1553 values[color_i+1] = 1.0f;
1554 values[color_i+2] = 1.0f;
1555 values[color_i+3] = 1.0f;
1556 color_i += floats_per_vertex;
1557 values[color_i] = 1.0f;
1558 values[color_i+1] = 1.0f;
1559 values[color_i+2] = 1.0f;
1560 values[color_i+3] = 1.0f;
1561 color_i += floats_per_vertex;
1562 values[color_i] = 1.0f;
1563 values[color_i+1] = 1.0f;
1564 values[color_i+2] = 1.0f;
1565 values[color_i+3] = 1.0f;
1566 color_i += floats_per_vertex;
1567 values[color_i] = 1.0f;
1568 values[color_i+1] = 1.0f;
1569 values[color_i+2] = 1.0f;
1570 values[color_i+3] = 1.0f;
1571 color_i += floats_per_vertex;
1577 float r = colors[color_n++]/255.0f;
1578 float g = colors[color_n++]/255.0f;
1579 float b = colors[color_n++]/255.0f;
1580 float a = colors[color_n++]/255.0f;
1582 values[color_i] =
r;
1583 values[color_i+1] =
g;
1584 values[color_i+2] =
b;
1585 values[color_i+3] =
a;
1586 color_i += floats_per_vertex;
1587 values[color_i] =
r;
1588 values[color_i+1] =
g;
1589 values[color_i+2] =
b;
1590 values[color_i+3] =
a;
1591 color_i += floats_per_vertex;
1592 values[color_i] =
r;
1593 values[color_i+1] =
g;
1594 values[color_i+2] =
b;
1595 values[color_i+3] =
a;
1596 color_i += floats_per_vertex;
1597 values[color_i] =
r;
1598 values[color_i+1] =
g;
1599 values[color_i+2] =
b;
1600 values[color_i+3] =
a;
1601 color_i += floats_per_vertex;
1606 values[color_i] = colors[color_n++];
1607 values[color_i+1] = colors[color_n++];
1608 values[color_i+2] = colors[color_n++];
1609 values[color_i+3] = colors[color_n++];
1610 color_i += floats_per_vertex;
1611 values[color_i] = colors[color_n++];
1612 values[color_i+1] = colors[color_n++];
1613 values[color_i+2] = colors[color_n++];
1614 values[color_i+3] = colors[color_n++];
1615 color_i += floats_per_vertex;
1616 values[color_i] = colors[color_n++];
1617 values[color_i+1] = colors[color_n++];
1618 values[color_i+2] = colors[color_n++];
1619 values[color_i+3] = colors[color_n++];
1620 color_i += floats_per_vertex;
1621 values[color_i] = colors[color_n++];
1622 values[color_i+1] = colors[color_n++];
1623 values[color_i+2] = colors[color_n++];
1624 values[color_i+3] = colors[color_n++];
1625 color_i += floats_per_vertex;
1636 int src_position_floats_per_vertex;
1637 int src_texcoord_floats_per_vertex;
1638 int src_color_floats_per_vertex;
1643 Uint8 pass_texcoords;
1646 int src_floats_per_vertex;
1674 if(num_vertices == 0)
1680 current_renderer->
TriangleBatch(current_renderer, image, target, num_vertices, values, num_indices, indices, flags);
1690 src_position_floats_per_vertex = 2;
1691 src_texcoord_floats_per_vertex = 2;
1692 src_color_floats_per_vertex = 4;
1701 src_position_floats_per_vertex = 2;
1703 src_texcoord_floats_per_vertex = 2;
1705 src_color_floats_per_vertex = 4;
1707 src_position_floats_per_vertex = 0;
1709 src_texcoord_floats_per_vertex = 0;
1711 src_color_floats_per_vertex = 0;
1713 src_floats_per_vertex = src_position_floats_per_vertex + src_texcoord_floats_per_vertex + src_color_floats_per_vertex;
1715 size = num_vertices*(2 + 2 + 4);
1716 new_values = (
float*)malloc(
sizeof(
float)*
size);
1720 texcoord_n = src_position_floats_per_vertex;
1721 color_n = src_position_floats_per_vertex + src_texcoord_floats_per_vertex;
1728 for(n = 0; n < num_vertices; n++)
1733 new_values[vert_i++] = 0.0f;
1734 new_values[vert_i++] = 0.0f;
1738 new_values[vert_i++] = values[pos_n];
1739 new_values[vert_i++] = values[pos_n+1];
1740 pos_n += src_floats_per_vertex;
1746 new_values[vert_i++] = 0.0f;
1747 new_values[vert_i++] = 0.0f;
1753 new_values[vert_i++] = values[texcoord_n]/tex_w;
1754 new_values[vert_i++] = values[texcoord_n+1]/tex_h;
1755 texcoord_n += src_floats_per_vertex;
1759 new_values[vert_i++] = values[texcoord_n];
1760 new_values[vert_i++] = values[texcoord_n+1];
1766 new_values[vert_i++] = 1.0f;
1767 new_values[vert_i++] = 1.0f;
1768 new_values[vert_i++] = 1.0f;
1769 new_values[vert_i++] = 1.0f;
1775 new_values[vert_i++] = values[color_n]/255.0f;
1776 new_values[vert_i++] = values[color_n+1]/255.0f;
1777 new_values[vert_i++] = values[color_n+2]/255.0f;
1778 new_values[vert_i++] = values[color_n+3]/255.0f;
1779 color_n += src_floats_per_vertex;
1783 new_values[vert_i++] = values[color_n];
1784 new_values[vert_i++] = values[color_n+1];
1785 new_values[vert_i++] = values[color_n+2];
1786 new_values[vert_i++] = values[color_n+3];
1787 color_n += src_floats_per_vertex;
1792 current_renderer->
TriangleBatch(current_renderer, image, target, num_vertices, new_values, num_indices, indices, flags | GPU_PASSTHROUGH_ALL);
1819 return current_renderer->
SetClip(current_renderer, target, rect.
x, rect.
y, rect.
w, rect.
h);
1830 return current_renderer->
SetClip(current_renderer, target, x, y, w, h);
1838 current_renderer->
UnsetClip(current_renderer, target);
1851 SDL_Color
c = {255, 255, 255, 255};
1860 SDL_Color
c = {
r,
g,
b, 255};
1870 SDL_Color
c = {
r,
g,
b, a};
1897 if(r == 255 && g == 255 && b == 255)
1901 SDL_Color
c = {
r,
g,
b, 255};
1912 if(r == 255 && g == 255 && b == 255 && a == 255)
1916 SDL_Color
c = {
r,
g,
b, a};
2101 current_renderer->
SetImageFilter(current_renderer, image, filter);
2127 current_renderer->
SetWrapMode(current_renderer, image, wrap_mode_x, wrap_mode_y);
2135 SDL_Color
c = {0,0,0,0};
2139 return current_renderer->
GetPixel(current_renderer, target, x, y);
2153 current_renderer->
Clear(current_renderer, target);
2162 current_renderer->
ClearRGBA(current_renderer, target, 0, 0, 0, 0);
2164 current_renderer->
ClearRGBA(current_renderer, target, color->r, color->g, color->b,
GET_ALPHA(*color));
2172 current_renderer->
ClearRGBA(current_renderer, target, r, g, b, a);
2188 current_renderer->
Flip(current_renderer, target);
2203 return current_renderer->
CompileShader_RW(current_renderer, shader_type, shader_source);
2211 if(filename == NULL)
2216 rwops = SDL_RWFromFile(filename,
"r");
2232 return current_renderer->
CompileShader(current_renderer, shader_type, shader_source);
2248 return current_renderer->
LinkShaders(current_renderer, shader_object1, shader_object2);
2256 current_renderer->
FreeShader(current_renderer, shader_object);
2272 current_renderer->
AttachShader(current_renderer, program_object, shader_object);
2280 current_renderer->
DetachShader(current_renderer, program_object, shader_object);
2343 return current_renderer->
GetUniformLocation(current_renderer, program_object, uniform_name);
2358 return current_renderer->
LoadShaderBlock(current_renderer, program_object, position_name, texcoord_name, color_name, modelViewMatrix_name);
2374 current_renderer->
SetShaderImage(current_renderer, image, location, image_unit);
2382 current_renderer->
GetUniformiv(current_renderer, program_object, location, values);
2390 current_renderer->
SetUniformi(current_renderer, location, value);
2398 current_renderer->
SetUniformiv(current_renderer, location, num_elements_per_value, num_values, values);
2407 current_renderer->
GetUniformuiv(current_renderer, program_object, location, values);
2415 current_renderer->
SetUniformui(current_renderer, location, value);
2423 current_renderer->
SetUniformuiv(current_renderer, location, num_elements_per_value, num_values, values);
2432 current_renderer->
GetUniformfv(current_renderer, program_object, location, values);
2440 current_renderer->
SetUniformf(current_renderer, location, value);
2448 current_renderer->
SetUniformfv(current_renderer, location, num_elements_per_value, num_values, values);
2457 current_renderer->
GetUniformfv(current_renderer, program_object, location, values);
2465 current_renderer->
SetUniformMatrixfv(current_renderer, location, num_matrices, num_rows, num_columns, transpose, values);
2474 current_renderer->
SetAttributef(current_renderer, location, value);
2482 current_renderer->
SetAttributei(current_renderer, location, value);
2490 current_renderer->
SetAttributeui(current_renderer, location, value);
2498 current_renderer->
SetAttributefv(current_renderer, location, num_elements, value);
2506 current_renderer->
SetAttributeiv(current_renderer, location, num_elements, value);
2514 current_renderer->
SetAttributeuiv(current_renderer, location, num_elements, value);
void GPU_SetUniformuiv(int location, int num_elements_per_value, int num_values, unsigned int *values)
static Uint32 init_windowID
void GPU_UnsetClip(GPU_Target *target)
static void BlitTransformX(GPU_Renderer *renderer, 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)
void GPU_AddWindowMapping(GPU_Target *target)
static int renderer_order_size
int(* GetAttributeLocation)(GPU_Renderer *renderer, Uint32 program_object, const char *attrib_name)
GPU_Image * GPU_CopyImageFromSurface(SDL_Surface *surface)
void(* SetShaderImage)(GPU_Renderer *renderer, GPU_Image *image, int location, int image_unit)
void GPU_ClearRGBA(GPU_Target *target, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static void BlitRotate(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float degrees)
GLsizei GLboolean transpose
GPU_Target *(* Init)(GPU_Renderer *renderer, GPU_RendererID renderer_request, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
void GPU_SetRGBA(GPU_Image *image, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GPU_Target * GPU_CreateAliasTarget(GPU_Target *target)
void(* FreeShaderProgram)(GPU_Renderer *renderer, Uint32 program_object)
void GPU_SetSnapMode(GPU_Image *image, GPU_SnapEnum mode)
GPU_ShaderBlock GPU_LoadShaderBlock(Uint32 program_object, const char *position_name, const char *texcoord_name, const char *color_name, const char *modelViewMatrix_name)
SDL_Color GPU_GetPixel(GPU_Target *target, Sint16 x, Sint16 y)
void GPU_UpdateSubImage(GPU_Image *image, const GPU_Rect *image_rect, SDL_Surface *surface, const GPU_Rect *surface_rect)
static int window_mappings_size
void GPU_SetShaderBlock(GPU_ShaderBlock block)
void GPU_SetTargetRGB(GPU_Target *target, Uint8 r, Uint8 g, Uint8 b)
void(* SetAttributef)(GPU_Renderer *renderer, int location, float value)
GPU_Rect GPU_MakeRect(float x, float y, float w, float h)
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)
#define RETURN_ERROR(code, details)
static const GPU_BlitFlagEnum GPU_PASSTHROUGH_VERTICES
STBIDEF const char * stbi_failure_reason(void)
int modelViewProjection_loc
void(* SetShaderBlock)(GPU_Renderer *renderer, GPU_ShaderBlock block)
void(* BlitTransformMatrix)(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float *matrix3x3)
void GPU_SetUniformui(int location, unsigned int value)
GPU_Camera GPU_GetDefaultCamera(void)
static void BlitBatch(GPU_Renderer *renderer, GPU_Image *image, GPU_Target *target, unsigned int num_sprites, float *values, GPU_BlitFlagEnum flags)
#define GPU_PASSTHROUGH_ALL
void GPU_FreeTarget(GPU_Target *target)
#define GPU_MAX_NUM_ERRORS
static const GPU_BlitFlagEnum GPU_PASSTHROUGH_COLORS
Uint8 GPU_GetBlending(GPU_Image *image)
void(* BlitRotate)(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float degrees)
void GPU_BlitTransformMatrix(GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float *matrix3x3)
GLuint GLuint GLsizei GLenum type
void(* FreeImage)(GPU_Renderer *renderer, GPU_Image *image)
static l_noret error(LoadState *S, const char *why)
void GPU_GetUniformuiv(Uint32 program_object, int location, unsigned int *values)
void(* TriangleBatch)(GPU_Renderer *renderer, GPU_Image *image, GPU_Target *target, unsigned short num_vertices, float *values, unsigned int num_indices, unsigned short *indices, GPU_BlitFlagEnum flags)
Uint32 GPU_WindowFlagEnum
Uint32 GPU_LinkShaders(Uint32 shader_object1, Uint32 shader_object2)
void(* BlitScale)(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float scaleX, float scaleY)
int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data)
void GPU_SetColor(GPU_Image *image, SDL_Color *color)
GPU_ShaderBlock(* LoadShaderBlock)(GPU_Renderer *renderer, Uint32 program_object, const char *position_name, const char *texcoord_name, const char *color_name, const char *modelViewMatrix_name)
GPU_Target * GPU_Init(Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
static void TriangleBatch(GPU_Renderer *renderer, GPU_Image *image, GPU_Target *target, unsigned short num_vertices, float *values, unsigned int num_indices, unsigned short *indices, GPU_BlitFlagEnum flags)
void(* AttachShader)(GPU_Renderer *renderer, Uint32 program_object, Uint32 shader_object)
SDL_Surface *(* CopySurfaceFromTarget)(GPU_Renderer *renderer, GPU_Target *target)
GPU_Target * GPU_GetContextTarget(void)
GPU_DebugLevelEnum GPU_GetDebugLevel(void)
void GPU_SetTargetColor(GPU_Target *target, SDL_Color *color)
void GPU_SetUniformi(int location, int value)
const char * GPU_GetShaderMessage(void)
void GPU_SetTargetRGBA(GPU_Target *target, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GPU_RendererID GPU_MakeRendererID(GPU_RendererEnum id, int major_version, int minor_version)
void(* SetUniformi)(GPU_Renderer *renderer, int location, int value)
void GPU_GetVirtualCoords(GPU_Target *target, float *x, float *y, float displayX, float displayY)
void GPU_BlitTransform(GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float angle, float scaleX, float scaleY)
static GPU_DebugLevelEnum debug_level
Uint32 GPU_LinkShaderProgram(Uint32 program_object)
GPU_InitFlagEnum GPU_GetPreInitFlags(void)
STBIDEF stbi_uc * stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
void(* MakeCurrent)(GPU_Renderer *renderer, GPU_Target *target, Uint32 windowID)
void(* ActivateShaderProgram)(GPU_Renderer *renderer, Uint32 program_object, GPU_ShaderBlock *block)
static const GPU_BlitFlagEnum GPU_USE_DEFAULT_COLORS
void(* BlitBatch)(GPU_Renderer *renderer, GPU_Image *image, GPU_Target *target, unsigned int num_sprites, float *values, GPU_BlitFlagEnum flags)
Uint8 GPU_ToggleFullscreen(Uint8 use_desktop_resolution)
void GPU_SetViewport(GPU_Target *target, GPU_Rect viewport)
#define GPU_ERROR_FUNCTION_STRING_MAX
void GPU_SetBlendFunction(GPU_Image *image, GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha)
void(* BlitTransform)(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float degrees, float scaleX, float scaleY)
int(* GetUniformLocation)(GPU_Renderer *renderer, Uint32 program_object, const char *uniform_name)
void(* UnsetClip)(GPU_Renderer *renderer, GPU_Target *target)
GLint GLint GLint GLint GLint GLint y
static void Blit(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y)
GPU_Rect(* SetClip)(GPU_Renderer *renderer, GPU_Target *target, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
Uint32 GPU_LoadShader(GPU_ShaderEnum shader_type, const char *filename)
void(* FlushBlitBuffer)(GPU_Renderer *renderer)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
void GPU_SetShapeBlendEquation(GPU_BlendEqEnum color_equation, GPU_BlendEqEnum alpha_equation)
void(* SetAttributeSource)(GPU_Renderer *renderer, int num_values, GPU_Attribute source)
Uint32 GPU_CompileShader(GPU_ShaderEnum shader_type, const char *shader_source)
void GPU_MakeCurrent(GPU_Target *target, Uint32 windowID)
Uint8(* SetWindowResolution)(GPU_Renderer *renderer, Uint16 w, Uint16 h)
#define GPU_DEFAULT_INIT_FLAGS
void GPU_SetBlending(GPU_Image *image, Uint8 enable)
static const char * get_filename_ext(const char *filename)
void(* SetAsCurrent)(GPU_Renderer *renderer)
void GPU_PushErrorCode(const char *function, GPU_ErrorEnum error, const char *details,...)
const char *(* GetShaderMessage)(GPU_Renderer *renderer)
void GPU_SetShapeBlendFunction(GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha)
static GPU_WindowMapping * window_mappings
SDL_Surface * GPU_LoadSurface(const char *filename)
void(* Quit)(GPU_Renderer *renderer)
static void init_error_stack()
GLboolean GLenum GLenum GLvoid * values
GPU_Image * GPU_CopyImageFromTarget(GPU_Target *target)
void(* FreeShader)(GPU_Renderer *renderer, Uint32 shader_object)
Uint32(* LinkShaders)(GPU_Renderer *renderer, Uint32 shader_object1, Uint32 shader_object2)
void(* Blit)(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y)
void GPU_Clear(GPU_Target *target)
GLdouble GLdouble GLdouble b
void(* Flip)(GPU_Renderer *renderer, GPU_Target *target)
int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes)
static const GPU_BlitFlagEnum GPU_PASSTHROUGH_TEXCOORDS
GPU_BlendEqEnum alpha_equation
GPU_Image * GPU_CreateAliasImage(GPU_Image *image)
GPU_Renderer * GPU_GetRendererByID(GPU_RendererID id)
void GPU_SetShaderImage(GPU_Image *image, int location, int image_unit)
GPU_Renderer * GPU_GetCurrentRenderer(void)
GPU_Renderer * GPU_AddRenderer(GPU_RendererID id)
void GPU_SetPreInitFlags(GPU_InitFlagEnum GPU_flags)
void(* ClearRGBA)(GPU_Renderer *renderer, GPU_Target *target, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
void GPU_GetRendererOrder(int *order_size, GPU_RendererID *order)
void(* SetAttributeuiv)(GPU_Renderer *renderer, int location, int num_elements, unsigned int *value)
SDL_version GPU_GetLinkedVersion(void)
void GPU_SetAttributefv(int location, int num_elements, float *value)
#define GPU_INITIAL_WINDOW_MAPPINGS_SIZE
static GPU_Renderer * current_renderer
void GPU_BlitRotate(GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float angle)
void GPU_Flip(GPU_Target *target)
void(* BlitTransformX)(GPU_Renderer *renderer, 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)
GPU_Target * current_context_target
void GPU_ActivateShaderProgram(Uint32 program_object, GPU_ShaderBlock *block)
void GPU_UpdateImage(GPU_Image *image, SDL_Surface *surface, const GPU_Rect *surface_rect)
GPU_BlendEqEnum color_equation
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * value
void GPU_SetAttributeui(int location, unsigned int value)
GPU_Target * GPU_InitRendererByID(GPU_RendererID renderer_request, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
GPU_BlendMode shapes_blend_mode
GPU_BlendFuncEnum dest_alpha
SDL_Surface * GPU_CopySurfaceFromTarget(GPU_Target *target)
GLboolean GLboolean GLboolean GLboolean a
void GPU_SetInitWindow(Uint32 windowID)
void(* SetVirtualResolution)(GPU_Renderer *renderer, GPU_Target *target, Uint16 w, Uint16 h)
GPU_Target * GPU_GetWindowTarget(Uint32 windowID)
GPU_Image * GPU_LoadImage(const char *filename)
void(* SetUniformMatrixfv)(GPU_Renderer *renderer, int location, int num_matrices, int num_rows, int num_columns, Uint8 transpose, float *values)
void GPU_SetUniformMatrixfv(int location, int num_matrices, int num_rows, int num_columns, Uint8 transpose, float *values)
void GPU_SetUniformfv(int location, int num_elements_per_value, int num_values, float *values)
void(* SetAttributefv)(GPU_Renderer *renderer, int location, int num_elements, float *value)
#define GPU_RENDERER_ORDER_MAX
GLenum GLuint GLsizei const char * buf
Uint8(* ToggleFullscreen)(GPU_Renderer *renderer, Uint8 use_desktop_resolution)
static const GPU_BlitFlagEnum GPU_USE_DEFAULT_SRC_RECTS
static void init_window_mappings()
GPU_BlendFuncEnum source_color
GPU_Image *(* LoadImage)(GPU_Renderer *renderer, const char *filename)
SDL_Color GPU_MakeColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GPU_BlendMode GPU_GetBlendModeFromPreset(GPU_BlendPresetEnum preset)
void(* SetUniformui)(GPU_Renderer *renderer, int location, unsigned int value)
GPU_ErrorObject GPU_PopErrorCode(void)
void(* SetAttributei)(GPU_Renderer *renderer, int location, int value)
Uint8 GPU_SaveSurface(SDL_Surface *surface, const char *filename)
static int num_window_mappings
void GPU_FreeShaderProgram(Uint32 program_object)
void(* GetUniformuiv)(GPU_Renderer *renderer, Uint32 program_object, int location, unsigned int *values)
void GPU_SetCurrentRenderer(GPU_RendererID id)
Uint8 shapes_use_blending
cl_event GLbitfield flags
GPU_Rect GPU_SetClip(GPU_Target *target, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
void GPU_ClearColor(GPU_Target *target, SDL_Color *color)
void GPU_SetVirtualResolution(GPU_Target *target, Uint16 w, Uint16 h)
void GPU_DetachShader(Uint32 program_object, Uint32 shader_object)
SDL_Color(* GetPixel)(GPU_Renderer *renderer, GPU_Target *target, Sint16 x, Sint16 y)
static void BlitTransform(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float degrees, float scaleX, float scaleY)
Encapsulates the map of the game.
GPU_Image * GPU_CopyImage(GPU_Image *image)
Uint8(* IsFeatureEnabled)(GPU_Renderer *renderer, GPU_FeatureEnum feature)
static GPU_ErrorObject error_code_stack[GPU_MAX_NUM_ERRORS]
static const GPU_BlitFlagEnum GPU_USE_DEFAULT_POSITIONS
void GPU_SetAttributef(int location, float value)
GPU_Image *(* CopyImageFromTarget)(GPU_Renderer *renderer, GPU_Target *target)
struct GPU_WindowMapping GPU_WindowMapping
static void block(LexState *ls)
void GPU_UpdateImageBytes(GPU_Image *image, const GPU_Rect *image_rect, const unsigned char *bytes, int bytes_per_row)
void GPU_SetDebugLevel(GPU_DebugLevelEnum level)
void(* SetAttributeui)(GPU_Renderer *renderer, int location, unsigned int value)
GPU_SnapEnum GPU_GetSnapMode(GPU_Image *image)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GPU_Image *(* CreateAliasImage)(GPU_Renderer *renderer, GPU_Image *image)
void GPU_SetImageFilter(GPU_Image *image, GPU_FilterEnum filter)
GPU_Target * GPU_InitRenderer(GPU_RendererEnum renderer_enum, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
void GPU_BlitScale(GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float scaleX, float scaleY)
void GPU_DeactivateShaderProgram(void)
void GPU_RemoveWindowMappingByTarget(GPU_Target *target)
GPU_Target *(* CreateTargetFromWindow)(GPU_Renderer *renderer, Uint32 windowID, GPU_Target *target)
void(* GetUniformiv)(GPU_Renderer *renderer, Uint32 program_object, int location, int *values)
void GPU_UnsetVirtualResolution(GPU_Target *target)
GPU_Image *(* CreateImage)(GPU_Renderer *renderer, Uint16 w, Uint16 h, GPU_FormatEnum format)
int GPU_GetUniformLocation(Uint32 program_object, const char *uniform_name)
void(* UpdateSubImage)(GPU_Renderer *renderer, GPU_Image *image, const GPU_Rect *image_rect, SDL_Surface *surface, const GPU_Rect *surface_rect)
GLfloat GLfloat GLfloat GLfloat h
int GPU_GetNumActiveRenderers(void)
void(* SetImageFilter)(GPU_Renderer *renderer, GPU_Image *image, GPU_FilterEnum filter)
void GPU_LogWarning(const char *format,...)
GPU_Camera GPU_SetCamera(GPU_Target *target, GPU_Camera *cam)
GLint GLint GLint GLint GLint x
GPU_Target * GPU_LoadTarget(GPU_Image *image)
GPU_Image * GPU_CreateImage(Uint16 w, Uint16 h, GPU_FormatEnum format)
GPU_Rect GPU_SetClipRect(GPU_Target *target, GPU_Rect rect)
#define GET_ALPHA(sdl_color)
GLdouble GLdouble GLdouble r
Uint32(* CompileShader)(GPU_Renderer *renderer, GPU_ShaderEnum shader_type, const char *shader_source)
void GPU_RemoveWindowMapping(Uint32 windowID)
void GPU_SetWrapMode(GPU_Image *image, GPU_WrapEnum wrap_mode_x, GPU_WrapEnum wrap_mode_y)
Uint32 GPU_CompileShader_RW(GPU_ShaderEnum shader_type, SDL_RWops *shader_source)
void(* UpdateImage)(GPU_Renderer *renderer, GPU_Image *image, SDL_Surface *surface, const GPU_Rect *surface_rect)
void GPU_SetAttributeuiv(int location, int num_elements, unsigned int *value)
void GPU_SetUniformf(int location, float value)
void GPU_FreeShader(Uint32 shader_object)
Uint32(* CompileShader_RW)(GPU_Renderer *renderer, GPU_ShaderEnum shader_type, SDL_RWops *shader_source)
void GPU_BlitBatchSeparate(GPU_Image *image, GPU_Target *target, unsigned int num_sprites, float *positions, float *src_rects, float *colors, GPU_BlitFlagEnum flags)
GPU_BlendFuncEnum dest_color
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
void GPU_SetShapeBlendMode(GPU_BlendPresetEnum preset)
GPU_Target * GPU_CreateTargetFromWindow(Uint32 windowID)
void GPU_AttachShader(Uint32 program_object, Uint32 shader_object)
void GPU_SetUniformiv(int location, int num_elements_per_value, int num_values, int *values)
void GPU_SetBlendEquation(GPU_Image *image, GPU_BlendEqEnum color_equation, GPU_BlendEqEnum alpha_equation)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Uint8 GPU_IsFeatureEnabled(GPU_FeatureEnum feature)
static int inited_error_code_stack
static SDL_version GPU_GetCompiledVersion(void)
GPU_AttributeFormat format
Uint8 GPU_SetWindowResolution(Uint16 w, Uint16 h)
STBIDEF void stbi_image_free(void *retval_from_stbi_load)
void(* SetUniformfv)(GPU_Renderer *renderer, int location, int num_elements_per_value, int num_values, float *values)
void(* GetUniformfv)(GPU_Renderer *renderer, Uint32 program_object, int location, float *values)
void GPU_SetShapeBlending(Uint8 enable)
void GPU_GenerateMipmaps(GPU_Image *image)
void GPU_FreeImage(GPU_Image *image)
void GPU_FlushBlitBuffer(void)
static Uint8 init_SDL(void)
void(* DetachShader)(GPU_Renderer *renderer, Uint32 program_object, Uint32 shader_object)
void(* UpdateImageBytes)(GPU_Renderer *renderer, GPU_Image *image, const GPU_Rect *image_rect, const unsigned char *bytes, int bytes_per_row)
void(* GenerateMipmaps)(GPU_Renderer *renderer, GPU_Image *image)
Uint8(* IsDefaultShaderProgram)(GPU_Renderer *renderer, Uint32 program_object)
SDL_Surface *(* CopySurfaceFromImage)(GPU_Renderer *renderer, GPU_Image *image)
void(* SetUniformiv)(GPU_Renderer *renderer, int location, int num_elements_per_value, int num_values, int *values)
this module manages the cache of images.
int GPU_GetAttributeLocation(Uint32 program_object, const char *attrib_name)
Uint8(* SaveImage)(GPU_Renderer *renderer, GPU_Image *image, const char *filename)
Uint8 GPU_IsDefaultShaderProgram(Uint32 program_object)
static void BlitScale(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float scaleX, float scaleY)
GLuint GLuint GLsizei GLenum const GLvoid * indices
void GPU_SetAttributeiv(int location, int num_elements, int *value)
const char * GPU_GetErrorString(GPU_ErrorEnum error)
static int num_error_codes
void GPU_SetBlendMode(GPU_Image *image, GPU_BlendPresetEnum preset)
void GPU_GetUniformiv(Uint32 program_object, int location, int *values)
Uint32 current_shader_program
Uint32(* LinkShaderProgram)(GPU_Renderer *renderer, Uint32 program_object)
void GPU_Blit(GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y)
GPU_Target *(* LoadTarget)(GPU_Renderer *renderer, GPU_Image *image)
GLint GLint GLint GLint GLint GLint GLsizei width
void(* UnsetVirtualResolution)(GPU_Renderer *renderer, GPU_Target *target)
void GPU_LogError(const char *format,...)
void GPU_TriangleBatch(GPU_Image *image, GPU_Target *target, unsigned short num_vertices, float *values, unsigned int num_indices, unsigned short *indices, GPU_BlitFlagEnum flags)
GPU_Target *(* CreateAliasTarget)(GPU_Renderer *renderer, GPU_Target *target)
void GPU_SetRGB(GPU_Image *image, Uint8 r, Uint8 g, Uint8 b)
void(* SetUniformf)(GPU_Renderer *renderer, int location, float value)
Uint32 GPU_GetInitWindow(void)
void GPU_CloseCurrentRenderer(void)
void GPU_SetAttributeSource(int num_values, GPU_Attribute source)
static GPU_RendererID renderer_order[GPU_RENDERER_ORDER_MAX]
static GPU_InitFlagEnum preinit_flags
void(* DeactivateShaderProgram)(GPU_Renderer *renderer)
GPU_Image *(* CopyImage)(GPU_Renderer *renderer, GPU_Image *image)
void(* SetAttributeiv)(GPU_Renderer *renderer, int location, int num_elements, int *value)
STBIDEF stbi_uc * stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp)
GPU_Image *(* CopyImageFromSurface)(GPU_Renderer *renderer, SDL_Surface *surface)
static void BlitTransformMatrix(GPU_Renderer *renderer, GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float *matrix3x3)
void GPU_InitRendererRegister(void)
void GPU_RemoveRenderer(GPU_RendererID id)
#define GPU_ERROR_DETAILS_STRING_MAX
int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data)
void(* Clear)(GPU_Renderer *renderer, GPU_Target *target)
void(* SetWrapMode)(GPU_Renderer *renderer, GPU_Image *image, GPU_WrapEnum wrap_mode_x, GPU_WrapEnum wrap_mode_y)
void(* FreeTarget)(GPU_Renderer *renderer, GPU_Target *target)
GPU_Camera GPU_GetCamera(GPU_Target *target)
void GPU_LogInfo(const char *format,...)
Uint32 GPU_GetCurrentShaderProgram(void)
GPU_Camera(* SetCamera)(GPU_Renderer *renderer, GPU_Target *target, GPU_Camera *cam)
void GPU_GetUniformfv(Uint32 program_object, int location, float *values)
GLsizei GLsizei GLchar * source
#define CHECK_FUNCTION_POINTER(fn)
void GPU_SetAttributei(int location, int value)
void GPU_GetUniformMatrixfv(Uint32 program_object, int location, float *values)
void(* SetUniformuiv)(GPU_Renderer *renderer, int location, int num_elements_per_value, int num_values, unsigned int *values)
Uint8 GPU_SaveImage(GPU_Image *image, const char *filename)
GPU_Attribute GPU_MakeAttribute(int location, void *values, GPU_AttributeFormat format)
SDL_Surface * GPU_CopySurfaceFromImage(GPU_Image *image)
GPU_BlendFuncEnum source_alpha
GPU_AttributeFormat GPU_MakeAttributeFormat(int num_elems_per_vertex, GPU_TypeEnum type, Uint8 normalize, int stride_bytes, int offset_bytes)
void GPU_BlitBatch(GPU_Image *image, GPU_Target *target, unsigned int num_sprites, float *values, GPU_BlitFlagEnum flags)