1 {
2  *  CVOpenGLBuffer.h
3  *  CoreVideo
4  *
5  *  Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
6  *
7  }
8 {  Pascal Translation:  Gorazd Krosl, <gorazd_1957@yahoo.ca>, 2009 }
9 {  Pascal Translation Update: Jonas Maebe <jonas@freepascal.org>, October 2012 }
10 {  Pascal Translation Update: Jonas Maebe <jonas@freepascal.org>, August 2015 }
11 {
12     Modified for use with Free Pascal
13     Version 308
14     Please report any bugs to <gpc@microbizz.nl>
15 }
16 
17 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
18 {$mode macpas}
19 {$modeswitch cblocks}
20 {$packenum 1}
21 {$macro on}
22 {$inline on}
23 {$calling mwpascal}
24 
25 unit CVOpenGLBuffer;
26 interface
27 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
28 {$setc GAP_INTERFACES_VERSION := $0308}
29 
30 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
31     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
32 {$endc}
33 
34 {$ifc defined CPUPOWERPC and defined CPUI386}
35 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
36 {$endc}
37 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
38 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
39 {$endc}
40 
41 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
42 	{$setc __ppc__ := 1}
43 {$elsec}
44 	{$setc __ppc__ := 0}
45 {$endc}
46 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
47 	{$setc __ppc64__ := 1}
48 {$elsec}
49 	{$setc __ppc64__ := 0}
50 {$endc}
51 {$ifc not defined __i386__ and defined CPUI386}
52 	{$setc __i386__ := 1}
53 {$elsec}
54 	{$setc __i386__ := 0}
55 {$endc}
56 {$ifc not defined __x86_64__ and defined CPUX86_64}
57 	{$setc __x86_64__ := 1}
58 {$elsec}
59 	{$setc __x86_64__ := 0}
60 {$endc}
61 {$ifc not defined __arm__ and defined CPUARM}
62 	{$setc __arm__ := 1}
63 {$elsec}
64 	{$setc __arm__ := 0}
65 {$endc}
66 {$ifc not defined __arm64__ and defined CPUAARCH64}
67   {$setc __arm64__ := 1}
68 {$elsec}
69   {$setc __arm64__ := 0}
70 {$endc}
71 
72 {$ifc defined cpu64}
73   {$setc __LP64__ := 1}
74 {$elsec}
75   {$setc __LP64__ := 0}
76 {$endc}
77 
78 
79 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
80 	{$error Conflicting definitions for __ppc__ and __i386__}
81 {$endc}
82 
83 {$ifc defined __ppc__ and __ppc__}
84 	{$setc TARGET_CPU_PPC := TRUE}
85 	{$setc TARGET_CPU_PPC64 := FALSE}
86 	{$setc TARGET_CPU_X86 := FALSE}
87 	{$setc TARGET_CPU_X86_64 := FALSE}
88 	{$setc TARGET_CPU_ARM := FALSE}
89 	{$setc TARGET_CPU_ARM64 := FALSE}
90 	{$setc TARGET_OS_MAC := TRUE}
91 	{$setc TARGET_OS_IPHONE := FALSE}
92 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
93 	{$setc TARGET_OS_EMBEDDED := FALSE}
94 {$elifc defined __ppc64__ and __ppc64__}
95 	{$setc TARGET_CPU_PPC := FALSE}
96 	{$setc TARGET_CPU_PPC64 := TRUE}
97 	{$setc TARGET_CPU_X86 := FALSE}
98 	{$setc TARGET_CPU_X86_64 := FALSE}
99 	{$setc TARGET_CPU_ARM := FALSE}
100 	{$setc TARGET_CPU_ARM64 := FALSE}
101 	{$setc TARGET_OS_MAC := TRUE}
102 	{$setc TARGET_OS_IPHONE := FALSE}
103 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
104 	{$setc TARGET_OS_EMBEDDED := FALSE}
105 {$elifc defined __i386__ and __i386__}
106 	{$setc TARGET_CPU_PPC := FALSE}
107 	{$setc TARGET_CPU_PPC64 := FALSE}
108 	{$setc TARGET_CPU_X86 := TRUE}
109 	{$setc TARGET_CPU_X86_64 := FALSE}
110 	{$setc TARGET_CPU_ARM := FALSE}
111 	{$setc TARGET_CPU_ARM64 := FALSE}
112 {$ifc defined iphonesim}
113  	{$setc TARGET_OS_MAC := FALSE}
114 	{$setc TARGET_OS_IPHONE := TRUE}
115 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
116 {$elsec}
117 	{$setc TARGET_OS_MAC := TRUE}
118 	{$setc TARGET_OS_IPHONE := FALSE}
119 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
120 {$endc}
121 	{$setc TARGET_OS_EMBEDDED := FALSE}
122 {$elifc defined __x86_64__ and __x86_64__}
123 	{$setc TARGET_CPU_PPC := FALSE}
124 	{$setc TARGET_CPU_PPC64 := FALSE}
125 	{$setc TARGET_CPU_X86 := FALSE}
126 	{$setc TARGET_CPU_X86_64 := TRUE}
127 	{$setc TARGET_CPU_ARM := FALSE}
128 	{$setc TARGET_CPU_ARM64 := FALSE}
129 {$ifc defined iphonesim}
130  	{$setc TARGET_OS_MAC := FALSE}
131 	{$setc TARGET_OS_IPHONE := TRUE}
132 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
133 {$elsec}
134 	{$setc TARGET_OS_MAC := TRUE}
135 	{$setc TARGET_OS_IPHONE := FALSE}
136 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
137 {$endc}
138 	{$setc TARGET_OS_EMBEDDED := FALSE}
139 {$elifc defined __arm__ and __arm__}
140 	{$setc TARGET_CPU_PPC := FALSE}
141 	{$setc TARGET_CPU_PPC64 := FALSE}
142 	{$setc TARGET_CPU_X86 := FALSE}
143 	{$setc TARGET_CPU_X86_64 := FALSE}
144 	{$setc TARGET_CPU_ARM := TRUE}
145 	{$setc TARGET_CPU_ARM64 := FALSE}
146 	{$setc TARGET_OS_MAC := FALSE}
147 	{$setc TARGET_OS_IPHONE := TRUE}
148 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
149 	{$setc TARGET_OS_EMBEDDED := TRUE}
150 {$elifc defined __arm64__ and __arm64__}
151 	{$setc TARGET_CPU_PPC := FALSE}
152 	{$setc TARGET_CPU_PPC64 := FALSE}
153 	{$setc TARGET_CPU_X86 := FALSE}
154 	{$setc TARGET_CPU_X86_64 := FALSE}
155 	{$setc TARGET_CPU_ARM := FALSE}
156 	{$setc TARGET_CPU_ARM64 := TRUE}
157 {$ifc defined ios}
158 	{$setc TARGET_OS_MAC := FALSE}
159 	{$setc TARGET_OS_IPHONE := TRUE}
160 	{$setc TARGET_OS_EMBEDDED := TRUE}
161 {$elsec}
162 	{$setc TARGET_OS_MAC := TRUE}
163 	{$setc TARGET_OS_IPHONE := FALSE}
164 	{$setc TARGET_OS_EMBEDDED := FALSE}
165 {$endc}
166 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
167 {$elsec}
168 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
169 {$endc}
170 
171 {$ifc defined __LP64__ and __LP64__ }
172   {$setc TARGET_CPU_64 := TRUE}
173 {$elsec}
174   {$setc TARGET_CPU_64 := FALSE}
175 {$endc}
176 
177 {$ifc defined FPC_BIG_ENDIAN}
178 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
179 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
180 {$elifc defined FPC_LITTLE_ENDIAN}
181 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
182 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
183 {$elsec}
184 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
185 {$endc}
186 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
187 {$setc CALL_NOT_IN_CARBON := FALSE}
188 {$setc OLDROUTINENAMES := FALSE}
189 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
190 {$setc OPAQUE_UPP_TYPES := TRUE}
191 {$setc OTCARBONAPPLICATION := TRUE}
192 {$setc OTKERNEL := FALSE}
193 {$setc PM_USE_SESSION_APIS := TRUE}
194 {$setc TARGET_API_MAC_CARBON := TRUE}
195 {$setc TARGET_API_MAC_OS8 := FALSE}
196 {$setc TARGET_API_MAC_OSX := TRUE}
197 {$setc TARGET_CARBON := TRUE}
198 {$setc TARGET_CPU_68K := FALSE}
199 {$setc TARGET_CPU_MIPS := FALSE}
200 {$setc TARGET_CPU_SPARC := FALSE}
201 {$setc TARGET_OS_UNIX := FALSE}
202 {$setc TARGET_OS_WIN32 := FALSE}
203 {$setc TARGET_RT_MAC_68881 := FALSE}
204 {$setc TARGET_RT_MAC_CFM := FALSE}
205 {$setc TARGET_RT_MAC_MACHO := TRUE}
206 {$setc TYPED_FUNCTION_POINTERS := TRUE}
207 {$setc TYPE_BOOL := FALSE}
208 {$setc TYPE_EXTENDED := FALSE}
209 {$setc TYPE_LONGLONG := TRUE}
210 uses MacTypes,CFBase,CFString,CFDictionary,CVReturns,CVImageBuffer,CGLTypes,macgl;
211 {$endc} {not MACOSALLINCLUDE}
212 
213 
214 {$ifc TARGET_OS_MAC}
215 
216 {$ALIGN POWER}
217 
218  {! @header CVOpenGLBuffer.h
219 	@copyright 2004 Apple Computer, Inc. All rights reserved.
220 	@availability Mac OS X 10.4 or later
221     @discussion A CoreVideo buffer derives from a generic buffer and can be an ImageBuffer or PixelBuffer.
222 
223 }
224 
225 
226 var kCVOpenGLBufferWidth: CFStringRef; external name '_kCVOpenGLBufferWidth'; (* attribute const *)
227 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
228 var kCVOpenGLBufferHeight: CFStringRef; external name '_kCVOpenGLBufferHeight'; (* attribute const *)
229 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
230 var kCVOpenGLBufferTarget: CFStringRef; external name '_kCVOpenGLBufferTarget'; (* attribute const *)
231 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
232 var kCVOpenGLBufferInternalFormat: CFStringRef; external name '_kCVOpenGLBufferInternalFormat'; (* attribute const *)
233 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
234 var kCVOpenGLBufferMaximumMipmapLevel: CFStringRef; external name '_kCVOpenGLBufferMaximumMipmapLevel'; (* attribute const *)
235 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
236 
237 type
238 	CVOpenGLBufferRef = CVImageBufferRef;
239 
CVOpenGLBufferGetTypeIDnull240 function CVOpenGLBufferGetTypeID: CFTypeID; external name '_CVOpenGLBufferGetTypeID';
241 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
242 
243 {!
244     @function   CVOpenGLBufferRetain
245     @abstract   Retains a CVOpenGLBuffer object
246     @discussion Equivalent to CFRetain, but NULL safe
247     @param      buffer A CVOpenGLBuffer object that you want to retain.
248     @result     A CVOpenGLBuffer object that is the same as the passed in buffer.
249 }
CVOpenGLBufferRetainnull250 function CVOpenGLBufferRetain( buffer: CVOpenGLBufferRef ): CVOpenGLBufferRef; external name '_CVOpenGLBufferRetain';
251 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
252 
253 {!
254     @function   CVOpenGLBufferRelease
255     @abstract   Releases a CVOpenGLBuffer object
256     @discussion Equivalent to CFRelease, but NULL safe
257     @param      buffer A CVOpenGLBuffer object that you want to release.
258 }
259 procedure CVOpenGLBufferRelease( buffer: CVOpenGLBufferRef ); external name '_CVOpenGLBufferRelease';
260 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
261 
262 {!
263     @function   CVOpenGLBufferCreate
264     @abstract   Create a new CVOpenGLBuffer that may be used for OpenGL rendering purposes
265     @param      width The width of the buffer in pixels
266     @param      height The height of the buffer in pixels
267     @param      attributes A CFDictionaryRef containing other desired attributes of the buffer (texture target, internal format, max mipmap level, etc.).
268 		May be NULL.  Defaults are GL_TEXTURE_RECTANGLE_EXT, GL_RGBA, and 0 for kCVOpenGLBufferTarget, kCVOpenGLBufferInternalFormat and kCVOpenGLBufferMaximumMipmapLevel,
269 		respectively.
270     @param      bufferOut    The newly created buffer will be placed here.
271     @result     kCVReturnSuccess if the attachment succeeded
272 }
CVOpenGLBufferCreatenull273 function CVOpenGLBufferCreate( allocator: CFAllocatorRef; width: size_t; height: size_t; attributes: CFDictionaryRef; var bufferOut: CVOpenGLBufferRef ): CVReturn; external name '_CVOpenGLBufferCreate';
274 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
275 
276 {!
277     @function   CVOpenGLBufferGetAttributes
278     @param      openGLBuffer Target OpenGL Buffer.
279     @result     CVOpenGLBuffer attributes dictionary, NULL if not set.
280 }
CVOpenGLBufferGetAttributesnull281 function CVOpenGLBufferGetAttributes( openGLBuffer: CVOpenGLBufferRef ): CFDictionaryRef; external name '_CVOpenGLBufferGetAttributes';
282 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
283 
284 {!
285     @function   CVOpenGLBufferAttach
286     @param      openGLBuffer The buffer you wish to attach a GL context to
287     @param      cglContext   The CGLContextObj you wish to attach
288     @param      face	     The target GL face enum (0 for non cube maps)
289     @param      level        The mipmap level index you wish to attach to
290     @param      screen       The virtual screen number you want to use
291     @result     kCVReturnSuccess if the attachment succeeded
292 }
CVOpenGLBufferAttachnull293 function CVOpenGLBufferAttach( openGLBuffer: CVOpenGLBufferRef; cglContext: CGLContextObj; face: GLenum; level: GLint; screen: GLint ): CVReturn; external name '_CVOpenGLBufferAttach';
294 (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
295 
296 {$endc}	// TARGET_OS_MAC
297 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
298 
299 end.
300 {$endc} {not MACOSALLINCLUDE}
301