this repo has no description
0
fork

Configure Feed

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

Added base_w and base_h to GPU_Target so the underlying dimensions are easier to get at. Changed texture_w and texture_h in GPU_Image to base_w and base_h to match GPU_Target.

+44 -59
+30 -46
SDL_gpu/GL_common/SDL_gpu_GL_common.inl
··· 1049 1049 target->renderer = renderer; 1050 1050 target->w = target->context->window_w; 1051 1051 target->h = target->context->window_h; 1052 + target->base_w = target->context->window_w; 1053 + target->base_h = target->context->window_h; 1052 1054 1053 1055 target->use_clip_rect = 0; 1054 1056 target->clip_rect.x = 0; ··· 1497 1499 target->context->stored_window_w = target->context->window_w; 1498 1500 target->context->stored_window_h = target->context->window_h; 1499 1501 1502 + // Update base dimensions 1503 + target->base_w = target->context->window_w; 1504 + target->base_h = target->context->window_h; 1505 + 1500 1506 // Resets virtual resolution 1501 - target->w = target->context->window_w; 1502 - target->h = target->context->window_h; 1507 + target->w = target->base_w; 1508 + target->h = target->base_h; 1503 1509 target->using_virtual_resolution = 0; 1504 1510 1505 1511 // Resets viewport ··· 1544 1550 if(isCurrent) 1545 1551 renderer->impl->FlushBlitBuffer(renderer); 1546 1552 1547 - if(target->image != NULL) 1548 - { 1549 - target->w = target->image->w; 1550 - target->h = target->image->h; 1551 - } 1552 - else if(target->context != NULL) 1553 - { 1554 - target->w = target->context->window_w; 1555 - target->h = target->context->window_h; 1556 - } 1553 + target->w = target->base_w; 1554 + target->h = target->base_h; 1557 1555 1558 1556 target->using_virtual_resolution = 0; 1559 1557 ··· 1794 1792 result->w = w; 1795 1793 result->h = h; 1796 1794 // POT textures will change this later 1797 - result->texture_w = w; 1798 - result->texture_h = h; 1795 + result->base_w = w; 1796 + result->base_h = h; 1799 1797 1800 1798 return result; 1801 1799 } ··· 1853 1851 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, 1854 1852 internal_format, GL_UNSIGNED_BYTE, zero_buffer); 1855 1853 // Tell SDL_gpu what we got. 1856 - result->texture_w = w; 1857 - result->texture_h = h; 1854 + result->base_w = w; 1855 + result->base_h = h; 1858 1856 1859 1857 // Restore GL defaults 1860 1858 glPixelStorei(GL_UNPACK_ALIGNMENT, 4); ··· 1948 1946 default: 1949 1947 GPU_PushErrorCode("GPU_CreateImageUsingTexture", GPU_ERROR_USER_ERROR, "Unsupported value for GL_TEXTURE_MIN_FILTER (0x%x)", min_filter); 1950 1948 filter_mode = GPU_FILTER_LINEAR; 1951 - return; 1949 + break; 1952 1950 } 1953 1951 1954 1952 ··· 1970 1968 default: 1971 1969 GPU_PushErrorCode("GPU_CreateImageUsingTexture", GPU_ERROR_USER_ERROR, "Unsupported value for GL_TEXTURE_WRAP_S (0x%x)", wrap_s); 1972 1970 wrap_x = GPU_WRAP_NONE; 1973 - return; 1971 + break; 1974 1972 } 1975 1973 1976 1974 switch(wrap_t) ··· 1987 1985 default: 1988 1986 GPU_PushErrorCode("GPU_CreateImageUsingTexture", GPU_ERROR_USER_ERROR, "Unsupported value for GL_TEXTURE_WRAP_T (0x%x)", wrap_t); 1989 1987 wrap_y = GPU_WRAP_NONE; 1990 - return; 1988 + break; 1991 1989 } 1992 1990 1993 1991 // Finally create the image ··· 2022 2020 result->w = w; 2023 2021 result->h = h; 2024 2022 2025 - result->texture_w = w; 2026 - result->texture_h = h; 2023 + result->base_w = w; 2024 + result->base_h = h; 2027 2025 2028 2026 return result; 2029 2027 } ··· 2075 2073 2076 2074 if(bindFramebuffer(renderer, source)) 2077 2075 { 2078 - int w, h; 2079 - if(source->image != NULL) 2080 - { 2081 - w = source->image->w; 2082 - h = source->image->h; 2083 - } 2084 - else if(source->context != NULL) 2085 - { 2086 - w = source->context->window_w; 2087 - h = source->context->window_h; 2088 - } 2089 - else 2090 - { 2091 - w = source->w; 2092 - h = source->h; 2093 - } 2094 - glReadPixels(0, 0, w, h, format, GL_UNSIGNED_BYTE, pixels); 2076 + glReadPixels(0, 0, source->base_w, source->base_h, format, GL_UNSIGNED_BYTE, pixels); 2095 2077 return 1; 2096 2078 } 2097 2079 return 0; ··· 2791 2773 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, 2792 2774 internal_format, GL_UNSIGNED_BYTE, texture_data); 2793 2775 // Tell SDL_gpu what we got. 2794 - result->texture_w = w; 2795 - result->texture_h = h; 2776 + result->base_w = w; 2777 + result->base_h = h; 2796 2778 2797 2779 // Restore GL defaults 2798 2780 glPixelStorei(GL_UNPACK_ALIGNMENT, 4); ··· 3207 3189 result->image = image; 3208 3190 result->w = image->w; 3209 3191 result->h = image->h; 3192 + result->base_w = image->base_w; 3193 + result->base_h = image->base_h; 3210 3194 3211 3195 result->viewport = GPU_MakeRect(0, 0, result->w, result->h); 3212 3196 ··· 3215 3199 result->use_clip_rect = 0; 3216 3200 result->clip_rect.x = 0; 3217 3201 result->clip_rect.y = 0; 3218 - result->clip_rect.w = image->w; 3219 - result->clip_rect.h = image->h; 3202 + result->clip_rect.w = result->w; 3203 + result->clip_rect.h = result->h; 3220 3204 result->use_color = 0; 3221 3205 3222 3206 image->target = result; ··· 3467 3451 return; 3468 3452 } 3469 3453 3470 - tex_w = image->texture_w; 3471 - tex_h = image->texture_h; 3454 + tex_w = image->base_w; 3455 + tex_h = image->base_h; 3472 3456 3473 3457 if(image->snap_mode == GPU_SNAP_POSITION || image->snap_mode == GPU_SNAP_POSITION_AND_DIMENSIONS) 3474 3458 { ··· 3674 3658 return; 3675 3659 } 3676 3660 3677 - tex_w = image->texture_w; 3678 - tex_h = image->texture_h; 3661 + tex_w = image->base_w; 3662 + tex_h = image->base_h; 3679 3663 3680 3664 if(image->snap_mode == GPU_SNAP_POSITION || image->snap_mode == GPU_SNAP_POSITION_AND_DIMENSIONS) 3681 3665 {
+6 -6
SDL_gpu/SDL_gpu.c
··· 1179 1179 w2 = 0.5f*image->w; // texcoord helpers for position expansion 1180 1180 h2 = 0.5f*image->h; 1181 1181 1182 - tex_w = image->texture_w; 1183 - tex_h = image->texture_h; 1182 + tex_w = image->base_w; 1183 + tex_h = image->base_h; 1184 1184 1185 1185 for(n = 0; n < num_sprites; n++) 1186 1186 { ··· 1468 1468 w2 = 0.5f*image->w; // texcoord helpers for position expansion 1469 1469 h2 = 0.5f*image->h; 1470 1470 1471 - tex_w = image->texture_w; 1472 - tex_h = image->texture_h; 1471 + tex_w = image->base_w; 1472 + tex_h = image->base_h; 1473 1473 1474 1474 for(n = 0; n < num_sprites; n++) 1475 1475 { ··· 1771 1771 1772 1772 if(using_texture) 1773 1773 { 1774 - tex_w = image->texture_w; 1775 - tex_h = image->texture_h; 1774 + tex_w = image->base_w; 1775 + tex_h = image->base_h; 1776 1776 } 1777 1777 1778 1778 for(n = 0; n < num_vertices; n++)
+2 -1
SDL_gpu/SDL_gpu.h
··· 210 210 GPU_FormatEnum format; 211 211 int num_layers; 212 212 int bytes_per_pixel; 213 - Uint32 texture_w, texture_h; // Underlying texture dimensions 213 + Uint32 base_w, base_h; // Underlying texture dimensions 214 214 Uint8 has_mipmaps; 215 215 216 216 SDL_Color color; ··· 330 330 void* data; 331 331 Uint16 w, h; 332 332 Uint8 using_virtual_resolution; 333 + Uint16 base_w, base_h; // The true dimensions of the underlying image or window 333 334 Uint8 use_clip_rect; 334 335 GPU_Rect clip_rect; 335 336 Uint8 use_color;
+6 -6
demos/triangle-batch/main.c
··· 416 416 offset_y1 = rand()%(image->h/2); 417 417 x1 = vertex_values[val_n++] = rand()%screen->w + offset_x1; 418 418 y1 = vertex_values[val_n++] = rand()%screen->h + offset_y1; 419 - vertex_values[val_n++] = offset_x1/image->texture_w; 420 - vertex_values[val_n++] = offset_y1/image->texture_h; 419 + vertex_values[val_n++] = offset_x1/image->base_w; 420 + vertex_values[val_n++] = offset_y1/image->base_h; 421 421 vertex_values[val_n++] = rand()%101/100.0f; 422 422 vertex_values[val_n++] = rand()%101/100.0f; 423 423 vertex_values[val_n++] = rand()%101/100.0f; ··· 427 427 offset_y2 = 5 + rand()%(image->h/2); 428 428 vertex_values[val_n++] = x1 + offset_x2; 429 429 vertex_values[val_n++] = y1 + offset_y2; 430 - vertex_values[val_n++] = (offset_x1 + offset_x2)/image->texture_w; 431 - vertex_values[val_n++] = (offset_y1 + offset_y2)/image->texture_h; 430 + vertex_values[val_n++] = (offset_x1 + offset_x2)/image->base_w; 431 + vertex_values[val_n++] = (offset_y1 + offset_y2)/image->base_h; 432 432 vertex_values[val_n++] = rand()%101/100.0f; 433 433 vertex_values[val_n++] = rand()%101/100.0f; 434 434 vertex_values[val_n++] = rand()%101/100.0f; ··· 438 438 offset_y3 = 5 + rand()%(image->h/2); 439 439 vertex_values[val_n++] = x1 + offset_x3; 440 440 vertex_values[val_n++] = y1 + offset_y3; 441 - vertex_values[val_n++] = (offset_x1 + offset_x3)/image->texture_w; 442 - vertex_values[val_n++] = (offset_y1 + offset_y3)/image->texture_h; 441 + vertex_values[val_n++] = (offset_x1 + offset_x3)/image->base_w; 442 + vertex_values[val_n++] = (offset_y1 + offset_y3)/image->base_h; 443 443 vertex_values[val_n++] = rand()%101/100.0f; 444 444 vertex_values[val_n++] = rand()%101/100.0f; 445 445 vertex_values[val_n++] = rand()%101/100.0f;