DEADSOFTWARE

render: move screen resize handler from io-driver
[d2df-sdl.git] / src / game / opengl / r_render.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../../shared/a_modes.inc}
16 unit r_render;
18 interface
20 procedure r_Render_Initialize;
21 procedure r_Render_Finalize;
22 procedure r_Render_Resize (w, h: Integer);
24 implementation
26 uses SysUtils, Classes, e_log, g_system, g_game, g_options, r_window, r_graphics, r_console, r_playermodel;
28 procedure r_Render_Initialize;
29 begin
30 if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
31 raise Exception.Create('Failed to set videomode on startup.');
33 r_Window_Initialize;
34 r_Console_Init;
35 r_PlayerModel_Initialize;
36 end;
38 procedure r_Render_Finalize;
39 begin
40 r_PlayerModel_Finalize;
41 e_ReleaseEngine
42 end;
44 procedure r_Render_Resize (w, h: Integer);
45 begin
46 gWinSizeX := w;
47 gWinSizeY := h;
48 gRC_Width := w;
49 gRC_Height := h;
50 if glRenderToFBO then
51 begin
52 // store real window size in gWinSize, downscale resolution now
53 w := round(w / r_pixel_scale);
54 h := round(h / r_pixel_scale);
55 if not e_ResizeFramebuffer(w, h) then
56 begin
57 e_LogWriteln('GL: could not create framebuffer, falling back to --no-fbo');
58 glRenderToFBO := False;
59 w := gWinSizeX;
60 h := gWinSizeY;
61 end;
62 end;
63 gScreenWidth := w;
64 gScreenHeight := h;
65 e_ResizeWindow(w, h);
66 e_InitGL
67 end;
69 end.