this repo has no description
0
fork

Configure Feed

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

Suppressed a bunch of compiler warnings for type conversions.

+193 -170
+9 -1
CMakeLists.txt
··· 103 103 # SET(CMAKE_BUILD_TYPE Release) 104 104 #endif ( SDL_gpu_BUILD_DEBUG ) 105 105 106 + if (CMAKE_VERSION VERSION_LESS "3.1") 107 + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") 108 + set (CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}") 109 + endif () 110 + else () 111 + set (CMAKE_C_STANDARD 99) 112 + endif () 113 + 106 114 # Find the package for SDL or SDL2 107 115 if ( SDL_gpu_USE_SDL1 ) 108 116 find_package(SDL REQUIRED) ··· 278 286 ) 279 287 endif(DOXYGEN_FOUND) 280 288 281 - add_definitions("-Wall -std=c99 -pedantic") 289 + add_definitions("-Wall -pedantic") 282 290 283 291 if (SDL_gpu_USE_BUFFER_RESET) 284 292 add_definitions("-DSDL_GPU_USE_BUFFER_RESET")
+6
src/CMakeLists.txt
··· 100 100 target_link_libraries(SDL_gpu_shared ${SDL_gpu_GL_LIBRARIES}) 101 101 102 102 if(SDL_gpu_BUILD_FRAMEWORK) 103 + if(NOT CMAKE_VERSION VERSION_LESS "3.1") 104 + set_property(TARGET SDL_gpu_shared PROPERTY C_STANDARD 99) 105 + endif() 103 106 set_target_properties(SDL_gpu_shared PROPERTIES 104 107 FRAMEWORK TRUE 105 108 FRAMEWORK_VERSION "A" ··· 155 158 ${SDL_gpu_HDRS} 156 159 ${SDL_gpu_SRCS} 157 160 ) 161 + if(NOT CMAKE_VERSION VERSION_LESS "3.1") 162 + set_property(TARGET SDL_gpu PROPERTY C_STANDARD 99) 163 + endif() 158 164 set_target_properties(SDL_gpu PROPERTIES 159 165 OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME} 160 166 CLEAN_DIRECT_OUTPUT 1
+6 -8
src/SDL_gpu.c
··· 1096 1096 // We'll at least create a grayscale one, but it's not ideal... 1097 1097 // Better would be to get the palette from stbi, but stbi doesn't do that! 1098 1098 SDL_Color colors[256]; 1099 - int i; 1100 1099 1101 1100 for(i = 0; i < 256; i++) 1102 1101 { ··· 1120 1119 unsigned char* data; 1121 1120 SDL_Surface* result; 1122 1121 1123 - Sint64 data_bytes; 1122 + int data_bytes; 1124 1123 unsigned char* c_data; 1125 1124 1126 1125 if(rwops == NULL) ··· 1131 1130 1132 1131 // Get count of bytes 1133 1132 SDL_RWseek(rwops, 0, SEEK_SET); 1134 - data_bytes = SDL_RWseek(rwops, 0, SEEK_END); 1133 + data_bytes = (int)SDL_RWseek(rwops, 0, SEEK_END); 1135 1134 SDL_RWseek(rwops, 0, SEEK_SET); 1136 1135 1137 1136 // Read in the rwops data ··· 1139 1138 SDL_RWread(rwops, c_data, 1, data_bytes); 1140 1139 1141 1140 // Load image 1142 - data = stbi_load_from_memory(c_data, (int)data_bytes, &width, &height, &channels, 0); 1141 + data = stbi_load_from_memory(c_data, data_bytes, &width, &height, &channels, 0); 1143 1142 1144 1143 // Clean up temp data 1145 1144 SDL_free(c_data); ··· 2558 2557 { 2559 2558 unsigned char u1, u2; 2560 2559 2561 - for (;;) 2560 + do 2562 2561 { 2563 2562 u1 = (unsigned char) *s1++; 2564 2563 u2 = (unsigned char) *s2++; 2565 2564 if (caseless_charmap[u1] != caseless_charmap[u2]) 2566 2565 return caseless_charmap[u1] - caseless_charmap[u2]; 2567 - if (u1 == '\0') 2568 - return 0; 2569 - } 2566 + } while (u1 != '\0'); 2567 + 2570 2568 return 0; 2571 2569 } 2572 2570
+8 -5
src/SDL_gpu_matrix.c
··· 6 6 #define __func__ __FUNCTION__ 7 7 #endif 8 8 9 - #ifndef M_PI 10 - #define M_PI 3.1415926f 9 + #ifndef PI 10 + #define PI 3.1415926f 11 11 #endif 12 + 13 + #define RAD_PER_DEG 0.017453293f 14 + #define DEG_PER_RAD 57.2957795f 12 15 13 16 14 17 // Visual C does not support static inline ··· 220 223 fovy = -fovy; 221 224 aspect = -aspect; 222 225 223 - fH = tanf(fovy / 360 * M_PI) * z_near; 226 + fH = tanf((fovy / 360) * PI) * z_near; 224 227 fW = fH * aspect; 225 228 GPU_MatrixFrustum(result, -fW, fW, -fH, fH, z_near, z_far); 226 229 } ··· 319 322 320 323 p = 1/sqrtf(x*x + y*y + z*z); 321 324 x *= p; y *= p; z *= p; 322 - radians = degrees * (M_PI/180); 325 + radians = degrees * RAD_PER_DEG; 323 326 c = cosf(radians); 324 327 s = sinf(radians); 325 328 c_ = 1 - c; ··· 479 482 // Alloc new one 480 483 unsigned int new_storage_size = stack->storage_size*2 + 4; 481 484 float** new_stack = (float**)SDL_malloc(sizeof(float*) * new_storage_size); 482 - int i; 485 + unsigned int i; 483 486 for(i = 0; i < new_storage_size; ++i) 484 487 { 485 488 new_stack[i] = (float*)SDL_malloc(sizeof(float) * 16);
+87 -71
src/renderer_GL_common.inl
··· 12 12 #include <stdint.h> 13 13 #include <stdlib.h> 14 14 #include "SDL_platform.h" 15 + #include "SDL_gpu.h" // For poor, dumb Intellisense 15 16 #include <math.h> 16 17 #include <string.h> 17 18 ··· 26 27 #include "stb_image.h" 27 28 #include "stb_image_write.h" 28 29 29 - #ifndef M_PI 30 - #define M_PI 3.14159265358979323846 30 + #ifndef PI 31 + #define PI 3.1415926f 31 32 #endif 33 + 34 + #define RAD_PER_DEG 0.017453293f 35 + #define DEG_PER_RAD 57.2957795f 32 36 33 37 // Visual C does not support static inline 34 38 #ifndef static_inline ··· 288 292 #endif 289 293 290 294 glTexSubImage2D(GL_TEXTURE_2D, 0, 291 - update_rect.x, update_rect.y, update_rect.w, update_rect.h, 295 + (GLint)update_rect.x, (GLint)update_rect.y, (GLsizei)update_rect.w, (GLsizei)update_rect.h, 292 296 format, GL_UNSIGNED_BYTE, pixels); 293 297 294 298 #if defined(SDL_GPU_USE_OPENGL) || SDL_GPU_GLES_MAJOR_VERSION > 2 ··· 300 304 static void row_upload_texture(const unsigned char* pixels, GPU_Rect update_rect, Uint32 format, int alignment, unsigned int pitch, int bytes_per_pixel) 301 305 { 302 306 unsigned int i; 303 - unsigned int h = update_rect.h; 307 + unsigned int h = (unsigned int)update_rect.h; 308 + (void)bytes_per_pixel; 304 309 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); 305 310 if(h > 0 && update_rect.w > 0.0f) 306 311 { ··· 308 313 for(i = 0; i < h; ++i) 309 314 { 310 315 glTexSubImage2D(GL_TEXTURE_2D, 0, 311 - update_rect.x, update_rect.y + i, update_rect.w, 1, 316 + (GLint)update_rect.x, (GLint)(update_rect.y + i), (GLsizei)update_rect.w, 1, 312 317 format, GL_UNSIGNED_BYTE, pixels); 313 318 pixels += pitch; 314 319 } ··· 319 324 static void copy_upload_texture(const unsigned char* pixels, GPU_Rect update_rect, Uint32 format, int alignment, unsigned int pitch, int bytes_per_pixel) 320 325 { 321 326 unsigned int i; 322 - unsigned int h = update_rect.h; 323 - unsigned int w = update_rect.w*bytes_per_pixel; 327 + unsigned int h = (unsigned int)update_rect.h; 328 + unsigned int w = ((unsigned int)update_rect.w)*bytes_per_pixel; 324 329 325 330 if(h > 0 && w > 0) 326 331 { ··· 329 334 if(rem > 0) 330 335 w += alignment - rem; 331 336 332 - unsigned char *copy = (unsigned char*)SDL_malloc(update_rect.h*w); 337 + unsigned char *copy = (unsigned char*)SDL_malloc(w*h); 333 338 unsigned char *dst = copy; 334 339 335 340 for(i = 0; i < h; ++i) ··· 338 343 pixels += pitch; 339 344 dst += w; 340 345 } 341 - fast_upload_texture(copy, update_rect, format, alignment, update_rect.w); 346 + fast_upload_texture(copy, update_rect, format, alignment, (int)update_rect.w); 342 347 SDL_free(copy); 343 348 } 344 349 } ··· 347 352 348 353 static_inline void upload_texture(const void* pixels, GPU_Rect update_rect, Uint32 format, int alignment, int row_length, unsigned int pitch, int bytes_per_pixel) 349 354 { 355 + (void)pitch; 350 356 #if defined(SDL_GPU_USE_OPENGL) || SDL_GPU_GLES_MAJOR_VERSION > 2 357 + (void)bytes_per_pixel; 351 358 fast_upload_texture(pixels, update_rect, format, alignment, row_length); 352 359 #else 353 360 if(row_length == update_rect.w) ··· 361 368 static_inline void upload_new_texture(void* pixels, GPU_Rect update_rect, Uint32 format, int alignment, int row_length, int bytes_per_pixel) 362 369 { 363 370 #if defined(SDL_GPU_USE_OPENGL) || SDL_GPU_GLES_MAJOR_VERSION > 2 371 + (void)bytes_per_pixel; 364 372 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); 365 373 glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); 366 - glTexImage2D(GL_TEXTURE_2D, 0, format, update_rect.w, update_rect.h, 0, 374 + glTexImage2D(GL_TEXTURE_2D, 0, format, (GLsizei)update_rect.w, (GLsizei)update_rect.h, 0, 367 375 format, GL_UNSIGNED_BYTE, pixels); 368 376 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 369 377 glPixelStorei(GL_UNPACK_ALIGNMENT, 4); 370 378 #else 371 - glTexImage2D(GL_TEXTURE_2D, 0, format, update_rect.w, update_rect.h, 0, 379 + glTexImage2D(GL_TEXTURE_2D, 0, format, (GLsizei)update_rect.w, (GLsizei)update_rect.h, 0, 372 380 format, GL_UNSIGNED_BYTE, NULL); 373 381 upload_texture(pixels, update_rect, format, alignment, row_length, row_length*bytes_per_pixel, bytes_per_pixel); 374 382 #endif ··· 726 734 memcpy(new_buffer, cdata->blit_buffer, cdata->blit_buffer_num_vertices * GPU_BLIT_BUFFER_STRIDE); 727 735 SDL_free(cdata->blit_buffer); 728 736 cdata->blit_buffer = new_buffer; 729 - cdata->blit_buffer_max_num_vertices = new_max_num_vertices; 737 + cdata->blit_buffer_max_num_vertices = (unsigned short)new_max_num_vertices; 730 738 731 739 #ifdef SDL_GPU_USE_BUFFER_PIPELINE 732 740 // Resize the VBOs ··· 813 821 glEnable(GL_SCISSOR_TEST); 814 822 if(target->context != NULL) 815 823 { 816 - int y; 824 + float y; 817 825 if(renderer->coordinate_mode == 0) 818 826 y = context_target->h - (target->clip_rect.y + target->clip_rect.h); 819 827 else 820 828 y = target->clip_rect.y; 821 829 float xFactor = ((float)context_target->context->drawable_w)/context_target->w; 822 830 float yFactor = ((float)context_target->context->drawable_h)/context_target->h; 823 - glScissor(target->clip_rect.x * xFactor, y * yFactor, target->clip_rect.w * xFactor, target->clip_rect.h * yFactor); 831 + glScissor((GLint)(target->clip_rect.x * xFactor), (GLint)(y * yFactor), (GLsizei)(target->clip_rect.w * xFactor), (GLsizei)(target->clip_rect.h * yFactor)); 824 832 } 825 833 else 826 - glScissor(target->clip_rect.x, target->clip_rect.y, target->clip_rect.w, target->clip_rect.h); 834 + glScissor((GLint)target->clip_rect.x, (GLint)target->clip_rect.y, (GLsizei)target->clip_rect.w, (GLsizei)target->clip_rect.h); 827 835 } 828 836 } 829 837 ··· 1036 1044 } 1037 1045 1038 1046 #define MIX_COLOR_COMPONENT_NORMALIZED_RESULT(a, b) ((a)/255.0f * (b)/255.0f) 1039 - #define MIX_COLOR_COMPONENT(a, b) (((a)/255.0f * (b)/255.0f)*255) 1047 + #define MIX_COLOR_COMPONENT(a, b) ((Uint8)(((a)/255.0f * (b)/255.0f)*255)) 1040 1048 1041 1049 static SDL_Color get_complete_mod_color(GPU_Renderer* renderer, GPU_Target* target, GPU_Image* image) 1042 1050 { 1051 + (void)renderer; 1043 1052 SDL_Color color = { 255, 255, 255, 255 }; 1044 1053 if(target->use_color) 1045 1054 { ··· 1122 1131 y = target->context->drawable_h - viewport.h - viewport.y; 1123 1132 } 1124 1133 1125 - glViewport(viewport.x, y, viewport.w, viewport.h); 1134 + glViewport((GLint)viewport.x, (GLint)y, (GLsizei)viewport.w, (GLsizei)viewport.h); 1126 1135 } 1127 1136 1128 1137 static void changeViewport(GPU_Target* target) ··· 1432 1441 *version = major*100 + minor; 1433 1442 } 1434 1443 #endif 1444 + #else 1445 + (void)version; 1435 1446 #endif 1436 1447 return GPU_TRUE; 1437 1448 } ··· 1578 1589 1579 1590 target->renderer = renderer; 1580 1591 target->context_target = renderer->current_context_target; 1581 - target->w = target->context->drawable_w; 1582 - target->h = target->context->drawable_h; 1583 - target->base_w = target->context->drawable_w; 1584 - target->base_h = target->context->drawable_h; 1592 + target->w = (Uint16)target->context->drawable_w; 1593 + target->h = (Uint16)target->context->drawable_h; 1594 + target->base_w = (Uint16)target->context->drawable_w; 1595 + target->base_h = (Uint16)target->context->drawable_h; 1585 1596 1586 1597 target->use_clip_rect = GPU_FALSE; 1587 1598 target->clip_rect.x = 0; ··· 1590 1601 target->clip_rect.h = target->h; 1591 1602 target->use_color = GPU_FALSE; 1592 1603 1593 - target->viewport = GPU_MakeRect(0, 0, target->context->drawable_w, target->context->drawable_h); 1604 + target->viewport = GPU_MakeRect(0, 0, (float)target->context->drawable_w, (float)target->context->drawable_h); 1594 1605 target->camera = GPU_GetDefaultCamera(); 1595 1606 target->use_camera = GPU_TRUE; 1596 1607 ··· 1691 1702 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); 1692 1703 1693 1704 // Viewport and Framebuffer 1694 - glViewport(0.0f, 0.0f, target->viewport.w, target->viewport.h); 1705 + glViewport(0, 0, (GLsizei)target->viewport.w, (GLsizei)target->viewport.h); 1695 1706 1696 1707 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 1697 1708 #if defined(SDL_GPU_USE_FIXED_FUNCTION_PIPELINE) || defined(SDL_GPU_USE_ARRAY_PIPELINE) ··· 1909 1920 { 1910 1921 get_window_dimensions(window, &target->context->window_w, &target->context->window_h); 1911 1922 get_drawable_dimensions(window, &target->context->drawable_w, &target->context->drawable_h); 1912 - target->base_w = target->context->drawable_w; 1913 - target->base_h = target->context->drawable_h; 1923 + target->base_w = (Uint16)target->context->drawable_w; 1924 + target->base_h = (Uint16)target->context->drawable_h; 1914 1925 } 1915 1926 1916 1927 // Reset the camera for this window ··· 2073 2084 update_stored_dimensions(target); 2074 2085 2075 2086 // Update base dimensions 2076 - target->base_w = target->context->drawable_w; 2077 - target->base_h = target->context->drawable_h; 2087 + target->base_w = (Uint16)target->context->drawable_w; 2088 + target->base_h = (Uint16)target->context->drawable_h; 2078 2089 2079 2090 // Resets virtual resolution 2080 2091 target->w = target->base_w; ··· 2202 2213 if(!target->using_virtual_resolution) 2203 2214 { 2204 2215 // Update dims 2205 - target->w = target->context->drawable_w; 2206 - target->h = target->context->drawable_h; 2216 + target->w = (Uint16)target->context->drawable_w; 2217 + target->h = (Uint16)target->context->drawable_h; 2207 2218 } 2208 2219 2209 2220 // Reset viewport 2210 - target->viewport = GPU_MakeRect(0, 0, target->context->drawable_w, target->context->drawable_h); 2221 + target->viewport = GPU_MakeRect(0, 0, (float)target->context->drawable_w, (float)target->context->drawable_h); 2211 2222 changeViewport(target); 2212 2223 2213 2224 // Reset clip ··· 2218 2229 applyTargetCamera(target); 2219 2230 } 2220 2231 2221 - target->base_w = target->context->drawable_w; 2222 - target->base_h = target->context->drawable_h; 2232 + target->base_w = (Uint16)target->context->drawable_w; 2233 + target->base_h = (Uint16)target->context->drawable_h; 2223 2234 2224 2235 return is_fullscreen; 2225 2236 } ··· 2443 2454 if(!(renderer->enabled_features & GPU_FEATURE_NON_POWER_OF_TWO)) 2444 2455 { 2445 2456 if(!isPowerOfTwo(w)) 2446 - w = getNearestPowerOf2(w); 2457 + w = (Uint16)getNearestPowerOf2(w); 2447 2458 if(!isPowerOfTwo(h)) 2448 - h = getNearestPowerOf2(h); 2459 + h = (Uint16)getNearestPowerOf2(h); 2449 2460 } 2450 2461 2451 2462 // Initialize texture using a blank buffer ··· 2662 2673 result->is_alias = GPU_FALSE; 2663 2674 2664 2675 result->using_virtual_resolution = GPU_FALSE; 2665 - result->w = w; 2666 - result->h = h; 2676 + result->w = (Uint16)w; 2677 + result->h = (Uint16)h; 2667 2678 2668 - result->base_w = w; 2669 - result->base_h = h; 2670 - result->texture_w = w; 2671 - result->texture_h = h; 2679 + result->base_w = (Uint16)w; 2680 + result->base_h = (Uint16)h; 2681 + result->texture_w = (Uint16)w; 2682 + result->texture_h = (Uint16)h; 2672 2683 2673 2684 return result; 2674 2685 #endif ··· 3117 3128 static SDL_PixelFormat* AllocFormat(GLenum glFormat) 3118 3129 { 3119 3130 // Yes, I need to do the whole thing myself... :( 3120 - int channels; 3131 + Uint8 channels; 3121 3132 Uint32 Rmask, Gmask, Bmask, Amask = 0, mask; 3122 3133 SDL_PixelFormat* result; 3123 3134 ··· 3303 3314 GPU_UnsetImageVirtualResolution(image); 3304 3315 } 3305 3316 3306 - renderer->impl->Blit(renderer, image, NULL, target, image->w / 2, image->h / 2); 3317 + renderer->impl->Blit(renderer, image, NULL, target, (float)(image->w / 2), (float)(image->h / 2)); 3307 3318 3308 3319 // Restore the saved settings 3309 3320 GPU_SetColor(image, color); ··· 3354 3365 h = getNearestPowerOf2(h); 3355 3366 } 3356 3367 3357 - upload_new_texture(texture_data, GPU_MakeRect(0, 0, w, h), internal_format, 1, w, result->bytes_per_pixel); 3368 + upload_new_texture(texture_data, GPU_MakeRect(0, 0, (float)w, (float)h), internal_format, 1, w, result->bytes_per_pixel); 3358 3369 3359 3370 3360 3371 // Tell SDL_gpu what we got. 3361 - result->texture_w = w; 3362 - result->texture_h = h; 3372 + result->texture_w = (Uint16)w; 3373 + result->texture_h = (Uint16)h; 3363 3374 3364 3375 SDL_free(texture_data); 3365 3376 } ··· 3488 3499 { 3489 3500 sourceRect.x = 0; 3490 3501 sourceRect.y = 0; 3491 - sourceRect.w = newSurface->w; 3492 - sourceRect.h = newSurface->h; 3502 + sourceRect.w = (float)newSurface->w; 3503 + sourceRect.h = (float)newSurface->h; 3493 3504 } 3494 3505 3495 3506 ··· 3637 3648 { 3638 3649 sourceRect.x = 0; 3639 3650 sourceRect.y = 0; 3640 - sourceRect.w = surface->w; 3641 - sourceRect.h = surface->h; 3651 + sourceRect.w = (float)surface->w; 3652 + sourceRect.h = (float)surface->h; 3642 3653 } 3643 3654 else 3644 3655 sourceRect = *surface_rect; ··· 3655 3666 sourceRect.y = 0; 3656 3667 } 3657 3668 if(sourceRect.x >= surface->w) 3658 - sourceRect.x = surface->w - 1; 3669 + sourceRect.x = (float)surface->w - 1; 3659 3670 if(sourceRect.y >= surface->h) 3660 - sourceRect.y = surface->h - 1; 3671 + sourceRect.y = (float)surface->h - 1; 3661 3672 3662 3673 if(sourceRect.x + sourceRect.w > surface->w) 3663 - sourceRect.w = surface->w - sourceRect.x; 3674 + sourceRect.w = (float)surface->w - sourceRect.x; 3664 3675 if(sourceRect.y + sourceRect.h > surface->h) 3665 - sourceRect.h = surface->h - sourceRect.y; 3676 + sourceRect.h = (float)surface->h - sourceRect.y; 3666 3677 3667 3678 if(sourceRect.w <= 0 || sourceRect.h <= 0) 3668 3679 { ··· 3680 3691 } 3681 3692 3682 3693 // Update image members 3683 - w = sourceRect.w; 3684 - h = sourceRect.h; 3694 + w = (int)sourceRect.w; 3695 + h = (int)sourceRect.h; 3685 3696 3686 3697 if(!image->using_virtual_resolution) 3687 3698 { 3688 - image->w = w; 3689 - image->h = h; 3699 + image->w = (Uint16)w; 3700 + image->h = (Uint16)h; 3690 3701 } 3691 - image->base_w = w; 3692 - image->base_h = h; 3702 + image->base_w = (Uint16)w; 3703 + image->base_h = (Uint16)h; 3693 3704 3694 3705 if(!(renderer->enabled_features & GPU_FEATURE_NON_POWER_OF_TWO)) 3695 3706 { ··· 3698 3709 if(!isPowerOfTwo(h)) 3699 3710 h = getNearestPowerOf2(h); 3700 3711 } 3701 - image->texture_w = w; 3702 - image->texture_h = h; 3712 + image->texture_w = (Uint16)w; 3713 + image->texture_h = (Uint16)h; 3703 3714 3704 3715 image->has_mipmaps = GPU_FALSE; 3705 3716 ··· 3713 3724 // Shift the pixels pointer to the proper source position 3714 3725 pixels += (int)(newSurface->pitch * sourceRect.y + (newSurface->format->BytesPerPixel)*sourceRect.x); 3715 3726 3716 - upload_new_texture(pixels, GPU_MakeRect(0, 0, w, h), internal_format, alignment, (newSurface->pitch / newSurface->format->BytesPerPixel), newSurface->format->BytesPerPixel); 3727 + upload_new_texture(pixels, GPU_MakeRect(0, 0, (float)w, (float)h), internal_format, alignment, (newSurface->pitch / newSurface->format->BytesPerPixel), newSurface->format->BytesPerPixel); 3717 3728 3718 3729 3719 3730 // Delete temporary surface ··· 3834 3845 format = GPU_FORMAT_RGBA; 3835 3846 } 3836 3847 3837 - image = renderer->impl->CreateImage(renderer, surface->w, surface->h, format); 3848 + image = renderer->impl->CreateImage(renderer, (Uint16)surface->w, (Uint16)surface->h, format); 3838 3849 if(image == NULL) 3839 3850 return NULL; 3840 3851 ··· 4007 4018 static void FreeContext(GPU_Context* context) 4008 4019 { 4009 4020 GPU_CONTEXT_DATA* cdata; 4010 - int i; 4021 + unsigned int i; 4011 4022 4012 4023 if(context == NULL) 4013 4024 return; ··· 4154 4165 color_index += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX; 4155 4166 4156 4167 #define SET_INDEXED_VERTEX(offset) \ 4157 - index_buffer[cdata->index_buffer_num_vertices++] = blit_buffer_starting_index + (offset); 4168 + index_buffer[cdata->index_buffer_num_vertices++] = blit_buffer_starting_index + (unsigned short)(offset); 4158 4169 4159 4170 #define SET_RELATIVE_INDEXED_VERTEX(offset) \ 4160 - index_buffer[cdata->index_buffer_num_vertices++] = cdata->blit_buffer_num_vertices + (offset); 4171 + index_buffer[cdata->index_buffer_num_vertices++] = cdata->blit_buffer_num_vertices + (unsigned short)(offset); 4161 4172 4162 4173 4163 4174 ··· 4555 4566 // Rotate about the anchor 4556 4567 if(degrees != 0.0f) 4557 4568 { 4558 - float cosA = cos(degrees*M_PI/180); 4559 - float sinA = sin(degrees*M_PI/180); 4569 + float cosA = cosf(degrees*RAD_PER_DEG); 4570 + float sinA = sinf(degrees*RAD_PER_DEG); 4560 4571 float tempX = dx1; 4561 4572 dx1 = dx1*cosA - dy1*sinA; 4562 4573 dy1 = tempX*sinA + dy1*cosA; ··· 4748 4759 lowest = a->num_values; 4749 4760 } 4750 4761 } 4762 + #else 4763 + (void)cdata; 4751 4764 #endif 4752 4765 4753 4766 return lowest; ··· 4781 4794 #else 4782 4795 #error "SDL_gpu's VBO upload needs to choose SDL_GPU_USE_BUFFER_RESET, SDL_GPU_USE_BUFFER_MAPPING, or SDL_GPU_USE_BUFFER_UPDATE and none is defined!" 4783 4796 #endif 4797 + #else 4798 + (void)indices; 4784 4799 #endif 4785 4800 } 4786 4801 ··· 5182 5197 GPU_Rect r; 5183 5198 if(target == NULL) 5184 5199 { 5185 - GPU_Rect r = {0,0,0,0}; 5200 + r.x = r.y = r.w = r.h = 0; 5186 5201 return r; 5187 5202 } 5188 5203 ··· 5423 5438 5424 5439 static GPU_TextureHandle GetTextureHandle(GPU_Renderer* renderer, GPU_Image* image) 5425 5440 { 5441 + (void)renderer; 5426 5442 return ((GPU_IMAGE_DATA*)image->data)->handle; 5427 5443 } 5428 5444 ··· 5690 5706 num_vertices = MAX(cdata->blit_buffer_num_vertices, get_lowest_attribute_num_values(cdata, cdata->blit_buffer_num_vertices)); 5691 5707 num_indices = num_vertices * 3 / 2; // 6 indices per sprite / 4 vertices per sprite = 3/2 5692 5708 5693 - DoPartialFlush(renderer, dest, context, num_vertices, blit_buffer, num_indices, index_buffer); 5709 + DoPartialFlush(renderer, dest, context, (unsigned short)num_vertices, blit_buffer, (unsigned int)num_indices, index_buffer); 5694 5710 5695 - cdata->blit_buffer_num_vertices -= num_vertices; 5711 + cdata->blit_buffer_num_vertices -= (unsigned short)num_vertices; 5696 5712 // Move our pointers ahead 5697 5713 blit_buffer += GPU_BLIT_BUFFER_FLOATS_PER_VERTEX*num_vertices; 5698 5714 index_buffer += num_indices;
+77 -85
src/renderer_shapes_GL_common.inl
··· 1 1 /* This is an implementation file to be included after certain #defines have been set. 2 2 See a particular renderer's *.c file for specifics. */ 3 3 4 - #ifndef DEGPERRAD 5 - #define DEGPERRAD 57.2957795f 6 - #endif 7 - 8 - #ifndef RADPERDEG 9 - #define RADPERDEG 0.0174532925f 10 - #endif 11 - 12 4 13 5 14 6 ··· 193 185 194 186 dt = ((end_angle - start_angle)/360)*(1.25f/sqrtf(outer_radius)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 195 187 196 - numSegments = (fabs(end_angle - start_angle)*M_PI/180)/dt; 188 + numSegments = (int)((fabs(end_angle - start_angle)*PI/180)/dt); 197 189 if(numSegments == 0) 198 190 return; 199 191 200 192 { 201 193 BEGIN_UNTEXTURED("GPU_Arc", GL_TRIANGLES, 2*(numSegments), 6*(numSegments)); 202 194 203 - c = cos(dt); 204 - s = sin(dt); 195 + c = cosf(dt); 196 + s = sinf(dt); 205 197 206 198 // Rotate to start 207 - start_angle *= M_PI/180; 208 - dx = cos(start_angle); 209 - dy = sin(start_angle); 199 + start_angle *= RAD_PER_DEG; 200 + dx = cosf(start_angle); 201 + dy = sinf(start_angle); 210 202 211 203 BEGIN_UNTEXTURED_SEGMENTS(x+inner_radius*dx, y+inner_radius*dy, x+outer_radius*dx, y+outer_radius*dy, r, g, b, a); 212 204 ··· 219 211 } 220 212 221 213 // Last point 222 - end_angle *= M_PI/180; 223 - dx = cos(end_angle); 224 - dy = sin(end_angle); 214 + end_angle *= RAD_PER_DEG; 215 + dx = cosf(end_angle); 216 + dy = sinf(end_angle); 225 217 END_UNTEXTURED_SEGMENTS(x+inner_radius*dx, y+inner_radius*dy, x+outer_radius*dx, y+outer_radius*dy, r, g, b, a); 226 218 } 227 219 } ··· 270 262 271 263 dt = ((end_angle - start_angle)/360)*(1.25f/sqrtf(radius)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 272 264 273 - numSegments = (fabs(end_angle - start_angle)*M_PI/180)/dt; 265 + numSegments = (int)((fabs(end_angle - start_angle)*RAD_PER_DEG)/dt); 274 266 if(numSegments == 0) 275 267 return; 276 268 277 269 { 278 270 BEGIN_UNTEXTURED("GPU_ArcFilled", GL_TRIANGLES, 3 + (numSegments - 1) + 1, 3 + (numSegments - 1) * 3 + 3); 279 271 280 - c = cos(dt); 281 - s = sin(dt); 272 + c = cosf(dt); 273 + s = sinf(dt); 282 274 283 275 // Rotate to start 284 - start_angle *= M_PI/180; 285 - dx = cos(start_angle); 286 - dy = sin(start_angle); 276 + start_angle *= RAD_PER_DEG; 277 + dx = cosf(start_angle); 278 + dy = sinf(start_angle); 287 279 288 280 // First triangle 289 281 SET_UNTEXTURED_VERTEX(x, y, r, g, b, a); ··· 305 297 } 306 298 307 299 // Last triangle 308 - end_angle *= M_PI/180; 309 - dx = cos(end_angle); 310 - dy = sin(end_angle); 300 + end_angle *= RAD_PER_DEG; 301 + dx = cosf(end_angle); 302 + dy = sinf(end_angle); 311 303 SET_INDEXED_VERTEX(0); // center 312 304 SET_INDEXED_VERTEX(i); // last point 313 305 SET_UNTEXTURED_VERTEX(x + radius*dx, y + radius*dy, r, g, b, a); // new point ··· 328 320 float inner_radius = radius - t; 329 321 float outer_radius = radius + t; 330 322 float dt = (1.25f/sqrtf(outer_radius)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 331 - int numSegments = 2*M_PI/dt+1; 323 + int numSegments = (int)(2*PI/dt)+1; 332 324 333 325 float tempx; 334 - float c = cos(dt); 335 - float s = sin(dt); 326 + float c = cosf(dt); 327 + float s = sinf(dt); 336 328 337 329 BEGIN_UNTEXTURED("GPU_Circle", GL_TRIANGLES, 2*(numSegments), 6*(numSegments)); 338 330 ··· 360 352 { 361 353 float dt = (1.25f/sqrtf(radius)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 362 354 float dx, dy; 363 - int numSegments = 2*M_PI/dt+1; 355 + int numSegments = (int)(2*PI/dt)+1; 364 356 int i; 365 357 366 358 float tempx; 367 - float c = cos(dt); 368 - float s = sin(dt); 359 + float c = cosf(dt); 360 + float s = sinf(dt); 369 361 370 362 BEGIN_UNTEXTURED("GPU_CircleFilled", GL_TRIANGLES, 3 + (numSegments-2), 3 + (numSegments-2)*3 + 3); 371 363 ··· 402 394 float dx, dy; 403 395 int i; 404 396 float t = thickness/2; 405 - float rot_x = cos(degrees*M_PI/180); 406 - float rot_y = sin(degrees*M_PI/180); 397 + float rot_x = cosf(degrees*RAD_PER_DEG); 398 + float rot_y = sinf(degrees*RAD_PER_DEG); 407 399 float inner_radius_x = rx - t; 408 400 float outer_radius_x = rx + t; 409 401 float inner_radius_y = ry - t; 410 402 float outer_radius_y = ry + t; 411 403 float dt = (1.25f/sqrtf(outer_radius_x > outer_radius_y? outer_radius_x : outer_radius_y)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 412 - int numSegments = 2*M_PI/dt+1; 404 + int numSegments = (int)(2*M_PI/dt)+1; 413 405 414 406 float tempx; 415 - float c = cos(dt); 416 - float s = sin(dt); 407 + float c = cosf(dt); 408 + float s = sinf(dt); 417 409 float inner_trans_x, inner_trans_y; 418 410 float outer_trans_x, outer_trans_y; 419 411 ··· 453 445 { 454 446 float dx, dy; 455 447 int i; 456 - float rot_x = cos(degrees*M_PI/180); 457 - float rot_y = sin(degrees*M_PI/180); 448 + float rot_x = cosf(degrees*RAD_PER_DEG); 449 + float rot_y = sinf(degrees*RAD_PER_DEG); 458 450 float dt = (1.25f/sqrtf(rx > ry? rx : ry)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 459 - int numSegments = 2*M_PI/dt+1; 451 + int numSegments = (int)(2*M_PI/dt)+1; 460 452 461 453 float tempx; 462 - float c = cos(dt); 463 - float s = sin(dt); 454 + float c = cosf(dt); 455 + float s = sinf(dt); 464 456 float trans_x, trans_y; 465 457 466 458 BEGIN_UNTEXTURED("GPU_EllipseFilled", GL_TRIANGLES, 3 + (numSegments-2), 3 + (numSegments-2)*3 + 3); ··· 539 531 540 532 if(!circled) 541 533 { 542 - dx1 = inner_radius*cos(end_angle*RADPERDEG); 543 - dy1 = inner_radius*sin(end_angle*RADPERDEG); 544 - dx2 = outer_radius*cos(end_angle*RADPERDEG); 545 - dy2 = outer_radius*sin(end_angle*RADPERDEG); 534 + dx1 = inner_radius*cosf(end_angle*RAD_PER_DEG); 535 + dy1 = inner_radius*sinf(end_angle*RAD_PER_DEG); 536 + dx2 = outer_radius*cosf(end_angle*RAD_PER_DEG); 537 + dy2 = outer_radius*sinf(end_angle*RAD_PER_DEG); 546 538 Line(renderer, target, x+dx1, y+dy1, x+dx2, y+dy2, color); 547 539 } 548 540 ··· 550 542 551 543 if(!circled) 552 544 { 553 - dx3 = inner_radius*cos(start_angle*RADPERDEG); 554 - dy3 = inner_radius*sin(start_angle*RADPERDEG); 555 - dx4 = outer_radius*cos(start_angle*RADPERDEG); 556 - dy4 = outer_radius*sin(start_angle*RADPERDEG); 545 + dx3 = inner_radius*cosf(start_angle*RAD_PER_DEG); 546 + dy3 = inner_radius*sinf(start_angle*RAD_PER_DEG); 547 + dx4 = outer_radius*cosf(start_angle*RAD_PER_DEG); 548 + dy4 = outer_radius*sinf(start_angle*RAD_PER_DEG); 557 549 Line(renderer, target, x+dx3, y+dy3, x+dx4, y+dy4, color); 558 550 } 559 551 } ··· 599 591 600 592 601 593 t = start_angle; 602 - dt = ((end_angle - start_angle)/360)*(1.25f/sqrtf(outer_radius)) * DEGPERRAD; // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 594 + dt = ((end_angle - start_angle)/360)*(1.25f/sqrtf(outer_radius)) * DEG_PER_RAD; // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 603 595 604 - numSegments = fabs(end_angle - start_angle)/dt; 596 + numSegments = (int)(fabs(end_angle - start_angle)/dt); 605 597 if(numSegments == 0) 606 598 return; 607 599 ··· 613 605 use_inner = GPU_FALSE; // Switches between the radii for the next point 614 606 615 607 // First triangle 616 - dx = inner_radius*cos(t*RADPERDEG); 617 - dy = inner_radius*sin(t*RADPERDEG); 608 + dx = inner_radius*cosf(t*RAD_PER_DEG); 609 + dy = inner_radius*sinf(t*RAD_PER_DEG); 618 610 SET_UNTEXTURED_VERTEX(x + dx, y + dy, r, g, b, a); 619 611 620 - dx = outer_radius*cos(t*RADPERDEG); 621 - dy = outer_radius*sin(t*RADPERDEG); 612 + dx = outer_radius*cosf(t*RAD_PER_DEG); 613 + dy = outer_radius*sinf(t*RAD_PER_DEG); 622 614 SET_UNTEXTURED_VERTEX(x + dx, y + dy, r, g, b, a); 623 615 t += dt; 624 - dx = inner_radius*cos(t*RADPERDEG); 625 - dy = inner_radius*sin(t*RADPERDEG); 616 + dx = inner_radius*cosf(t*RAD_PER_DEG); 617 + dy = inner_radius*sinf(t*RAD_PER_DEG); 626 618 SET_UNTEXTURED_VERTEX(x + dx, y + dy, r, g, b, a); 627 619 t += dt; 628 620 ··· 632 624 SET_INDEXED_VERTEX(i); 633 625 if (use_inner) 634 626 { 635 - dx = inner_radius*cos(t*RADPERDEG); 636 - dy = inner_radius*sin(t*RADPERDEG); 627 + dx = inner_radius*cosf(t*RAD_PER_DEG); 628 + dy = inner_radius*sinf(t*RAD_PER_DEG); 637 629 } 638 630 else 639 631 { 640 - dx = outer_radius*cos(t*RADPERDEG); 641 - dy = outer_radius*sin(t*RADPERDEG); 632 + dx = outer_radius*cosf(t*RAD_PER_DEG); 633 + dy = outer_radius*sinf(t*RAD_PER_DEG); 642 634 } 643 635 SET_UNTEXTURED_VERTEX(x + dx, y + dy, r, g, b, a); // new point 644 636 t += dt; ··· 649 641 t = end_angle; 650 642 if (use_inner) 651 643 { 652 - dx = inner_radius*cos(t*RADPERDEG); 653 - dy = inner_radius*sin(t*RADPERDEG); 644 + dx = inner_radius*cosf(t*RAD_PER_DEG); 645 + dy = inner_radius*sinf(t*RAD_PER_DEG); 654 646 } 655 647 else 656 648 { 657 - dx = outer_radius*cos(t*RADPERDEG); 658 - dy = outer_radius*sin(t*RADPERDEG); 649 + dx = outer_radius*cosf(t*RAD_PER_DEG); 650 + dy = outer_radius*sinf(t*RAD_PER_DEG); 659 651 } 660 652 SET_INDEXED_VERTEX(i - 1); 661 653 SET_INDEXED_VERTEX(i); ··· 665 657 666 658 if (use_inner) 667 659 { 668 - dx = inner_radius*cos(t*RADPERDEG); 669 - dy = inner_radius*sin(t*RADPERDEG); 660 + dx = inner_radius*cosf(t*RAD_PER_DEG); 661 + dy = inner_radius*sinf(t*RAD_PER_DEG); 670 662 } 671 663 else 672 664 { 673 - dx = outer_radius*cos(t*RADPERDEG); 674 - dy = outer_radius*sin(t*RADPERDEG); 665 + dx = outer_radius*cosf(t*RAD_PER_DEG); 666 + dy = outer_radius*sinf(t*RAD_PER_DEG); 675 667 } 676 668 SET_INDEXED_VERTEX(i - 1); 677 669 SET_INDEXED_VERTEX(i); ··· 822 814 float inner_radius = radius - t; 823 815 float outer_radius = radius + t; 824 816 float dt = (1.25f/sqrtf(outer_radius)); // s = rA, so dA = ds/r. ds of 1.25*sqrt(radius) is good, use A in degrees. 825 - int numSegments = 2*M_PI/dt+1; 817 + int numSegments = (int)(2*PI/dt)+1; 826 818 if(numSegments < 4) 827 819 numSegments = 4; 828 820 829 821 // Make a multiple of 4 so we can have even corners 830 822 numSegments += numSegments % 4; 831 823 832 - dt = 2*M_PI/(numSegments-1); 824 + dt = 2*PI/(numSegments-1); 833 825 834 826 { 835 827 float x, y; ··· 838 830 int go_to_fourth = 3*numSegments / 4; 839 831 840 832 float tempx; 841 - float c = cos(dt); 842 - float s = sin(dt); 833 + float c = cosf(dt); 834 + float s = sinf(dt); 843 835 844 836 // Add another 4 for the extra corner vertices 845 837 BEGIN_UNTEXTURED("GPU_RectangleRound", GL_TRIANGLES, 2*(numSegments + 4), 6*(numSegments + 4)); ··· 923 915 radius = (y2 - y1) / 2; 924 916 925 917 { 926 - float tau = 2 * M_PI; 918 + float tau = 2 * PI; 927 919 928 920 int verts_per_corner = 7; 929 921 float corner_angle_increment = (tau / 4) / (verts_per_corner - 1); // 0, 15, 30, 45, 60, 75, 90 ··· 938 930 939 931 // First triangle 940 932 SET_UNTEXTURED_VERTEX((x2 + x1) / 2, (y2 + y1) / 2, r, g, b, a); // Center 941 - SET_UNTEXTURED_VERTEX(x2 - radius + cos(angle)*radius, y1 + radius + sin(angle)*radius, r, g, b, a); 933 + SET_UNTEXTURED_VERTEX(x2 - radius + cosf(angle)*radius, y1 + radius + sinf(angle)*radius, r, g, b, a); 942 934 angle += corner_angle_increment; 943 - SET_UNTEXTURED_VERTEX(x2 - radius + cos(angle)*radius, y1 + radius + sin(angle)*radius, r, g, b, a); 935 + SET_UNTEXTURED_VERTEX(x2 - radius + cosf(angle)*radius, y1 + radius + sinf(angle)*radius, r, g, b, a); 944 936 angle += corner_angle_increment; 945 937 946 938 for (i = 2; i < verts_per_corner; i++) 947 939 { 948 940 SET_INDEXED_VERTEX(0); 949 941 SET_INDEXED_VERTEX(last_index++); 950 - SET_UNTEXTURED_VERTEX(x2 - radius + cos(angle)*radius, y1 + radius + sin(angle)*radius, r, g, b, a); 942 + SET_UNTEXTURED_VERTEX(x2 - radius + cosf(angle)*radius, y1 + radius + sinf(angle)*radius, r, g, b, a); 951 943 angle += corner_angle_increment; 952 944 } 953 945 954 946 SET_INDEXED_VERTEX(0); 955 947 SET_INDEXED_VERTEX(last_index++); 956 - SET_UNTEXTURED_VERTEX(x2 - radius + cos(angle)*radius, y2 - radius + sin(angle)*radius, r, g, b, a); 948 + SET_UNTEXTURED_VERTEX(x2 - radius + cosf(angle)*radius, y2 - radius + sinf(angle)*radius, r, g, b, a); 957 949 for (i = 1; i < verts_per_corner; i++) 958 950 { 959 951 SET_INDEXED_VERTEX(0); 960 952 SET_INDEXED_VERTEX(last_index++); 961 - SET_UNTEXTURED_VERTEX(x2 - radius + cos(angle)*radius, y2 - radius + sin(angle)*radius, r, g, b, a); 953 + SET_UNTEXTURED_VERTEX(x2 - radius + cosf(angle)*radius, y2 - radius + sinf(angle)*radius, r, g, b, a); 962 954 angle += corner_angle_increment; 963 955 } 964 956 965 957 SET_INDEXED_VERTEX(0); 966 958 SET_INDEXED_VERTEX(last_index++); 967 - SET_UNTEXTURED_VERTEX(x1 + radius + cos(angle)*radius, y2 - radius + sin(angle)*radius, r, g, b, a); 959 + SET_UNTEXTURED_VERTEX(x1 + radius + cosf(angle)*radius, y2 - radius + sinf(angle)*radius, r, g, b, a); 968 960 for (i = 1; i < verts_per_corner; i++) 969 961 { 970 962 SET_INDEXED_VERTEX(0); 971 963 SET_INDEXED_VERTEX(last_index++); 972 - SET_UNTEXTURED_VERTEX(x1 + radius + cos(angle)*radius, y2 - radius + sin(angle)*radius, r, g, b, a); 964 + SET_UNTEXTURED_VERTEX(x1 + radius + cosf(angle)*radius, y2 - radius + sinf(angle)*radius, r, g, b, a); 973 965 angle += corner_angle_increment; 974 966 } 975 967 976 968 SET_INDEXED_VERTEX(0); 977 969 SET_INDEXED_VERTEX(last_index++); 978 - SET_UNTEXTURED_VERTEX(x1 + radius + cos(angle)*radius, y1 + radius + sin(angle)*radius, r, g, b, a); 970 + SET_UNTEXTURED_VERTEX(x1 + radius + cosf(angle)*radius, y1 + radius + sinf(angle)*radius, r, g, b, a); 979 971 for (i = 1; i < verts_per_corner; i++) 980 972 { 981 973 SET_INDEXED_VERTEX(0); 982 974 SET_INDEXED_VERTEX(last_index++); 983 - SET_UNTEXTURED_VERTEX(x1 + radius + cos(angle)*radius, y1 + radius + sin(angle)*radius, r, g, b, a); 975 + SET_UNTEXTURED_VERTEX(x1 + radius + cosf(angle)*radius, y1 + radius + sinf(angle)*radius, r, g, b, a); 984 976 angle += corner_angle_increment; 985 977 } 986 978 ··· 1040 1032 x1 = vertices[ i * 2 ]; 1041 1033 y1 = vertices[ i * 2 + 1 ]; 1042 1034 i++; 1043 - if ( i == num_vertices ) 1035 + if ( i == (int)num_vertices ) 1044 1036 { 1045 1037 x2 = vertices[ 0 ]; 1046 1038 y2 = vertices[ 1 ];