objc2_open_gl/generated/IOSurface.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "objc2-io-surface")]
5use objc2_io_surface::*;
6
7use crate::*;
8
9extern "C-unwind" {
10 /// CGLTexImageIOSurface2D() allows you to bind a single image plane from an IOSurfaceRef to
11 /// an OpenGL texture object. It is the rough equivalent to glTexImage2D(), except that
12 /// the underlying source data comes from an IOSurface rather than from an explicit pointer.
13 /// Note that unlike glTexImage2D(), the binding is "live", in that if the contents of
14 /// the IOSurface change, the contents become visible to OpenGL without making another
15 /// call to CGLTexImageIOSurface2D(). That being said, there are a few synchronization
16 /// things to worry about if you are using IOSurface to pass data between contexts and/or
17 /// different processes, or between the CPU and OpenGL.
18 ///
19 /// In general IOSurface follows Apple's cross-context synchronization rules for OpenGL. Put
20 /// simply, in order for changes done to an IOSurface on context A to become visible to context
21 /// B, you must flush context A's command stream (via an explicit call to glFlush, glFlushRenderAPPLE,
22 /// etc.), and then perform a 'bind' (in this case, glBindTexture()) on context B. Note that
23 /// in the case of an IOSurface backed texture used as a color buffer attachment for an FBO,
24 /// you are only required to call glBindFramebuffer() again. You do not have to call
25 /// glFramebufferTexture2D().
26 ///
27 /// Likewise, if you make changes to an IOSurface with the CPU, you *must* wrap those changes
28 /// with calls to IOSurfaceLock() and IOSurfaceUnlock(), and call glBindTexture() again for
29 /// OpenGL to pick up the changes.
30 ///
31 /// Going in the other direction, if you want changes made with OpenGL to an IOSurface to become
32 /// visible to the CPU, you must also perform an explicit flush of the OpenGL context before
33 /// calling IOSurfaceLock(), or you may not get the most recent data.
34 ///
35 /// IOSurface and OpenGL make no guarantees about correctness if these rules are not followed.
36 ///
37 /// Because of the way IOSurface is currently implemented, it does not allow for any kind of
38 /// automatic format conversion to take place between the data in the IOSurface and the data seen
39 /// by the GPU. This means that OpenGL is going to interpret the data in the IOSurface exactly
40 /// as how it is specified by the format and type parameters passed to CGLTexImageIOSurface2D().
41 ///
42 /// The upshot if this is that the only supported format/type combinations are those that have
43 /// exact matching hardware formats. The table at the bottom of this file lists the format/type/
44 /// internalFormat combinations that are supported in Mac OS X 10.6.
45 ///
46 /// In cases where a given format/type combination has both an Internal Format and Sized Internal
47 /// Format, either one may be used.
48 ///
49 /// Note that CGLTexImageIOSurface2D for the most part doesn't care what the pixel format or bytes
50 /// per element of the IOSurface is. Instead it only enforces the rule that there must be enough
51 /// data in the plane being bound to cover what is required by the width/height/format/type
52 /// parameters. However, if you are using the IOSurface texture as a color buffer attachment to
53 /// an FBO, then you must ensure that the bytes per element value of the IOSurface must match the
54 /// effective bytes per pixel value for the format and type combination you are passing to OpenGL.
55 ///
56 ///
57 /// Parameter `ctx`: The CGLContextObj for the OpenGL context you are using
58 ///
59 /// Parameter `target`: Must currently be GL_TEXTURE_RECTANGLE_ARB as of Mac OS X 10.6.0.
60 ///
61 /// Parameter `internal_format`: One of the supported values from the table below that matches
62 /// the format/type combination.
63 ///
64 /// Parameter `width`: The width of the texture in pixels.
65 ///
66 /// Parameter `height`: The height of the texture in pixels.
67 ///
68 /// Parameter `format`: The OpenGL texture format enum
69 ///
70 /// Parameter `type`: The OpenGL texture type enum
71 ///
72 /// Parameter `ioSurface`: The IOSurfaceRef this texture is being bound to
73 ///
74 /// Parameter `plane`: Which plane of the IOSurface this texture is being bound to
75 ///
76 /// # Safety
77 ///
78 /// `ctx` must be a valid pointer.
79 #[cfg(all(feature = "CGLTypes", feature = "objc2-io-surface"))]
80 pub fn CGLTexImageIOSurface2D(
81 ctx: CGLContextObj,
82 target: GLenum,
83 internal_format: GLenum,
84 width: GLsizei,
85 height: GLsizei,
86 format: GLenum,
87 r#type: GLenum,
88 io_surface: &IOSurfaceRef,
89 plane: GLuint,
90 ) -> CGLError;
91}