Debian Codegraph @

src/window/castlewindow_egl.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 to make a CastleWindow backend using EGL
18 (initialize window with OpenGL ES context). }
19
20 {$ifdef read_interface_uses}
21 CastleInternalEgl, CastleInternalContextEgl,
22 {$endif}
23
24 {$ifdef read_window_interface}
25 private
26 Context: TGLContextEgl;
27 procedure ContextCreate(WndPtr: EGLNativeWindowType);
28 procedure ContextDestroy;
29 public
30 { Query the EGL context what is current size. }
31 procedure QuerySize(out AWidth, AHeight: EGLint);
32 {$endif}
33
34 {$ifdef read_implementation}
35
36 procedure TCastleWindow.ContextCreate(WndPtr: EGLNativeWindowType);
37 begin
38 Context := TGLContextEgl.Create;
39 Context.WndPtr := WndPtr;
40 Context.Initialize(FRequirements);
41 end;
42
43 procedure TCastleWindow.ContextDestroy;
44 begin
45 if Context <> nil then
46 begin
47 Context.Finalize;
48 FreeAndNil(Context);
49 end;
50 end;
51
52 procedure TCastleWindow.BackendMakeCurrent;
53 begin
54 Assert(not Closed);
55 Assert(Context <> nil);
56 Context.MakeCurrent;
57 end;
58
59 procedure TCastleWindow.SwapBuffers;
60 begin
61 Assert(not Closed);
62 Assert(Context <> nil);
63 Context.SwapBuffers;
64 end;
65
66 procedure TCastleWindow.QuerySize(out AWidth, AHeight: EGLint);
67 begin
68 if Context <> nil then
69 Context.QuerySize(AWidth, AHeight) else
70 begin
71 AWidth := 0;
72 AHeight := 0;
73 end;
74 end;
75
76 {$endif read_implementation}