this repo has no description
0
fork

Configure Feed

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

Fixed readTargetPixels() so it doesn't crash on virtual resolutions. Added a check to SetWindowResolution() so it can skip the resolution change if the window is already at that resolution (making it safer to call on user resize). Removed another (the last?) texture enable call from GLES 2.

+45 -17
+45 -17
SDL_gpu/GL_common/SDL_gpu_GL_common.inl
··· 1043 1043 1044 1044 cdata->last_use_texturing = 1; 1045 1045 cdata->last_shape = GL_TRIANGLES; 1046 - #ifndef SDL_GPU_SKIP_ENABLE_TEXTURE_2D 1047 - glEnable(GL_TEXTURE_2D); 1048 - #endif 1049 1046 1050 1047 cdata->last_use_blending = 0; 1051 1048 cdata->last_blend_mode = GPU_GetBlendModeFromPreset(GPU_BLEND_NORMAL); ··· 1146 1143 target->context->matrix_mode = GPU_MODELVIEW; 1147 1144 1148 1145 // Modes 1149 - glEnable( GL_TEXTURE_2D ); 1146 + #ifndef SDL_GPU_SKIP_ENABLE_TEXTURE_2D 1147 + glEnable(GL_TEXTURE_2D); 1148 + #endif 1150 1149 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1151 1150 1152 1151 glDisable(GL_BLEND); ··· 1380 1379 1381 1380 #ifdef SDL_GPU_USE_SDL2 1382 1381 1383 - SDL_SetWindowSize(SDL_GetWindowFromID(target->context->windowID), w, h); 1382 + // Don't need to resize (only update internals) when resolution isn't changing. 1384 1383 SDL_GetWindowSize(SDL_GetWindowFromID(target->context->windowID), &target->context->window_w, &target->context->window_h); 1384 + if(target->context->window_w != w || target->context->window_h != h) 1385 + { 1386 + SDL_SetWindowSize(SDL_GetWindowFromID(target->context->windowID), w, h); 1387 + SDL_GetWindowSize(SDL_GetWindowFromID(target->context->windowID), &target->context->window_w, &target->context->window_h); 1388 + } 1385 1389 1386 1390 #else 1387 - SDL_Surface* surf = SDL_GetVideoSurface(); 1388 - Uint32 flags = surf->flags; 1391 + SDL_Surface* screen = SDL_GetVideoSurface(); 1392 + Uint32 flags = screen->flags; 1393 + GPU_Context* context; 1389 1394 1395 + // Don't need to resize (only update internals) when resolution isn't changing. 1396 + if(screen->w != w || screen->h != h) 1397 + { 1398 + screen = SDL_SetVideoMode(w, h, 0, flags); 1399 + // There's a bug in SDL. This is a workaround. Let's resize again: 1400 + screen = SDL_SetVideoMode(w, h, 0, flags); 1390 1401 1391 - SDL_Surface* screen = SDL_SetVideoMode(w, h, 0, flags); 1392 - // There's a bug in SDL. This is a workaround. Let's resize again: 1393 - screen = SDL_SetVideoMode(w, h, 0, flags); 1394 - 1395 - if(screen == NULL) 1396 - return 0; 1402 + if(screen == NULL) 1403 + return 0; 1404 + } 1397 1405 1398 1406 target->context->window_w = screen->w; 1399 1407 target->context->window_h = screen->h; 1400 1408 1401 1409 // FIXME: Does the entire GL state need to be reset because the screen was recreated? 1402 - // FIXME: This interferes with context state 1403 - glEnable( GL_TEXTURE_2D ); 1410 + 1411 + // Reset texturing state 1412 + context = renderer->current_context_target->context; 1413 + context->use_texturing = 1; 1414 + ((GPU_CONTEXT_DATA*)context->data)->last_use_texturing = 0; 1415 + 1416 + // Clear target (no state change) 1404 1417 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); 1405 - 1406 1418 glClear( GL_COLOR_BUFFER_BIT ); 1407 1419 #endif 1408 1420 ··· 1825 1837 1826 1838 if(bindFramebuffer(renderer, source)) 1827 1839 { 1828 - glReadPixels(0, 0, source->w, source->h, format, GL_UNSIGNED_BYTE, pixels); 1840 + int w, h; 1841 + if(source->image != NULL) 1842 + { 1843 + w = source->image->w; 1844 + h = source->image->h; 1845 + } 1846 + else if(source->context != NULL) 1847 + { 1848 + w = source->context->window_w; 1849 + h = source->context->window_h; 1850 + } 1851 + else 1852 + { 1853 + w = source->w; 1854 + h = source->h; 1855 + } 1856 + glReadPixels(0, 0, w, h, format, GL_UNSIGNED_BYTE, pixels); 1829 1857 return 1; 1830 1858 } 1831 1859 return 0;