1 (* Copyright (C) Doom 2D: Forever Developers
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.
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.
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/>.
15 {$INCLUDE ../../shared/a_modes.inc}
20 procedure r_Render_Initialize
;
21 procedure r_Render_Finalize
;
22 procedure r_Render_Resize (w
, h
: Integer);
24 procedure r_Render_Apply
;
29 {$INCLUDE ../../nogl/noGLuses.inc}
30 SysUtils
, Classes
, Math
,
32 g_game
, g_options
, g_console
,
33 r_window
, r_graphics
, r_console
, r_playermodel
37 LoadedGL
: Boolean = false;
41 if LoadedGL
= false then
45 if glRenderToFBO
and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then
47 e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
48 glRenderToFBO
:= false
51 if glRenderToFBO
and (not Load_GL_ARB_framebuffer_object
) then
53 e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
54 glRenderToFBO
:= false
63 if LoadedGL
= true then
72 procedure r_Render_Initialize
;
74 if sys_SetDisplayMode(gRC_Width
, gRC_Height
, gBPP
, gRC_FullScreen
, gRC_Maximized
) = False then
75 raise Exception
.Create('Failed to set videomode on startup.');
79 r_PlayerModel_Initialize
;
82 procedure r_Render_Finalize
;
85 r_PlayerModel_Finalize
;
89 procedure r_Render_Resize (w
, h
: Integer);
98 // store real window size in gWinSize, downscale resolution now
99 w
:= round(w
/ r_pixel_scale
);
100 h
:= round(h
/ r_pixel_scale
);
101 if not e_ResizeFramebuffer(w
, h
) then
103 e_LogWriteln('GL: could not create framebuffer, falling back to --no-fbo');
104 glRenderToFBO
:= False;
111 e_ResizeWindow(w
, h
);
115 procedure r_Render_Apply
;
117 if sys_SetDisplayMode(Max(1, gRC_Width
), Max(1, gRC_Height
), Max(1, gBPP
), gRC_FullScreen
, gRC_Maximized
) then
118 e_LogWriteln('resolution changed')
120 e_LogWriteln('resolution not changed');
121 sys_EnableVSync(gVSync
)