this repo has no description
0
fork

Configure Feed

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

Added texture_w and texture_h back to GPU_Image, so now those values represent the underlying texture and base_w and base_h will account for lack of NPOT support. This is to set up for virtual resolution for images (which can revert to the base values).

+45 -36
+2 -1
include/SDL_gpu.h
··· 237 237 GPU_FormatEnum format; 238 238 int num_layers; 239 239 int bytes_per_pixel; 240 - Uint16 base_w, base_h; // Underlying texture dimensions 240 + Uint16 base_w, base_h; // Original image dimensions 241 + Uint16 texture_w, texture_h; // Underlying texture dimensions 241 242 Uint8 has_mipmaps; 242 243 243 244 SDL_Color color;
+6 -6
src/SDL_gpu.c
··· 1220 1220 w2 = 0.5f*image->w; // texcoord helpers for position expansion 1221 1221 h2 = 0.5f*image->h; 1222 1222 1223 - tex_w = image->base_w; 1224 - tex_h = image->base_h; 1223 + tex_w = image->texture_w; 1224 + tex_h = image->texture_h; 1225 1225 1226 1226 for(n = 0; n < num_sprites; n++) 1227 1227 { ··· 1509 1509 w2 = 0.5f*image->w; // texcoord helpers for position expansion 1510 1510 h2 = 0.5f*image->h; 1511 1511 1512 - tex_w = image->base_w; 1513 - tex_h = image->base_h; 1512 + tex_w = image->texture_w; 1513 + tex_h = image->texture_h; 1514 1514 1515 1515 for(n = 0; n < num_sprites; n++) 1516 1516 { ··· 1812 1812 1813 1813 if(using_texture) 1814 1814 { 1815 - tex_w = image->base_w; 1816 - tex_h = image->base_h; 1815 + tex_w = image->texture_w; 1816 + tex_h = image->texture_h; 1817 1817 } 1818 1818 1819 1819 for(n = 0; n < num_vertices; n++)
+26 -19
src/renderer_GL_common.inl
··· 1811 1811 1812 1812 result->w = w; 1813 1813 result->h = h; 1814 - // POT textures will change this later 1815 1814 result->base_w = w; 1816 1815 result->base_h = h; 1816 + // POT textures will change this later 1817 + result->texture_w = w; 1818 + result->texture_h = h; 1817 1819 1818 1820 return result; 1819 1821 } ··· 1870 1872 1871 1873 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, 1872 1874 internal_format, GL_UNSIGNED_BYTE, zero_buffer); 1873 - // Tell SDL_gpu what we got. 1874 - result->base_w = w; 1875 - result->base_h = h; 1875 + // Tell SDL_gpu what we got (power-of-two requirements have made this change) 1876 + result->texture_w = w; 1877 + result->texture_h = h; 1876 1878 1877 1879 // Restore GL defaults 1878 1880 glPixelStorei(GL_UNPACK_ALIGNMENT, 4); ··· 2042 2044 2043 2045 result->base_w = w; 2044 2046 result->base_h = h; 2047 + result->texture_w = w; 2048 + result->texture_h = h; 2045 2049 2046 2050 return result; 2047 2051 } ··· 2120 2124 created_target = 1; 2121 2125 } 2122 2126 // Get the data 2127 + // FIXME: This may use different dimensions than the OpenGL code... (base_w vs texture_w) 2128 + // FIXME: I should force it to use the texture dims. 2123 2129 result = readTargetPixels(renderer, source->target, format, pixels); 2124 2130 // Free the target 2125 2131 if(created_target) ··· 2153 2159 bytes_per_pixel = target->image->bytes_per_pixel; 2154 2160 data = (unsigned char*)malloc(target->base_w * target->base_h * bytes_per_pixel); 2155 2161 2162 + // This can take regions of pixels, so using base_w and base_h with an image target should be fine. 2156 2163 if(!readTargetPixels(renderer, target, ((GPU_TARGET_DATA*)target->data)->format, data)) 2157 2164 { 2158 2165 free(data); ··· 2183 2190 if(image->target != NULL && isCurrentTarget(renderer, image->target)) 2184 2191 renderer->impl->FlushBlitBuffer(renderer); 2185 2192 2186 - data = (unsigned char*)malloc(image->base_w * image->base_h * image->bytes_per_pixel); 2193 + data = (unsigned char*)malloc(image->texture_w * image->texture_h * image->bytes_per_pixel); 2187 2194 2188 2195 // FIXME: Sometimes the texture is stored and read in RGBA even when I specify RGB. getRawImageData() might need to return the stored format or Bpp. 2189 2196 if(!readImagePixels(renderer, image, ((GPU_IMAGE_DATA*)image->data)->format, data)) ··· 2210 2217 unsigned char* data; 2211 2218 2212 2219 if(image == NULL || filename == NULL || 2213 - image->base_w < 1 || image->base_h < 1 || image->bytes_per_pixel < 1 || image->bytes_per_pixel > 4) 2220 + image->texture_w < 1 || image->texture_h < 1 || image->bytes_per_pixel < 1 || image->bytes_per_pixel > 4) 2214 2221 { 2215 2222 return 0; 2216 2223 } ··· 2243 2250 switch(format) 2244 2251 { 2245 2252 case GPU_FILE_PNG: 2246 - result = (stbi_write_png(filename, image->base_w, image->base_h, image->bytes_per_pixel, (const unsigned char *const)data, 0) > 0); 2253 + result = (stbi_write_png(filename, image->texture_w, image->texture_h, image->bytes_per_pixel, (const unsigned char *const)data, 0) > 0); 2247 2254 break; 2248 2255 case GPU_FILE_BMP: 2249 - result = (stbi_write_bmp(filename, image->base_w, image->base_h, image->bytes_per_pixel, (void*)data) > 0); 2256 + result = (stbi_write_bmp(filename, image->texture_w, image->texture_h, image->bytes_per_pixel, (void*)data) > 0); 2250 2257 break; 2251 2258 case GPU_FILE_TGA: 2252 - result = (stbi_write_tga(filename, image->base_w, image->base_h, image->bytes_per_pixel, (void*)data) > 0); 2259 + result = (stbi_write_tga(filename, image->texture_w, image->texture_h, image->bytes_per_pixel, (void*)data) > 0); 2253 2260 break; 2254 2261 default: 2255 2262 GPU_PushErrorCode("GPU_SaveImage", GPU_ERROR_DATA_ERROR, "Unsupported output file format"); ··· 2307 2314 GPU_PushErrorCode("GPU_CopySurfaceFromImage", GPU_ERROR_NULL_ARGUMENT, "image"); 2308 2315 return NULL; 2309 2316 } 2310 - if(image->base_w < 1 || image->base_h < 1) 2317 + if(image->texture_w < 1 || image->texture_h < 1) 2311 2318 { 2312 2319 GPU_PushErrorCode("GPU_CopySurfaceFromImage", GPU_ERROR_DATA_ERROR, "Invalid image dimensions (%dx%d)", image->base_w, image->base_h); 2313 2320 return NULL; ··· 2323 2330 2324 2331 format = AllocFormat(((GPU_IMAGE_DATA*)image->data)->format); 2325 2332 2326 - result = SDL_CreateRGBSurfaceFrom(data, image->base_w, image->base_h, format->BitsPerPixel, image->base_w*format->BytesPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask); 2333 + result = SDL_CreateRGBSurfaceFrom(data, image->texture_w, image->texture_h, format->BitsPerPixel, image->base_w*format->BytesPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask); 2327 2334 if(result != NULL) 2328 2335 result->flags &= ~SDL_PREALLOC; // Make SDL take ownership of the data memory 2329 2336 ··· 2813 2820 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, 2814 2821 internal_format, GL_UNSIGNED_BYTE, texture_data); 2815 2822 // Tell SDL_gpu what we got. 2816 - result->base_w = w; 2817 - result->base_h = h; 2823 + result->texture_w = w; 2824 + result->texture_h = h; 2818 2825 2819 2826 // Restore GL defaults 2820 2827 glPixelStorei(GL_UNPACK_ALIGNMENT, 4); ··· 3229 3236 result->image = image; 3230 3237 result->w = image->w; 3231 3238 result->h = image->h; 3232 - result->base_w = image->base_w; 3233 - result->base_h = image->base_h; 3239 + result->base_w = image->texture_w; 3240 + result->base_h = image->texture_h; 3234 3241 3235 3242 result->viewport = GPU_MakeRect(0, 0, result->w, result->h); 3236 3243 ··· 3491 3498 return; 3492 3499 } 3493 3500 3494 - tex_w = image->base_w; 3495 - tex_h = image->base_h; 3501 + tex_w = image->texture_w; 3502 + tex_h = image->texture_h; 3496 3503 3497 3504 if(image->snap_mode == GPU_SNAP_POSITION || image->snap_mode == GPU_SNAP_POSITION_AND_DIMENSIONS) 3498 3505 { ··· 3698 3705 return; 3699 3706 } 3700 3707 3701 - tex_w = image->base_w; 3702 - tex_h = image->base_h; 3708 + tex_w = image->texture_w; 3709 + tex_h = image->texture_h; 3703 3710 3704 3711 if(image->snap_mode == GPU_SNAP_POSITION || image->snap_mode == GPU_SNAP_POSITION_AND_DIMENSIONS) 3705 3712 {
+5 -4
tests/renderer/main.c
··· 453 453 454 454 result->w = w; 455 455 result->h = h; 456 - 457 456 result->base_w = w; 458 457 result->base_h = h; 458 + result->texture_w = w; 459 + result->texture_h = h; 459 460 460 461 return result; 461 462 } ··· 575 576 if(image == NULL) 576 577 return NULL; 577 578 578 - return SDL_CreateRGBSurface(SDL_SWSURFACE, image->base_w, image->base_h, 32, 0, 0, 0, 0); 579 + return SDL_CreateRGBSurface(SDL_SWSURFACE, image->texture_w, image->texture_h, 32, 0, 0, 0, 0); 579 580 } 580 581 581 582 ··· 632 633 result->image = image; 633 634 result->w = image->w; 634 635 result->h = image->h; 635 - result->base_w = image->base_w; 636 - result->base_h = image->base_h; 636 + result->base_w = image->texture_w; 637 + result->base_h = image->texture_h; 637 638 638 639 result->viewport = GPU_MakeRect(0, 0, result->w, result->h); 639 640
+6 -6
tests/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->base_w; 420 - vertex_values[val_n++] = offset_y1/image->base_h; 419 + vertex_values[val_n++] = offset_x1/image->texture_w; 420 + vertex_values[val_n++] = offset_y1/image->texture_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->base_w; 431 - vertex_values[val_n++] = (offset_y1 + offset_y2)/image->base_h; 430 + vertex_values[val_n++] = (offset_x1 + offset_x2)/image->texture_w; 431 + vertex_values[val_n++] = (offset_y1 + offset_y2)/image->texture_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->base_w; 442 - vertex_values[val_n++] = (offset_y1 + offset_y3)/image->base_h; 441 + vertex_values[val_n++] = (offset_x1 + offset_x3)/image->texture_w; 442 + vertex_values[val_n++] = (offset_y1 + offset_y3)/image->texture_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;