this repo has no description
0
fork

Configure Feed

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

Added GPU_Context::drawable_w and drawable_h to correspond with SDL_GL_GetDrawableSize(). This is used to support differences in the reported window size and the actual rendering resolution, e.g. for SDL_WINDOW_ALLOW_HIGHDPI.

+51 -37
+4
include/SDL_gpu.h
··· 320 320 int window_w; 321 321 int window_h; 322 322 323 + /*! Drawable region dimensions */ 324 + int drawable_w; 325 + int drawable_h; 326 + 323 327 /*! Window dimensions for restoring windowed mode after GPU_SetFullscreen(1,1). */ 324 328 int stored_window_w; 325 329 int stored_window_h;
+47 -37
src/renderer_GL_common.inl
··· 495 495 y = context_target->h - (target->clip_rect.y + target->clip_rect.h); 496 496 else 497 497 y = target->clip_rect.y; 498 - float xFactor = ((float)context_target->context->window_w)/context_target->w; 499 - float yFactor = ((float)context_target->context->window_h)/context_target->h; 498 + float xFactor = ((float)context_target->context->drawable_w)/context_target->w; 499 + float yFactor = ((float)context_target->context->drawable_h)/context_target->h; 500 500 glScissor(target->clip_rect.x * xFactor, y * yFactor, target->clip_rect.w * xFactor, target->clip_rect.h * yFactor); 501 501 } 502 502 else ··· 745 745 if(target->image != NULL) 746 746 y = target->image->h - viewport.h - viewport.y; 747 747 else if(target->context != NULL) 748 - y = target->context->window_h - viewport.h - viewport.y; 748 + y = target->context->drawable_h - viewport.h - viewport.y; 749 749 } 750 750 751 751 glViewport(viewport.x, y, viewport.w, viewport.h); ··· 1050 1050 1051 1051 // Store the window info 1052 1052 SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h); 1053 + SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h); 1053 1054 target->context->stored_window_w = target->context->window_w; 1054 1055 target->context->stored_window_h = target->context->window_h; 1055 1056 target->context->windowID = SDL_GetWindowID(window); ··· 1079 1080 } 1080 1081 1081 1082 target->context->windowID = 1; 1082 - target->context->window_w = screen->w; 1083 - target->context->window_h = screen->h; 1083 + target->context->window_w = target->context->drawable_w = screen->w; 1084 + target->context->window_h = target->context->drawable_h = screen->h; 1084 1085 target->context->stored_window_w = target->context->window_w; 1085 1086 target->context->stored_window_h = target->context->window_h; 1086 1087 ··· 1090 1091 ((GPU_TARGET_DATA*)target->data)->format = GL_RGBA; 1091 1092 1092 1093 target->renderer = renderer; 1093 - target->w = target->context->window_w; 1094 - target->h = target->context->window_h; 1095 - target->base_w = target->context->window_w; 1096 - target->base_h = target->context->window_h; 1094 + target->w = target->context->drawable_w; 1095 + target->h = target->context->drawable_h; 1096 + target->base_w = target->context->drawable_w; 1097 + target->base_h = target->context->drawable_h; 1097 1098 1098 1099 target->use_clip_rect = 0; 1099 1100 target->clip_rect.x = 0; ··· 1102 1103 target->clip_rect.h = target->h; 1103 1104 target->use_color = 0; 1104 1105 1105 - target->viewport = GPU_MakeRect(0, 0, target->context->window_w, target->context->window_h); 1106 + target->viewport = GPU_MakeRect(0, 0, target->context->drawable_w, target->context->drawable_h); 1106 1107 target->camera = GPU_GetDefaultCamera(); 1107 1108 1108 1109 target->context->line_thickness = 1.0f; ··· 1443 1444 if(window != NULL) 1444 1445 { 1445 1446 SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h); 1446 - target->base_w = target->context->window_w; 1447 - target->base_h = target->context->window_h; 1447 + SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h); 1448 + target->base_w = target->context->drawable_w; 1449 + target->base_h = target->context->drawable_h; 1448 1450 } 1449 1451 1450 1452 // Reset the camera for this window ··· 1462 1464 screen = SDL_GetVideoSurface(); 1463 1465 if(screen != NULL) 1464 1466 { 1465 - target->context->window_w = screen->w; 1466 - target->context->window_h = screen->h; 1467 - target->base_w = target->context->window_w; 1468 - target->base_h = target->context->window_h; 1467 + target->context->window_w = target->context->drawable_w = screen->w; 1468 + target->context->window_h = target->context->drawable_h = screen->h; 1469 + target->base_w = target->context->drawable_w; 1470 + target->base_h = target->context->drawable_h; 1469 1471 } 1470 1472 #endif 1471 1473 } ··· 1539 1541 1540 1542 #ifdef SDL_GPU_USE_SDL2 1541 1543 1542 - // Don't need to resize (only update internals) when resolution isn't changing. 1543 - SDL_GetWindowSize(SDL_GetWindowFromID(target->context->windowID), &target->context->window_w, &target->context->window_h); 1544 - if(target->context->window_w != w || target->context->window_h != h) 1545 1544 { 1546 - SDL_SetWindowSize(SDL_GetWindowFromID(target->context->windowID), w, h); 1547 - SDL_GetWindowSize(SDL_GetWindowFromID(target->context->windowID), &target->context->window_w, &target->context->window_h); 1545 + SDL_Window* window = SDL_GetWindowFromID(target->context->windowID); 1546 + 1547 + // Don't need to resize (only update internals) when resolution isn't changing. 1548 + SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h); 1549 + SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h); 1550 + if(target->context->window_w != w || target->context->window_h != h) 1551 + { 1552 + SDL_SetWindowSize(window, w, h); 1553 + SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h); 1554 + SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h); 1555 + } 1548 1556 } 1549 1557 1550 1558 #else ··· 1563 1571 return 0; 1564 1572 } 1565 1573 1566 - target->context->window_w = screen->w; 1567 - target->context->window_h = screen->h; 1574 + target->context->window_w = target->context->drawable_w = screen->w; 1575 + target->context->window_h = target->context->drawable_h = screen->h; 1568 1576 1569 1577 // FIXME: Does the entire GL state need to be reset because the screen was recreated? 1570 1578 ··· 1583 1591 target->context->stored_window_h = target->context->window_h; 1584 1592 1585 1593 // Update base dimensions 1586 - target->base_w = target->context->window_w; 1587 - target->base_h = target->context->window_h; 1594 + target->base_w = target->context->drawable_w; 1595 + target->base_h = target->context->drawable_h; 1588 1596 1589 1597 // Resets virtual resolution 1590 1598 target->w = target->base_w; ··· 1655 1663 GPU_Target* target = renderer->current_context_target; 1656 1664 1657 1665 #ifdef SDL_GPU_USE_SDL2 1658 - Uint32 old_flags = SDL_GetWindowFlags(SDL_GetWindowFromID(target->context->windowID)); 1666 + SDL_Window* window = SDL_GetWindowFromID(target->context->windowID); 1667 + Uint32 old_flags = SDL_GetWindowFlags(window); 1659 1668 Uint8 was_fullscreen = (old_flags & SDL_WINDOW_FULLSCREEN); 1660 1669 Uint8 is_fullscreen = was_fullscreen; 1661 1670 ··· 1669 1678 flags = SDL_WINDOW_FULLSCREEN; 1670 1679 } 1671 1680 1672 - if(SDL_SetWindowFullscreen(SDL_GetWindowFromID(target->context->windowID), flags) >= 0) 1681 + if(SDL_SetWindowFullscreen(window, flags) >= 0) 1673 1682 { 1674 - flags = SDL_GetWindowFlags(SDL_GetWindowFromID(target->context->windowID)); 1683 + flags = SDL_GetWindowFlags(window); 1675 1684 is_fullscreen = (flags & SDL_WINDOW_FULLSCREEN); 1676 1685 1677 1686 // If we just went fullscreen, save the original resolution ··· 1685 1694 1686 1695 // If we're in windowed mode now and a resolution was stored, restore the original window resolution 1687 1696 if(was_fullscreen && !is_fullscreen && (target->context->stored_window_w != 0 && target->context->stored_window_h != 0)) 1688 - SDL_SetWindowSize(SDL_GetWindowFromID(target->context->windowID), target->context->stored_window_w, target->context->stored_window_h); 1697 + SDL_SetWindowSize(window, target->context->stored_window_w, target->context->stored_window_h); 1689 1698 1690 1699 // Update window dims 1691 - SDL_GetWindowSize(SDL_GetWindowFromID(target->context->windowID), &target->context->window_w, &target->context->window_h); 1700 + SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h); 1701 + SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h); 1692 1702 } 1693 1703 1694 1704 #else ··· 1702 1712 is_fullscreen = (surf->flags & SDL_FULLSCREEN); 1703 1713 1704 1714 // Update window dims 1705 - target->context->window_w = surf->w; 1706 - target->context->window_h = surf->h; 1715 + target->context->window_w = target->context->drawable_w = surf->w; 1716 + target->context->window_h = target->context->drawable_h = surf->h; 1707 1717 } 1708 1718 1709 1719 #endif ··· 1714 1724 if(!target->using_virtual_resolution) 1715 1725 { 1716 1726 // Update dims 1717 - target->w = target->context->window_w; 1718 - target->h = target->context->window_h; 1727 + target->w = target->context->drawable_w; 1728 + target->h = target->context->drawable_h; 1719 1729 } 1720 1730 1721 1731 // Reset viewport 1722 - target->viewport = GPU_MakeRect(0, 0, target->context->window_w, target->context->window_h); 1732 + target->viewport = GPU_MakeRect(0, 0, target->context->drawable_w, target->context->drawable_h); 1723 1733 changeViewport(target); 1724 1734 1725 1735 // Reset clip ··· 1730 1740 applyTargetCamera(target); 1731 1741 } 1732 1742 1733 - target->base_w = target->context->window_w; 1734 - target->base_h = target->context->window_h; 1743 + target->base_w = target->context->drawable_w; 1744 + target->base_h = target->context->drawable_h; 1735 1745 1736 1746 return is_fullscreen; 1737 1747 }