nuclear@6: Name nuclear@6: nuclear@6: EXT_texture_from_pixmap nuclear@6: nuclear@6: Name Strings nuclear@6: nuclear@6: GLX_EXT_texture_from_pixmap nuclear@6: nuclear@6: Contributors nuclear@6: nuclear@6: James Jones, NVIDIA nuclear@6: Aaron Plattner, NVIDIA nuclear@6: Andy Ritger, NVIDIA nuclear@6: nuclear@6: Contact nuclear@6: nuclear@6: David Reveman, Novell, Inc. (davidr 'at' novell.com) nuclear@6: nuclear@6: Status nuclear@6: nuclear@6: Complete nuclear@6: nuclear@6: Version nuclear@6: nuclear@6: 17 (10 Feb 2009) nuclear@6: nuclear@6: Number nuclear@6: nuclear@6: 344 nuclear@6: nuclear@6: Dependencies nuclear@6: nuclear@6: OpenGL 1.1 is required. nuclear@6: GLX 1.3 is required. nuclear@6: GL_EXT_framebuffer_object affects the definition of this extension. nuclear@6: GL_ARB_texture_rectangle affects the definition of this extension. nuclear@6: GL_ARB_texture_non_power_of_two affects the definition of this extension. nuclear@6: GL_SGIS_generate_mipmap affects the definition of this extension. nuclear@6: nuclear@6: Overview nuclear@6: nuclear@6: This extension allows a color buffer to be used for both rendering and nuclear@6: texturing. nuclear@6: nuclear@6: Only color buffers of pixmaps can be used for texturing by this extension nuclear@6: but other types of drawables can be supported by future extensions layered nuclear@6: on top of this extension. nuclear@6: nuclear@6: The functionality of this extension is similar to WGL_ARB_render_texture. nuclear@6: However, the purpose of this extension is not to provide nuclear@6: "render to texture" like functionality but rather the ability to bind nuclear@6: an existing X drawable to a texture. Though, there is nothing that nuclear@6: prohibits it from being used for "render to texture". nuclear@6: nuclear@6: - Windows are problematic as they can change size and therefore are not nuclear@6: supported by this extension. nuclear@6: nuclear@6: - Only a color buffer of a GLX pixmap created using an FBConfig with nuclear@6: attribute GLX_BIND_TO_TEXTURE_RGB_EXT or GLX_BIND_TO_TEXTURE_RGBA_EXT nuclear@6: set to TRUE can be bound as a texture. nuclear@6: nuclear@6: - The texture internal format is determined when the color buffer nuclear@6: is associated with the texture, guaranteeing that the color nuclear@6: buffer format is equivalent to the texture internal format. nuclear@6: nuclear@6: - A client can create a complete set of mipmap images if nuclear@6: EXT_framebuffer_object is supported. nuclear@6: nuclear@6: nuclear@6: IP Status nuclear@6: nuclear@6: There are no known IP issues. nuclear@6: nuclear@6: Issues nuclear@6: nuclear@6: 1. What should this extension be called? nuclear@6: nuclear@6: Even though it is very similar to WGL_ARB_render_texture that name is nuclear@6: not appropriate as the intention of this extension is not nuclear@6: "render to texture" like functionality. nuclear@6: nuclear@6: EXT_texture_from_pixmap seams most appropriate. Layering of future nuclear@6: extensions on top of this extension for using other type of drawables nuclear@6: as textures follows the same conventions as vertex/pixel buffer objects nuclear@6: and vertex/fragment programs. nuclear@6: nuclear@6: nuclear@6: 2. Should we allow applications to render to different mipmap levels and nuclear@6: cube map faces? nuclear@6: nuclear@6: In order to discourage the use of this extension as a render to texture nuclear@6: mechanism, cube maps and rendering directly to mip-map levels > 0 will nuclear@6: not be supported. A new FBConfig attribute is introduced that specifies nuclear@6: whether or not drawables created with that config will support multiple nuclear@6: mipmap levels when bound to a texture. The other mipmap levels can be nuclear@6: filled in by the EXT_framebuffer_object GenerateMipmapEXT function. nuclear@6: nuclear@6: Specifying which level of a pixmap was being rendered to on a per-drawable nuclear@6: basis, as was done in the WGL_ARB_render_texture extension, also nuclear@6: introduces concurrency issues. The state of the drawable when it was nuclear@6: being rendered two by two separate threads of execution and both were nuclear@6: changing the mipmap level was difficult to define. nuclear@6: nuclear@6: It is also desireable to keep this extension as simple as possible. nuclear@6: Adding functionality that complicates the implementation and that is not nuclear@6: directly relevenat to the goal of exposing a mechanism for texturing from nuclear@6: arbitrary X pixmaps is not productive. If the ability to render directly nuclear@6: to all levels of a texture is needed, EXT_framebuffer_object is the nuclear@6: extension that should be used. nuclear@6: nuclear@6: nuclear@6: 3. Should 1D textures be supported? nuclear@6: nuclear@6: X servers layered on top of an OpenGL implementation might not be able nuclear@6: to support this. A new FBConfig attribute is introduced specifying nuclear@6: which texture targets a drawable created with the given FBConfig can nuclear@6: be bound to. nuclear@6: nuclear@6: nuclear@6: 4. What should the default value for GLX_TEXTURE_TARGET_EXT be? Should nuclear@6: users be required to set this value if GLX_TEXTURE_FORMAT_EXT is not nuclear@6: GLX_TEXTURE_FORMAT_NONE_EXT? nuclear@6: nuclear@6: The implementation is capable of choosing a reasonable default, we simply nuclear@6: need to specify the correct way to do so. We can base the ordering on nuclear@6: the properties of the pixmap and the texturing capabilities of the nuclear@6: pixmap's FBConfig and the implementation. nuclear@6: nuclear@6: The order is: nuclear@6: nuclear@6: - If GL_ARB_texture_non_power_of_two is supported GL_TEXTURE_2D will nuclear@6: be used for all pixmap sizes. nuclear@6: nuclear@6: - If only GL_ARB_texture_rectangle is supported GL_TEXTURE_2D will nuclear@6: be used for all power of two pixmap sizes and GL_TEXTURE_RECTANGLE_ARB nuclear@6: will be used for all non power of two pixmap sizes. nuclear@6: nuclear@6: nuclear@6: 5. Should users be required to re-bind the drawable to a texture after nuclear@6: the drawable has been rendered to? nuclear@6: nuclear@6: It is difficult to define what the contents of the texture would be if nuclear@6: we don't require this. Also, requiring this would allow implementations nuclear@6: to perform an implicit copy at this point if they could not support nuclear@6: texturing directly out of renderable memory. nuclear@6: nuclear@6: The problem with defining the contents of the texture after rendering nuclear@6: has occured to the associated drawable is that there is no way to nuclear@6: synchronize the use of the buffer as a source and as a destination. nuclear@6: Direct OpenGL rendering is not necessarily done in the same command nuclear@6: stream as X rendering. At the time the pixmap is used as the source nuclear@6: for a texturing operation, it could be in a state halfway through a nuclear@6: copyarea operation in which half of it is say, white, and half is the nuclear@6: result of the copyarea operation. How is this defined? Worse, some nuclear@6: other OpenGL application could be halfway through a frame of rendering nuclear@6: when the composite manager sources from it. The buffer might just nuclear@6: contain the results of a "glClear" operation at that point. nuclear@6: nuclear@6: To gurantee tear-free rendering, a composite manager would run as follows: nuclear@6: nuclear@6: -receive request for compositing: nuclear@6: XGrabServer() nuclear@6: glXWaitX() or XSync() nuclear@6: glXBindTexImageEXT() nuclear@6: nuclear@6: nuclear@6: nuclear@6: glXReleaseTexImageEXT() nuclear@6: XUngrabServer() nuclear@6: nuclear@6: Apps that don't synchronize like this would get what's available, nuclear@6: and that may or may not be what they expect. nuclear@6: nuclear@6: nuclear@6: 6. What is the result of calling GenerateMipmapEXT on a drawable that nuclear@6: was not created with mipmap levels? nuclear@6: nuclear@6: The results are undefined. nuclear@6: nuclear@6: nuclear@6: 7. Rendering done by the window system may be y-inverted compared nuclear@6: to the standard OpenGL texture representation. More specifically: nuclear@6: the X Window system uses a coordinate system where the origin is in nuclear@6: the upper left; however, the GL uses a coordinate system where the nuclear@6: origin is in the lower left. Should we define the contents of the nuclear@6: texture as the y-inverted contents of the drawable? nuclear@6: nuclear@6: X implementations may represent their drawables differently internally, nuclear@6: so y-inversion should be exposed as an FBConfig attribute. nuclear@6: Applications will need to query this attribute and adjust their rendering nuclear@6: appropriately. nuclear@6: nuclear@6: If a drawables is y-inverted and is bound to a texture, the contents of the nuclear@6: texture will be y-inverted with respect to the standard GL memory layout. nuclear@6: This means the contents of a pixmap of size (width, height) at pixmap nuclear@6: coordinate (x, y) will be at location (x, height-y-1) in the texture. nuclear@6: Applications will need to adjust their texture coordinates accordingly to nuclear@6: avoid drawing the texture contents upside down. nuclear@6: nuclear@6: nuclear@6: 8. Why wasn't this extension based on FBO instead of ARB_render_texture? nuclear@6: Isn't the render_texture extension deprecated? nuclear@6: nuclear@6: At first glance, FBO may seem like the perfect framework to base a spec nuclear@6: for texturing from pixmap surfaces on. It replaced the nuclear@6: WGL_ARB_render_texture specification, which provided a mechanism to nuclear@6: texture from pbuffer surfaces. However, this train of thought is another nuclear@6: side effect of the unfortunate naming of the WGL_ARB_render_texture nuclear@6: specification. FBO and the orginal render_texture specification were nuclear@6: two different solutions to the problem of how to render to and texture nuclear@6: from the same surface. WGL_ARB_render_texture provided a method to bind nuclear@6: a texture to a drawable surface, as this extension does. FBO provides the nuclear@6: opposite solution, allowing rendering to arbitrary surfaces including nuclear@6: textures. In the case of FBO, the application doing the rendering knows nuclear@6: that it needs to render to an alternate surface. In our usage case, the nuclear@6: application doing the rendering is arbitrary, and has no knowledge that another nuclear@6: application wants to use the surface it is rendering to as a texture. The nuclear@6: only application able to name the surface is the one texturing from it. nuclear@6: Therefore, it makes sense to provide a mechanism for binding a texture to nuclear@6: an arbitrary surface in general, and a pixmap in this particular case. nuclear@6: nuclear@6: nuclear@6: 9. Why not allow binding directly to an X pixmap without creating an nuclear@6: intermediate GLX pixmap? nuclear@6: nuclear@6: Architecturally, GLX has moved away from operating directly on X nuclear@6: drawables. This allows GLX specific attributes to be associated with the nuclear@6: GLX drawables. In this case, it is important to associate an FBConfig nuclear@6: with the drawable. The FBConfig contains attributes specifying the nuclear@6: internal format the GL will use when utilizing the drawable's framebuffer nuclear@6: as a texture. nuclear@6: nuclear@6: nuclear@6: New Procedures and Functions nuclear@6: nuclear@6: void glXBindTexImageEXT (Display *display, nuclear@6: GLXDrawable drawable, nuclear@6: int buffer, nuclear@6: const int *attrib_list) nuclear@6: nuclear@6: void glXReleaseTexImageEXT (Display *display, nuclear@6: GLXDrawable drawable, nuclear@6: int buffer) nuclear@6: nuclear@6: nuclear@6: New Tokens nuclear@6: nuclear@6: Accepted by the parameter of glXGetFBConfigAttrib and nuclear@6: the parameter of glXChooseFBConfig: nuclear@6: nuclear@6: GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 nuclear@6: GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 nuclear@6: GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 nuclear@6: GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 nuclear@6: GLX_Y_INVERTED_EXT 0x20D4 nuclear@6: nuclear@6: Accepted as an attribute in the parameter of nuclear@6: glXCreatePixmap, and by the parameter of glXQueryDrawable: nuclear@6: nuclear@6: GLX_TEXTURE_FORMAT_EXT 0x20D5 nuclear@6: GLX_TEXTURE_TARGET_EXT 0x20D6 nuclear@6: GLX_MIPMAP_TEXTURE_EXT 0x20D7 nuclear@6: nuclear@6: Accepted as a value in the parameter of glXCreatePixmap nuclear@6: and returned in the parameter of glXQueryDrawable when nuclear@6: is GLX_TEXTURE_FORMAT_EXT: nuclear@6: nuclear@6: GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 nuclear@6: GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 nuclear@6: GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA nuclear@6: nuclear@6: Accepted as bits in the GLX_BIND_TO_TEXTURE_TARGETS_EXT variable: nuclear@6: nuclear@6: GLX_TEXTURE_1D_BIT_EXT 0x00000001 nuclear@6: GLX_TEXTURE_2D_BIT_EXT 0x00000002 nuclear@6: GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 nuclear@6: nuclear@6: Accepted as a value in the parameter of glXCreatePixmap nuclear@6: and returned in the parameter of glXQueryDrawable when nuclear@6: is GLX_TEXTURE_TARGET_EXT: nuclear@6: nuclear@6: GLX_TEXTURE_1D_EXT 0x20DB nuclear@6: GLX_TEXTURE_2D_EXT 0x20DC nuclear@6: GLX_TEXTURE_RECTANGLE_EXT 0x20DD nuclear@6: nuclear@6: Accepted by the parameter of glXBindTexImageEXT and nuclear@6: glXReleaseTexImageEXT: nuclear@6: nuclear@6: GLX_FRONT_LEFT_EXT 0x20DE nuclear@6: GLX_FRONT_RIGHT_EXT 0x20DF nuclear@6: GLX_BACK_LEFT_EXT 0x20E0 nuclear@6: GLX_BACK_RIGHT_EXT 0x20E1 nuclear@6: GLX_FRONT_EXT GLX_FRONT_LEFT_EXT nuclear@6: GLX_BACK_EXT GLX_BACK_LEFT_EXT nuclear@6: GLX_AUX0_EXT 0x20E2 nuclear@6: GLX_AUX1_EXT 0x20E3 nuclear@6: GLX_AUX2_EXT 0x20E4 nuclear@6: GLX_AUX3_EXT 0x20E5 nuclear@6: GLX_AUX4_EXT 0x20E6 nuclear@6: GLX_AUX5_EXT 0x20E7 nuclear@6: GLX_AUX6_EXT 0x20E8 nuclear@6: GLX_AUX7_EXT 0x20E9 nuclear@6: GLX_AUX8_EXT 0x20EA nuclear@6: GLX_AUX9_EXT 0x20EB nuclear@6: nuclear@6: nuclear@6: GLX Protocol nuclear@6: nuclear@6: Two new GLX protocol commands are added. nuclear@6: nuclear@6: BindTexImageEXT nuclear@6: 1 CARD8 opcode (X assigned) nuclear@6: 1 16 GLX opcode (glXVendorPrivate) nuclear@6: 2 6+n request length nuclear@6: 4 1330 vendor specific opcode nuclear@6: 4 CARD32 context tag nuclear@6: 4 GLX_DRAWABLE drawable nuclear@6: 4 INT32 buffer nuclear@6: 4 CARD32 num_attributes nuclear@6: 4*n LISTofATTRIBUTE_PAIR attribute, value pairs. nuclear@6: nuclear@6: ReleaseTexImageEXT nuclear@6: 1 CARD8 opcode (X assigned) nuclear@6: 1 16 GLX opcode (glXVendorPrivate) nuclear@6: 2 5 request length nuclear@6: 4 1331 vendor specific opcode nuclear@6: 4 CARD32 context tag nuclear@6: 4 GLX_DRAWABLE drawable nuclear@6: 4 INT32 buffer nuclear@6: nuclear@6: nuclear@6: Errors nuclear@6: nuclear@6: Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation) nuclear@6: nuclear@6: None. nuclear@6: nuclear@6: Additions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization) nuclear@6: nuclear@6: None. nuclear@6: nuclear@6: Additions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment nuclear@6: Operations and the Frame Buffer) nuclear@6: nuclear@6: None. nuclear@6: nuclear@6: Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions) nuclear@6: nuclear@6: None. nuclear@6: nuclear@6: Additions to Chapter 6 of the OpenGL 1.2.1 Specification (State and State nuclear@6: Requests) nuclear@6: nuclear@6: None. nuclear@6: nuclear@6: Additions to the GLX Specification nuclear@6: nuclear@6: Add to table 3.1, GLXFBConfig Attributes: nuclear@6: nuclear@6: Attribute Type Notes nuclear@6: ------------------------------- ------- ------------------------------------------------------------------- nuclear@6: GLX_BIND_TO_TEXTURE_RGB_EXT boolean True if color buffers can be bound to RGB texture nuclear@6: GLX_BIND_TO_TEXTURE_RGBA_EXT boolean True if color buffers can be bound to RGBA texture nuclear@6: GLX_BIND_TO_MIPMAP_TEXTURE_EXT boolean True if color buffers can be bound to textures with multiple levels nuclear@6: GLX_BIND_TO_TEXTURE_TARGETS_EXT bitmask Bitmask of texture targets color buffers can be bound to nuclear@6: GLX_Y_INVERTED_EXT boolean True if the drawable's framebuffer is y-inverted. This can be used to determine if y-inverted texture coordinates need to be used when texturing from this drawable when it is bound to a texture target. nuclear@6: nuclear@6: Additions to table 3.4, Default Match Criteria for GLXFBConfig attributes: nuclear@6: nuclear@6: Attribute Default Selection Criteria Priority nuclear@6: ------------------------------- -------------------- ------------------ --------- nuclear@6: GLX_BIND_TO_TEXTURE_RGB_EXT GLX_DONT_CARE Exact nuclear@6: GLX_BIND_TO_TEXTURE_RGBA_EXT GLX_DONT_CARE Exact nuclear@6: GLX_BIND_TO_MIPMAP_TEXTURE_EXT GLX_DONT_CARE Exact nuclear@6: GLX_BIND_TO_TEXTURE_TARGETS_EXT - Mask nuclear@6: GLX_Y_INVERTED_EXT GLX_DONT_CARE Exact nuclear@6: nuclear@6: Modifications to 3.3.3, "Configuration Management" nuclear@6: nuclear@6: Add after paragraph 17 in the description of FBConfigs: nuclear@6: nuclear@6: GLX_Y_INVERTED_EXT is a boolean describing the memory layout used for nuclear@6: drawables created with the GLXFBConfig. The attribute is True if the nuclear@6: drawable's framebuffer will be y-inverted. This can be used to determine nuclear@6: if y-inverted texture coordinates need to be used when texturing from this nuclear@6: drawable when it is bound to a texture target. nuclear@6: nuclear@6: Modifications to 3.3.5, "Offscreen Rendering" nuclear@6: nuclear@6: Modify paragraph 3 of the description of glXCreatePixmap: nuclear@6: nuclear@6: specifies a list of attributes for the pixmap. The list has nuclear@6: the same structure as described for glXChooseFBConfig. Currently the nuclear@6: following attributes can be specified in attrib_list: nuclear@6: GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_TARGET_EXT, GLX_MIPMAP_TEXTURE_EXT, nuclear@6: attrib_list may be NULL or empty (first attribute of None), in which case nuclear@6: all attributes assume their default values as described below. nuclear@6: nuclear@6: GLX_TEXTURE_FORMAT_EXT describes the texture format this pixmap can be nuclear@6: bound to. Valid values are GLX_TEXTURE_FORMAT_RGB_EXT, nuclear@6: GLX_TEXTURE_FORMAT_RGBA_EXT, and GLX_TEXTURE_FORMAT_NONE_EXT. nuclear@6: nuclear@6: GLX_TEXTURE_TARGET_EXT can be set to GLX_TEXTURE_1D_EXT, nuclear@6: GLX_TEXTURE_2D_EXT, or GLX_TEXTURE_RECTANGLE_EXT; it indicates the type nuclear@6: of texture that will be created when GLX_TEXTURE_FORMAT_EXT is not nuclear@6: GLX_TEXTURE_FORMAT_NONE_EXT. The default value of GLX_TEXTURE_TARGET_EXT nuclear@6: depends on the capabilities in and the dimensions of the pixmap. nuclear@6: If has GLX_TEXTURE_2D_BIT set and one or more of the following is nuclear@6: true: nuclear@6: nuclear@6: * GLX_TEXTURE_RECTANGLE_BIT_EXT is not set in nuclear@6: nuclear@6: * GL_ARB_texture_non_power_of_two is supported nuclear@6: nuclear@6: * the pixmap's width and height are powers of 2 nuclear@6: nuclear@6: the default value for GLX_TEXTURE_TARGET_EXT is GLX_TEXTURE_2D_EXT. nuclear@6: nuclear@6: Otherwise, the first supported target is chosen in this order: nuclear@6: GLX_TEXTURE_RECTANGLE_EXT, GLX_TEXTURE_1D_EXT. nuclear@6: nuclear@6: GLX_MIPMAP_TEXTURE_EXT indicates that storage for mipmaps should be nuclear@6: allocated. Space for mipmaps will be set aside if GLX_TEXTURE_FORMAT_EXT nuclear@6: is not GLX_TEXTURE_FORMAT_NONE_EXT and GLX_MIPMAP_TEXTURE_EXT is TRUE. nuclear@6: The default value is FALSE. nuclear@6: nuclear@6: Modify paragraph 5 of the description of glXCreatePixmap: nuclear@6: nuclear@6: ...If is not a valid Pixmap XID, then a BadPixmap error is nuclear@6: generated. A BadConfig error is generated if any of the following nuclear@6: conditions are true: nuclear@6: nuclear@6: * GLX_TEXTURE_FORMAT_EXT is GLX_TEXTURE_FORMAT_RGB_EXT and nuclear@6: does not have GLX_BIND_TO_TEXTURE_RGB set to TRUE. nuclear@6: nuclear@6: * GLX_TEXTURE_FORMAT_EXT is GLX_TEXTURE_FORMAT_RGBA_EXT and nuclear@6: does not have GLX_BIND_TO_TEXTURE_RGBA set to TRUE. nuclear@6: nuclear@6: * GLX_MIPMAP_TEXTURE_EXT is set to TRUE and does not nuclear@6: have GLX_BIND_TO_MIPMAP_EXT set to TRUE. nuclear@6: nuclear@6: * GLX_TEXTURE_TARGET_EXT is set to GLX_TEXTURE_1D_EXT nuclear@6: and does not have GLX_TEXTURE_1D_BIT_EXT set. nuclear@6: nuclear@6: * GLX_TEXTURE_TARGET_EXT is set to GLX_TEXTURE_2D_EXT nuclear@6: and does not have GLX_TEXTURE_2D_BIT_EXT set. nuclear@6: nuclear@6: * GLX_TEXTURE_TARGET_EXT is set to GLX_TEXTURE_RECTANGLE_EXT nuclear@6: and does not have GLX_TEXTURE_RECTANGLE_BIT_EXT set. nuclear@6: nuclear@6: A BadValue error is generated if GLX_TEXTURE_FORMAT_EXT is not nuclear@6: GLX_TEXTURE_FORMAT_NONE_EXT and the width or height of are nuclear@6: incompatible with the specified value of GLX_TEXTURE_TARGET_EXT on this nuclear@6: implementation. (e.g., the pixmap size is not a power of 2 and nuclear@6: GL_ARB_texture_rectangle is not supported). nuclear@6: nuclear@6: Modify paragraph 1 of the description of glXDestroyPixmap: nuclear@6: nuclear@6: ...The storage for the GLX pixmap will be freed when it is not current nuclear@6: to any client and all color buffers that are bound to a texture object nuclear@6: have been released. nuclear@6: nuclear@6: nuclear@6: Modifications to seciton 3.3.6, "Querying Attributes" nuclear@6: nuclear@6: Modify paragraph 1 of the description of glXQueryDrawable: nuclear@6: nuclear@6: ... must be set to one of GLX_WIDTH, GLX_HEIGHT, nuclear@6: GLX_PRESERVED_CONTENTS, GLX_LARGEST_PBUFFER, GLX_FBCONFIG_ID, nuclear@6: GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_TARGET_EXT or GLX_MIPMAP_TEXTURE_EXT nuclear@6: or a BadValue error is generated. nuclear@6: nuclear@6: Modify paragraph 3 of the description of glXQueryDrawable: nuclear@6: nuclear@6: ...If is a GLXWindow or GLXPixmap and is set to nuclear@6: GLX_PRESERVED_CONTENTS or GLX_LARGEST_PBUFFER, or if is a nuclear@6: GLXWindow or GLXPbuffer and is set to GLX_TEXTURE_FORMAT_EXT, nuclear@6: GLX_TEXTURE_TARGET_EXT, or GLX_MIPMAP_TEXTURE_EXT, the contents of nuclear@6: are undefined. nuclear@6: nuclear@6: Add a new section 3.3.6.1, "Texturing From Drawables" nuclear@6: nuclear@6: The command nuclear@6: nuclear@6: void glXBindTexImageEXT (Display *dpy, nuclear@6: GLXDrawable draw, nuclear@6: int buffer, nuclear@6: int *attrib_list); nuclear@6: nuclear@6: defines a one- or two-dimensional texture image. The texture image is taken nuclear@6: from and need not be copied. The texture target, the texture nuclear@6: format, and the size of the texture components are derived from attributes nuclear@6: of . nuclear@6: nuclear@6: The drawable attribute GLX_TEXTURE_FORMAT_EXT determines the base internal nuclear@6: format of the texture. The component sizes are also determined by drawable nuclear@6: attributes as shown in table 3.4a. nuclear@6: nuclear@6: Add new table 3.4a: Size of texture components: nuclear@6: nuclear@6: Texture component Size nuclear@6: ----------------- -------------- nuclear@6: R GLX_RED_SIZE nuclear@6: G GLX_GREEN_SIZE nuclear@6: B GLX_BLUE_SIZE nuclear@6: A GLX_ALPHA_SIZE nuclear@6: nuclear@6: The texture target is derived from the GLX_TEXTURE_TARGET_EXT attribute of nuclear@6: . If the texture target for the drawable is GLX_TEXTURE_2D_EXT or nuclear@6: GLX_TEXTURE_RECTANGLE_EXT, then buffer defines a 2D texture for the current nuclear@6: 2D or rectangle texture object respectively; if the texture target is nuclear@6: GLX_TEXTURE_1D_EXT, then buffer defines a 1D texture for the current 1D nuclear@6: texture object. nuclear@6: nuclear@6: If is not one of GLX_FRONT_LEFT_EXT, GLX_FRONT_RIGHT_EXT, nuclear@6: GLX_BACK_LEFT_EXT, GLX_BACK_RIGHT_EXT, or GLX_AUX0_EXT through nuclear@6: GLX_AUXn_EXT, where n is one less than the number of AUX buffers supported nuclear@6: by the FBConfig used to create , or if the requested buffer is nuclear@6: missing, a BadValue error is generated. nuclear@6: nuclear@6: specifies a list of attributes for the texture. The list has nuclear@6: the same structure as described for glXChooseFBConfig. If is nuclear@6: NULL or empty (first attribute of None), then all attributes assume their nuclear@6: default values. must be NULL or empty. nuclear@6: nuclear@6: If and are the display and drawable for the calling thread's nuclear@6: current context, glXBindTexImageEXT performs an implicit glFlush. nuclear@6: nuclear@6: The contents of the texture after the drawable has been bound are defined nuclear@6: as the result of all rendering that has completed before the call to nuclear@6: glXBindTexImageEXT. In other words, the results of any operation which nuclear@6: has caused damage on the drawable prior to the glXBindTexImageEXT call nuclear@6: will be represented in the texture. nuclear@6: nuclear@6: Rendering to the drawable while it is bound to a texture will leave the nuclear@6: contents of the texture in an undefined state. However, no nuclear@6: synchronization between rendering and texturing is done by GLX. It is nuclear@6: the application's responsibility to implement any synchronization nuclear@6: required. nuclear@6: nuclear@6: If a texture object is deleted before glXReleaseTexImageEXT is called, nuclear@6: the color buffer is released. nuclear@6: nuclear@6: It is not an error to call TexImage2D, TexImage1D, CopyTexImage1D, or nuclear@6: CopyTexImage2D to replace an image of a texture object that has a color nuclear@6: buffer bound to it. However, these calls will cause the color buffer to be nuclear@6: released and new memory to be allocated for the texture. Note that the nuclear@6: color buffer is released even if the image that is being defined is a mipmap nuclear@6: level that was not defined by the color buffer. GenerateMipmapEXT is an nuclear@6: exception. GenerateMipmapEXT can be used to define mipmap levels for nuclear@6: drawables that have been created with GLX_MIPMAP_TEXTURE_EXT set. Calling nuclear@6: GenerateMipmapEXT on a drawable that was created without nuclear@6: GLX_MIPMAP_TEXTURE_EXT is undefined. nuclear@6: nuclear@6: The results of calling glXBindTexImageEXT when GENERATE_MIPMAP_SGIS is TRUE nuclear@6: are undefined. nuclear@6: nuclear@6: If glXBindTexImageEXT is called and the drawable attribute nuclear@6: GLX_TEXTURE_FORMAT_EXT is GLX_TEXTURE_FORMAT_NONE_EXT, then a BadMatch nuclear@6: error is generated. nuclear@6: nuclear@6: Currently, only pixmaps can be bound to textures. If is not a nuclear@6: valid GLXPixmap, then a GLXBadPixmap error is generated. nuclear@6: nuclear@6: glXBindTexImageEXT is ignored if there is no current GLX rendering context. nuclear@6: nuclear@6: To release a color buffer that is being used as a texture, call nuclear@6: nuclear@6: void glXReleaseTexImageEXT (Dislpay *dpy, GLXDrawable draw, int buffer); nuclear@6: nuclear@6: must be one of GLX_FRONT_LEFT_EXT, GLX_FRONT_RIGHT_EXT, nuclear@6: GLX_BACK_LEFT_EXT, GLX_BACK_RIGHT_EXT, and GLX_AUX0_EXT through nuclear@6: GLX_AUXn_EXT, where n is one less than the number of AUX buffers nuclear@6: supported by the FBConfig used to create or a BadValue error nuclear@6: is generated. nuclear@6: nuclear@6: The contents of the color buffer are unaffected by glXReleaseTexImageEXT. nuclear@6: nuclear@6: If the specified color buffer is no longer bound to a texture (e.g., nuclear@6: because the texture object was deleted), then glXReleaseTexImageEXT has no effect; nuclear@6: no error is generated. nuclear@6: nuclear@6: When a color buffer is released (e.g., by calling glXReleaseTexImageEXT or nuclear@6: implicitly by calling a routine such as TexImage2D), all textures that were nuclear@6: defined by the color buffer become NULL. nuclear@6: nuclear@6: If glXReleaseTexImageEXT is called and the drawable attribute nuclear@6: GLX_TEXTURE_FORMAT_EXT is GLX_TEXTURE_FORMAT_NONE_EXT, then a BadMatch nuclear@6: error is generated. nuclear@6: nuclear@6: Currently, only pixmaps can be bound to textures. If is not a nuclear@6: valid GLXPixmap, then a GLXBadPixmap error is generated. nuclear@6: nuclear@6: nuclear@6: Usage Examples nuclear@6: nuclear@6: Example 1: Bind redirected window to texture: nuclear@6: nuclear@6: XGetWindowAttributes (display, window, &attrib); nuclear@6: nuclear@6: visualid = XVisualIDFromVisual (attrib.visual); nuclear@6: nuclear@6: fbconfigs = glXGetFBConfigs (display, screen, &nfbconfigs); nuclear@6: for (i = 0; i < nfbconfigs; i++) nuclear@6: { nuclear@6: visinfo = glXGetVisualFromFBConfig (display, fbconfigs[i]); nuclear@6: if (!visinfo || visinfo->visualid != visualid) nuclear@6: continue; nuclear@6: nuclear@6: glXGetFBConfigAttrib (display, fbconfigs[i], GLX_DRAWABLE_TYPE, &value); nuclear@6: if (!(value & GLX_PIXMAP_BIT)) nuclear@6: continue; nuclear@6: nuclear@6: glXGetFBConfigAttrib (display, fbconfigs[i], nuclear@6: GLX_BIND_TO_TEXTURE_TARGETS_EXT, nuclear@6: &value); nuclear@6: if (!(value & GLX_TEXTURE_2D_BIT_EXT)) nuclear@6: continue; nuclear@6: nuclear@6: glXGetFBConfigAttrib (display, fbconfigs[i], nuclear@6: GLX_BIND_TO_TEXTURE_RGBA_EXT, nuclear@6: &value); nuclear@6: if (value == FALSE) nuclear@6: { nuclear@6: glXGetFBConfigAttrib (display, fbconfigs[i], nuclear@6: GLX_BIND_TO_TEXTURE_RGB_EXT, nuclear@6: &value); nuclear@6: if (value == FALSE) nuclear@6: continue; nuclear@6: } nuclear@6: nuclear@6: glXGetFBConfigAttrib (display, fbconfigs[i], nuclear@6: GLX_Y_INVERTED_EXT, nuclear@6: &value); nuclear@6: if (value == TRUE) nuclear@6: { nuclear@6: top = 0.0f; nuclear@6: bottom = 1.0f; nuclear@6: } nuclear@6: else nuclear@6: { nuclear@6: top = 1.0f; nuclear@6: bottom = 0.0f; nuclear@6: } nuclear@6: nuclear@6: break; nuclear@6: } nuclear@6: nuclear@6: if (i == nfbconfigs) nuclear@6: /* error 1 */ nuclear@6: nuclear@6: pixmap = XCompositeNameWindowPixmap (display, window); nuclear@6: pixmapAttribs = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, nuclear@6: GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, nuclear@6: None }; nuclear@6: glxpixmap = glXCreatePixmap (display, fbconfigs[i], pixmap, pixmapAttribs); nuclear@6: nuclear@6: glGenTextures (1, &texture); nuclear@6: glBindTexture (GL_TEXTURE_2D, texture); nuclear@6: nuclear@6: glXBindTexImageEXT (display, glxpixmap, GLX_FRONT_LEFT_EXT, NULL); nuclear@6: nuclear@6: glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); nuclear@6: glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); nuclear@6: nuclear@6: /* draw using pixmap as texture */ nuclear@6: glBegin (GL_QUADS); nuclear@6: nuclear@6: glTexCoord2d (0.0f, bottom); nuclear@6: glVertex2d (0.0f, 0.0f); nuclear@6: nuclear@6: glTexCoord2d (0.0f, top); nuclear@6: glVertex2d (0.0f, 1.0f); nuclear@6: nuclear@6: glTexCoord2d (1.0f, top); nuclear@6: glVertex2d (1.0f, 1.0f); nuclear@6: nuclear@6: glTexCoord2d (1.0f, bottom); nuclear@6: glVertex2d (1.0f, 0.0f); nuclear@6: nuclear@6: glEnd (); nuclear@6: nuclear@6: glXReleaseTexImageEXT (display, glxpixmap, GLX_FRONT_LEFT_EXT); nuclear@6: nuclear@6: nuclear@6: Version History nuclear@6: nuclear@6: 1. 26 Nov 2005 - DavidR nuclear@6: Initial version nuclear@6: 2. 01 Dec 2005 - JamesJ nuclear@6: -Adapted spec language from draft version of GLX_ARB_render_texture. nuclear@6: -Added glXDrawableAttribute to set attributes. nuclear@6: -Modified glXBindTexImageEXT to take an attrib_list parameter. nuclear@6: -Added support for cubemap and 1D texture targets. nuclear@6: -Added attribute to set the texture target when creating the nuclear@6: drawable. nuclear@6: -Updated the issues section. nuclear@6: -Added mipmap support. Support is not required. nuclear@6: -Specified results of texturing from a drawable when it has been nuclear@6: rendered to while bound to a texture as undefined until nuclear@6: glXReleaseTexImageEXT has been called. Allows implementations nuclear@6: that need to perform an implicit copy after rendering occurs nuclear@6: to be compatible with this specification. nuclear@6: 3. 04 Dec 2005 - DavidR nuclear@6: -Changed name to GLX_EXT_texture_from_pixmap. nuclear@6: -Changed spec regarding what happens when a pixmap that is bound nuclear@6: to a texture is rendered to. Having textures be undefined once nuclear@6: they are rendered to makes it useless for a compositing manager, nuclear@6: which is a major use case for this extension. nuclear@6: -Added support for not specifying texture target when creating a nuclear@6: pixmap. Allows implementations to select whatever target it nuclear@6: finds most suitable. nuclear@6: 4. 05 Dec 2005 - JamesJ nuclear@6: -Changed the default value of GLX_TEXTURE_TARGET_EXT from nuclear@6: GLX_NO_TEXTURE_EXT to something usable. Eliminated nuclear@6: GLX_NO_TEXTURE_EXT. nuclear@6: -Eliminated GLX_TEXTURE_NONE_EXT. nuclear@6: -Removed language referring to sharing of color buffers when nuclear@6: pixmaps are bound to textures. nuclear@6: -Updated issues. nuclear@6: nuclear@6: 5. 13 Dec 2005 - JamesJ nuclear@6: -Removed cube map support and rendering to multiple mipmap nuclear@6: levels support. nuclear@6: nuclear@6: 6. 20 Jan 2006 - JamesJ nuclear@6: -Specified textures are y-inverted. nuclear@6: nuclear@6: 7. 23 Jan 2006 - AaronP nuclear@6: -Fix typos, make some things clearer. Replace ocurrences of "released nuclear@6: back to the drawable" with "released". nuclear@6: nuclear@6: 8. 01 Feb 2006 - AndyR nuclear@6: -Fix minor typos. nuclear@6: nuclear@6: 9. 03 Feb 2006 - JamesJ nuclear@6: -Added some new issues and their resolutions. nuclear@6: -Finalized some issues that had been in discussion. nuclear@6: -Made drawable y-inversion a queryable attribute of the drawable. nuclear@6: -Moved detailed explanation of y-inverted addressing to the issues nuclear@6: section nuclear@6: -Updated example to demonstrate proper use of the y-inverted nuclear@6: attribute. nuclear@6: nuclear@6: 10. 06 Feb 2006 - DavidR nuclear@6: -Made GLX_Y_INVERTED_EXT an FBConfig attribute instead of a drawable nuclear@6: attribute. nuclear@6: -Removed GLX_TEXTURE_CUBE_MAP_EXT. nuclear@6: -Fix minor typo. nuclear@6: nuclear@6: 11. 07 Feb 2006 - JamesJ nuclear@6: -Added description of GLX_Y_INVERTED_EXT GLXFBConfig attribute, based nuclear@6: on description of the drawable attribute of the same name from nuclear@6: and earlier version of the specification. nuclear@6: -Removed language requiring applications to re-bind a pixmap to a nuclear@6: texture to gurantee contents of the texture are updated after a nuclear@6: pixmap has been rendered to. nuclear@6: -Added Aaron Plattner and Andy Ritger to contributors section. nuclear@6: nuclear@6: 12. 14 Feb 2006 - JamesJ nuclear@6: -Disallowed rendering to a drawable while it is bound as a texture nuclear@6: and defined the exact contents of a texture after a drawable has nuclear@6: been bound to it. nuclear@6: nuclear@6: 13. 09 Mar 2006 - JamesJ nuclear@6: -Add a context tag member to the vendor private requests. This field nuclear@6: is part of the vendor private header, and is needed to specify which nuclear@6: context the BindTexImageEXT and ReleaseTexImageEXT requests correspond nuclear@6: to. nuclear@6: -Changed texture target bitfield values to not skip numbers removed in nuclear@6: earlier updates. nuclear@6: nuclear@6: 14. 13 Mar 2006 - JamesJ nuclear@6: -Only require GLX_SGIX_fbconfig + GLX 1.2. nuclear@6: -Clarify language regarding the result of rendering to drawables bound nuclear@6: to textures. nuclear@6: -Added GLX_FRONT_EXT and GLX_BACK_EXT tokens. nuclear@6: nuclear@6: 15. 18 Apr 2006 - JamesJ nuclear@6: -Allocated enum values and opcodes. nuclear@6: -Require GLX 1.3. GLX_SGIX_fbconfig doesn't allow creating pixmaps nuclear@6: with attributes. nuclear@6: -Added more arguments for not supporting rendering to multiple levels nuclear@6: of a texture with this extension. nuclear@6: -Fixed the inconsistencies in the return type of glXBindTexImageEXT nuclear@6: and glXReleaseTexImageEXT. It is now listed as void throughout. nuclear@6: nuclear@6: 16. 12 Sep 2006 - JamesJ nuclear@6: -Fix ordering of GLX protocol nuclear@6: nuclear@6: 17. 10 Feb 2009 - Jon Leech nuclear@6: -Fix typo reported by Jonathan Knispel.