forked from FMXExpress/ios-object-pascal-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiOSapi.OpenGLES.pas
167 lines (128 loc) · 4.24 KB
/
iOSapi.OpenGLES.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework OpenGLES
//
unit iOSapi.OpenGLES;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.CocoaTypes,
iOSapi.Foundation;
const
kEAGLRenderingAPIOpenGLES1 = 1;
kEAGLRenderingAPIOpenGLES2 = 2;
kEAGLRenderingAPIOpenGLES3 = 3;
type
// ===== Forward declarations =====
{$M+}
EAGLSharegroup = interface;
EAGLContext = interface;
EAGLDrawable = interface;
// ===== Framework typedefs =====
{$M+}
NSUInteger = Cardinal;
EAGLRenderingAPI = NSUInteger;
// ===== Interface declarations =====
EAGLSharegroupClass = interface(NSObjectClass)
['{A2BA2BEB-8D0C-4527-9F19-2B34A087A543}']
end;
EAGLSharegroup = interface(NSObject)
['{29DF543A-A1D8-4D64-8ACF-D3D09E20C05E}']
procedure setDebugLabel(debugLabel: NSString); cdecl;
function debugLabel: NSString; cdecl;
end;
TEAGLSharegroup = class(TOCGenericImport<EAGLSharegroupClass, EAGLSharegroup>)
end;
PEAGLSharegroup = Pointer;
EAGLContextClass = interface(NSObjectClass)
['{8832DC09-F4C2-4AEA-B08D-330DD1276AF2}']
{ class } function setCurrentContext(context: EAGLContext): Boolean; cdecl;
{ class } function currentContext: EAGLContext; cdecl;
end;
EAGLContext = interface(NSObject)
['{AE2917EF-2CBD-4139-A55C-4D9E1FFE9C79}']
[MethodName('initWithAPI:')]
function initWithAPI(api: EAGLRenderingAPI)
: Pointer { instancetype }; cdecl;
[MethodName('initWithAPI:sharegroup:')]
function initWithAPISharegroup(api: EAGLRenderingAPI;
sharegroup: EAGLSharegroup): Pointer { instancetype }; cdecl;
function api: EAGLRenderingAPI; cdecl;
function sharegroup: EAGLSharegroup; cdecl;
procedure setDebugLabel(debugLabel: NSString); cdecl;
function debugLabel: NSString; cdecl;
procedure setMultiThreaded(multiThreaded: Boolean); cdecl;
function isMultiThreaded: Boolean; cdecl;
function renderbufferStorage(target: NSUInteger; fromDrawable: Pointer)
: Boolean; cdecl;
function presentRenderbuffer(target: NSUInteger): Boolean; cdecl;
end;
TEAGLContext = class(TOCGenericImport<EAGLContextClass, EAGLContext>)
end;
PEAGLContext = Pointer;
// ===== Protocol declarations =====
EAGLDrawable = interface(IObjectiveC)
['{57C3E850-9DA3-4F45-9A64-C9F10406391A}']
procedure setDrawableProperties(drawableProperties: NSDictionary); cdecl;
function drawableProperties: NSDictionary; cdecl;
end;
// ===== Exported string consts =====
function kEAGLDrawablePropertyRetainedBacking: NSString;
function kEAGLDrawablePropertyColorFormat: NSString;
function kEAGLColorFormatRGBA8: NSString;
function kEAGLColorFormatRGB565: NSString;
function kEAGLColorFormatSRGBA8: NSString;
// ===== External functions =====
const
libOpenGLES = '/System/Library/Frameworks/OpenGLES.framework/OpenGLES';
procedure EAGLGetVersion(major: PCardinal; minor: PCardinal); cdecl;
external libOpenGLES name _PU + 'EAGLGetVersion';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
OpenGLESModule: THandle;
{$ENDIF IOS}
function kEAGLDrawablePropertyRetainedBacking: NSString;
begin
Result := CocoaNSStringConst(libOpenGLES,
'kEAGLDrawablePropertyRetainedBacking');
end;
function kEAGLDrawablePropertyColorFormat: NSString;
begin
Result := CocoaNSStringConst(libOpenGLES, 'kEAGLDrawablePropertyColorFormat');
end;
function kEAGLColorFormatRGBA8: NSString;
begin
Result := CocoaNSStringConst(libOpenGLES, 'kEAGLColorFormatRGBA8');
end;
function kEAGLColorFormatRGB565: NSString;
begin
Result := CocoaNSStringConst(libOpenGLES, 'kEAGLColorFormatRGB565');
end;
function kEAGLColorFormatSRGBA8: NSString;
begin
Result := CocoaNSStringConst(libOpenGLES, 'kEAGLColorFormatSRGBA8');
end;
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
OpenGLESModule := dlopen(MarshaledAString(libOpenGLES), RTLD_LAZY);
finalization
dlclose(OpenGLESModule);
{$ENDIF IOS}
end.