/packages/univint/src/CVOpenGLBufferPool.pas
Pascal | 275 lines | 16 code | 28 blank | 231 comment | 0 complexity | a088c314551bb22ce544ecf756618ba4 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
1{ 2 * CVOpenGLBufferPool.h 3 * CoreVideo 4 * 5 * Copyright 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{ 11 Modified for use with Free Pascal 12 Version 308 13 Please report any bugs to <gpc@microbizz.nl> 14} 15 16{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 17{$mode macpas} 18{$packenum 1} 19{$macro on} 20{$inline on} 21{$calling mwpascal} 22 23unit CVOpenGLBufferPool; 24interface 25{$setc UNIVERSAL_INTERFACES_VERSION := $0400} 26{$setc GAP_INTERFACES_VERSION := $0308} 27 28{$ifc not defined USE_CFSTR_CONSTANT_MACROS} 29 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE} 30{$endc} 31 32{$ifc defined CPUPOWERPC and defined CPUI386} 33 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386} 34{$endc} 35{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN} 36 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN} 37{$endc} 38 39{$ifc not defined __ppc__ and defined CPUPOWERPC32} 40 {$setc __ppc__ := 1} 41{$elsec} 42 {$setc __ppc__ := 0} 43{$endc} 44{$ifc not defined __ppc64__ and defined CPUPOWERPC64} 45 {$setc __ppc64__ := 1} 46{$elsec} 47 {$setc __ppc64__ := 0} 48{$endc} 49{$ifc not defined __i386__ and defined CPUI386} 50 {$setc __i386__ := 1} 51{$elsec} 52 {$setc __i386__ := 0} 53{$endc} 54{$ifc not defined __x86_64__ and defined CPUX86_64} 55 {$setc __x86_64__ := 1} 56{$elsec} 57 {$setc __x86_64__ := 0} 58{$endc} 59{$ifc not defined __arm__ and defined CPUARM} 60 {$setc __arm__ := 1} 61{$elsec} 62 {$setc __arm__ := 0} 63{$endc} 64 65{$ifc defined cpu64} 66 {$setc __LP64__ := 1} 67{$elsec} 68 {$setc __LP64__ := 0} 69{$endc} 70 71 72{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__} 73 {$error Conflicting definitions for __ppc__ and __i386__} 74{$endc} 75 76{$ifc defined __ppc__ and __ppc__} 77 {$setc TARGET_CPU_PPC := TRUE} 78 {$setc TARGET_CPU_PPC64 := FALSE} 79 {$setc TARGET_CPU_X86 := FALSE} 80 {$setc TARGET_CPU_X86_64 := FALSE} 81 {$setc TARGET_CPU_ARM := FALSE} 82 {$setc TARGET_OS_MAC := TRUE} 83 {$setc TARGET_OS_IPHONE := FALSE} 84 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 85 {$setc TARGET_OS_EMBEDDED := FALSE} 86{$elifc defined __ppc64__ and __ppc64__} 87 {$setc TARGET_CPU_PPC := FALSE} 88 {$setc TARGET_CPU_PPC64 := TRUE} 89 {$setc TARGET_CPU_X86 := FALSE} 90 {$setc TARGET_CPU_X86_64 := FALSE} 91 {$setc TARGET_CPU_ARM := FALSE} 92 {$setc TARGET_OS_MAC := TRUE} 93 {$setc TARGET_OS_IPHONE := FALSE} 94 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 95 {$setc TARGET_OS_EMBEDDED := FALSE} 96{$elifc defined __i386__ and __i386__} 97 {$setc TARGET_CPU_PPC := FALSE} 98 {$setc TARGET_CPU_PPC64 := FALSE} 99 {$setc TARGET_CPU_X86 := TRUE} 100 {$setc TARGET_CPU_X86_64 := FALSE} 101 {$setc TARGET_CPU_ARM := FALSE} 102{$ifc defined(iphonesim)} 103 {$setc TARGET_OS_MAC := FALSE} 104 {$setc TARGET_OS_IPHONE := TRUE} 105 {$setc TARGET_IPHONE_SIMULATOR := TRUE} 106{$elsec} 107 {$setc TARGET_OS_MAC := TRUE} 108 {$setc TARGET_OS_IPHONE := FALSE} 109 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 110{$endc} 111 {$setc TARGET_OS_EMBEDDED := FALSE} 112{$elifc defined __x86_64__ and __x86_64__} 113 {$setc TARGET_CPU_PPC := FALSE} 114 {$setc TARGET_CPU_PPC64 := FALSE} 115 {$setc TARGET_CPU_X86 := FALSE} 116 {$setc TARGET_CPU_X86_64 := TRUE} 117 {$setc TARGET_CPU_ARM := FALSE} 118 {$setc TARGET_OS_MAC := TRUE} 119 {$setc TARGET_OS_IPHONE := FALSE} 120 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 121 {$setc TARGET_OS_EMBEDDED := FALSE} 122{$elifc defined __arm__ and __arm__} 123 {$setc TARGET_CPU_PPC := FALSE} 124 {$setc TARGET_CPU_PPC64 := FALSE} 125 {$setc TARGET_CPU_X86 := FALSE} 126 {$setc TARGET_CPU_X86_64 := FALSE} 127 {$setc TARGET_CPU_ARM := TRUE} 128 { will require compiler define when/if other Apple devices with ARM cpus ship } 129 {$setc TARGET_OS_MAC := FALSE} 130 {$setc TARGET_OS_IPHONE := TRUE} 131 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 132 {$setc TARGET_OS_EMBEDDED := TRUE} 133{$elsec} 134 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.} 135{$endc} 136 137{$ifc defined __LP64__ and __LP64__ } 138 {$setc TARGET_CPU_64 := TRUE} 139{$elsec} 140 {$setc TARGET_CPU_64 := FALSE} 141{$endc} 142 143{$ifc defined FPC_BIG_ENDIAN} 144 {$setc TARGET_RT_BIG_ENDIAN := TRUE} 145 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE} 146{$elifc defined FPC_LITTLE_ENDIAN} 147 {$setc TARGET_RT_BIG_ENDIAN := FALSE} 148 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE} 149{$elsec} 150 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.} 151{$endc} 152{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE} 153{$setc CALL_NOT_IN_CARBON := FALSE} 154{$setc OLDROUTINENAMES := FALSE} 155{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE} 156{$setc OPAQUE_UPP_TYPES := TRUE} 157{$setc OTCARBONAPPLICATION := TRUE} 158{$setc OTKERNEL := FALSE} 159{$setc PM_USE_SESSION_APIS := TRUE} 160{$setc TARGET_API_MAC_CARBON := TRUE} 161{$setc TARGET_API_MAC_OS8 := FALSE} 162{$setc TARGET_API_MAC_OSX := TRUE} 163{$setc TARGET_CARBON := TRUE} 164{$setc TARGET_CPU_68K := FALSE} 165{$setc TARGET_CPU_MIPS := FALSE} 166{$setc TARGET_CPU_SPARC := FALSE} 167{$setc TARGET_OS_UNIX := FALSE} 168{$setc TARGET_OS_WIN32 := FALSE} 169{$setc TARGET_RT_MAC_68881 := FALSE} 170{$setc TARGET_RT_MAC_CFM := FALSE} 171{$setc TARGET_RT_MAC_MACHO := TRUE} 172{$setc TYPED_FUNCTION_POINTERS := TRUE} 173{$setc TYPE_BOOL := FALSE} 174{$setc TYPE_EXTENDED := FALSE} 175{$setc TYPE_LONGLONG := TRUE} 176uses MacTypes,CFBase,CFString,CFDictionary,CVBase,CVReturns,CVOpenGLBuffer; 177{$endc} {not MACOSALLINCLUDE} 178 179 180{$ifc TARGET_OS_MAC} 181 182{$ALIGN POWER} 183 184 {! @header CVOpenGLBufferPool.h 185 @copyright 2004 Apple Computer, Inc. All rights reserved. 186 @availability Mac OS X 10.4 or later 187 @discussion CVOpenGLBufferPool is a utility object for managing a set of CVOpenGLBuffer objects that are going to be recycled. 188 189} 190 191 192type 193 CVOpenGLBufferPoolRef = ^__CVOpenGLBufferPool; { an opaque type } 194 __CVOpenGLBufferPool = record end; 195 196var kCVOpenGLBufferPoolMinimumBufferCountKey: CFStringRef; external name '_kCVOpenGLBufferPoolMinimumBufferCountKey'; (* attribute const *) 197(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 198 199// By default, buffers will age out after one second. If required, setting an age of zero will disable 200// the age-out mechanism completely. 201var kCVOpenGLBufferPoolMaximumBufferAgeKey: CFStringRef; external name '_kCVOpenGLBufferPoolMaximumBufferAgeKey'; (* attribute const *) 202(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 203 204function CVOpenGLBufferPoolGetTypeID: CFTypeID; external name '_CVOpenGLBufferPoolGetTypeID'; 205(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 206 207{! 208 @function CVOpenGLBufferPoolRetain 209 @abstract Retains a CVOpenGLBufferPoolRef object 210 @discussion Equivalent to CFRetain, but NULL safe 211 @param buffer A CVOpenGLBufferPoolRef object that you want to retain. 212 @result A CVOpenGLBufferPoolRef object that is the same as the passed in buffer. 213} 214function CVOpenGLBufferPoolRetain( openGLBufferPool: CVOpenGLBufferPoolRef ): CVOpenGLBufferPoolRef; external name '_CVOpenGLBufferPoolRetain'; 215(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // NULL-safe 216 217{! 218 @function CVOpenGLBufferPoolRelease 219 @abstract Releases a CVOpenGLBufferPoolRef object 220 @discussion Equivalent to CFRelease, but NULL safe 221 @param buffer A CVOpenGLBufferPoolRef object that you want to release. 222} 223procedure CVOpenGLBufferPoolRelease( openGLBufferPool: CVOpenGLBufferPoolRef ); external name '_CVOpenGLBufferPoolRelease'; 224(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) // NULL-safe 225 226{! 227 @function CVOpenGLBufferPoolCreate 228 @abstract Creates a new OpenGL Buffer pool. 229 @discussion Equivalent to CFRelease, but NULL safe 230 @param allocator The CFAllocatorRef to use for allocating this buffer pool. May be NULL. 231 @param poolAttributes A CFDictionaryRef containing the attributes to be used for the pool itself. 232 @param openGLBufferAttributes A CFDictionaryRef containing the attributes to be used for creating new OpenGLBuffers within the pool. 233 @param poolOut The newly created pool will be placed here 234 @result Returns kCVReturnSuccess on success 235} 236function CVOpenGLBufferPoolCreate( allocator: CFAllocatorRef; poolAttributes: CFDictionaryRef; openGLBufferAttributes: CFDictionaryRef; var poolOut: CVOpenGLBufferPoolRef ): CVReturn; external name '_CVOpenGLBufferPoolCreate'; 237(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 238 239{! 240 @function CVOpenGLBufferPoolGetOpenGLBufferAttributes 241 @abstract Returns the pool attributes dictionary for a CVOpenGLBufferPool 242 @param pool The CVOpenGLBufferPoolRef to retrieve the attributes from 243 @result Returns the pool attributes dictionary, or NULL on failure. 244} 245function CVOpenGLBufferPoolGetAttributes( pool: CVOpenGLBufferPoolRef ): CFDictionaryRef; external name '_CVOpenGLBufferPoolGetAttributes'; 246(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 247 248{! 249 @function CVOpenGLBufferPoolGetOpenGLBufferAttributes 250 @abstract Returns the attributes of OpenGL buffers that will be created from this pool. 251 @discussion This function is provided for those cases where you may need to know some information about the buffers that 252 will be created up front. 253 @param pool The CVOpenGLBufferPoolRef to retrieve the attributes from 254 @result Returns the OpenGL buffer attributes dictionary, or NULL on failure. 255} 256function CVOpenGLBufferPoolGetOpenGLBufferAttributes( pool: CVOpenGLBufferPoolRef ): CFDictionaryRef; external name '_CVOpenGLBufferPoolGetOpenGLBufferAttributes'; 257(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 258 259{! 260 @function CVOpenGLBufferPoolCreateOpenGLBuffer 261 @abstract Creates a new OpenGLBuffer object from the pool. 262 @discussion The function creates a new CVOpenGLBuffer with the default attachments using the OpenGL buffer attributes specifed during pool creation. 263 @param allocator The CFAllocatorRef to use for creating the OpenGL buffer. May be NULL. 264 @param openGLBufferPool The CVOpenGLBufferPool that should create the new CVOpenGLBuffer. 265 @param openGLBufferOut The newly created OpenGL buffer will be placed here 266 @result Returns kCVReturnSuccess on success 267} 268function CVOpenGLBufferPoolCreateOpenGLBuffer( allocator: CFAllocatorRef; openGLBufferPool: CVOpenGLBufferPoolRef; var openGLBufferOut: CVOpenGLBufferRef ): CVReturn; external name '_CVOpenGLBufferPoolCreateOpenGLBuffer'; 269(* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *) 270 271{$endc} // TARGET_OS_MAC 272{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 273 274end. 275{$endc} {not MACOSALLINCLUDE}