Debian Codegraph @

src/window/windows/castlewindow_wgl.inc

raw
1 {%MainUnit ../castlewindow.pas}
2 {
3 Copyright 2013-2023 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 { Use this from castlewindow_winapi.inc to make a CastleWindow backend
18 using WinAPI and wgl. Initializes window on Windows with OpenGL context.
19
20 At this point this is a thin wrapper that uses CastleInternalContextWgl
21 to do the actual job. }
22
23 {$ifdef read_interface_uses}
24 CastleInternalContextWgl,
25 {$endif}
26
27 {$ifdef read_window_interface}
28 private
29 Context: TGLContextWGL;
30
31 { Methods compatible with castlewindow_egl.inc.
32 @groupBegin }
33 procedure ContextCreate(WndPtr: HWND);
34 procedure ContextDestroy;
35 { @groupEnd }
36 {$endif}
37
38 {$ifdef read_implementation}
39
40 procedure TCastleWindow.ContextCreate(WndPtr: HWND);
41 begin
42 Context := TGLContextWGL.Create;
43 Context.WndPtr := WndPtr;
44 Context.h_Dc := h_Dc;
45 Context.Initialize(FRequirements);
46 end;
47
48 procedure TCastleWindow.ContextDestroy;
49 begin
50 if Context <> nil then
51 begin
52 Context.Finalize;
53 FreeAndNil(Context);
54 end;
55 end;
56
57 procedure TCastleWindow.BackendMakeCurrent;
58 begin
59 Assert(not Closed);
60 Assert(Context <> nil);
61 Context.MakeCurrent;
62 end;
63
64 procedure TCastleWindow.SwapBuffers;
65 begin
66 Assert(not Closed);
67 Assert(Context <> nil);
68 Context.SwapBuffers;
69 end;
70
71 {$endif read_implementation}