MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / R_render

Function R_render

engine/src/game.cpp:1728–1970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1726}
1727
1728void R_render()
1729{
1730 // Update window size if needed
1731 int windowWidth, windowHeight;
1732 SDL_GetWindowSize(window.window, &windowWidth, &windowHeight);
1733 if (windowWidth != game.clientRect.w || windowHeight != game.clientRect.h)
1734 {
1735 game.clientRect.w = windowWidth;
1736 game.clientRect.h = windowHeight;
1737 game.aspectRatio = (float)windowWidth / windowHeight;
1738 R_resize(windowWidth, windowHeight);
1739 }
1740
1741 glGetUniformLocation(NULL, NULL);
1742
1743 if (!bdrawbglayer05)
1744 game.renderTargets.scene.Clear(0.75f, 0.56f, 0.46f, 1.0f);
1745 else
1746 game.renderTargets.scene.Clear(0.0f, 0.0f, 0.0f, 0.0f);
1747
1748 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
1749 glEnable(GL_TEXTURE_2D);
1750 glEnable(GL_BLEND);
1751
1752 float screen_width;
1753 float screen_height;
1754 float targetAspectRatio = _16x9;
1755 float width;
1756 float height;
1757 ScreenRect boxRect;
1758
1759 if (bsnapscale && bfixedaspect)
1760 {
1761 screen_width = window.virtualModes[window.scaleMode].width;
1762 screen_height = window.virtualModes[window.scaleMode].height;
1763 }
1764 else if (bfixedaspect)
1765 {
1766 screen_width = window.currentWidth();
1767 screen_height = window.currentHeight();
1768 }
1769
1770 width = screen_width;
1771 height = (width / targetAspectRatio);
1772
1773 if (bfixedaspect)
1774 {
1775 if (height > screen_height)
1776 {
1777 height = screen_height;
1778 width = (height * targetAspectRatio);
1779 }
1780 float boxwidth = 2 * (width / game.clientRect.w);
1781 float boxheight = 2 * (height / game.clientRect.h);
1782
1783 boxRect = ScreenRect(-1 + (1 - boxwidth * 0.5f),
1784 -1 + (1 - boxheight * 0.5f), boxwidth, boxheight);
1785 }

Callers 1

P_runFunction · 0.85

Calls 15

R_resizeFunction · 0.85
ScreenRectClass · 0.85
R_setPPOrthoMatrixFunction · 0.85
R_drawSkyFunction · 0.85
DrawFullscreenQuadFunction · 0.85
DrawQuadDFunction · 0.85
R_drawWorldDebugFunction · 0.85
R_drawSceneLightsFunction · 0.85
DrawFullscreenQuadSFunction · 0.85
R_setMenuOrthoMatrixFunction · 0.85
R_drawMenusFunction · 0.85
R_setClientOrthoMatrixFunction · 0.85

Tested by

no test coverage detected