GlGetTexImage: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "'''_glGetTexImage:''' return a texture image {{PageSyntax}} SUB _glGetTexImage (BYVAL target AS _UNSIGNED LONG, BYVAL level AS LONG, BYVAL format AS _UNSIGNED LONG, BYVAL type AS _UNSIGNED LONG, pixels AS _OFFSET) void '''_glGetTexImage'''(GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, GLvoid * {{Parameter|img}}); ; target : Specifies which texture is to be obtained. {{KW|_GL_TEXTURE_1D}}, {{KW|_GL...")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''_glGetTexImage:''' return a texture image
{{DISPLAYTITLE:_glGetTexImage}}
The '''_glGetTexImage''' statement returns a texture image.




{{PageSyntax}}
{{PageSyntax}}
: [[_glGetTexImage]] GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, GLvoid {{Parameter|*pixels}}


  SUB _glGetTexImage (BYVAL target AS _UNSIGNED LONG, BYVAL level AS LONG, BYVAL format AS _UNSIGNED LONG, BYVAL type AS _UNSIGNED LONG, pixels AS _OFFSET)
  void '''_glGetTexImage'''(GLenum {{Parameter|target}}, GLint {{Parameter|level}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, GLvoid * {{Parameter|img}});


 
{{PageParameters}}
; target
* OpenGL is using its own set of variable types to describe its command parameters.
: Specifies which texture is to be obtained. {{KW|_GL_TEXTURE_1D}}, {{KW|_GL_TEXTURE_2D}}, {{KW|_GL_TEXTURE_3D}}, {{KW|_GL_TEXTURE_1D_ARRAY}}, {{KW|_GL_TEXTURE_2D_ARRAY}}, {{KW|_GL_TEXTURE_RECTANGLE}}, {{KW|_GL_TEXTURE_CUBE_MAP_POSITIVE_X}}, {{KW|_GL_TEXTURE_CUBE_MAP_NEGATIVE_X}}, {{KW|_GL_TEXTURE_CUBE_MAP_POSITIVE_Y}}, {{KW|_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y}}, {{KW|_GL_TEXTURE_CUBE_MAP_POSITIVE_Z}}, and {{KW|_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z}} are accepted.
* Use the following table to find the respective QB64 [[Variable Types]].
; level
{{OpenGLTypesPlugin}}
: Specifies the level-of-detail number of the desired image. Level 0 is the base image level. Level ''n'' is the ''n''th mipmap reduction image.
; format
: Specifies a pixel format for the returned data. The supported formats are {{KW|_GL_STENCIL_INDEX}}, {{KW|_GL_DEPTH_COMPONENT}}, {{KW|_GL_DEPTH_STENCIL}}, {{KW|_GL_RED}}, {{KW|_GL_GREEN}}, {{KW|_GL_BLUE}}, {{KW|_GL_RG}}, {{KW|_GL_RGB}}, {{KW|_GL_RGBA}}, {{KW|_GL_BGR}}, {{KW|_GL_BGRA}}, {{KW|_GL_RED_INTEGER}}, {{KW|_GL_GREEN_INTEGER}}, {{KW|_GL_BLUE_INTEGER}}, {{KW|_GL_RG_INTEGER}}, {{KW|_GL_RGB_INTEGER}}, {{KW|_GL_RGBA_INTEGER}}, {{KW|_GL_BGR_INTEGER}}, {{KW|_GL_BGRA_INTEGER}}.
; type
: Specifies a pixel type for the returned data. The supported types are {{KW|_GL_UNSIGNED_BYTE}}, {{KW|_GL_BYTE}}, {{KW|_GL_UNSIGNED_SHORT}}, {{KW|_GL_SHORT}}, {{KW|_GL_UNSIGNED_INT}}, {{KW|_GL_INT}}, {{KW|_GL_HALF_FLOAT}}, {{KW|_GL_FLOAT}}, {{KW|_GL_UNSIGNED_BYTE_3_3_2}}, {{KW|_GL_UNSIGNED_BYTE_2_3_3_REV}}, {{KW|_GL_UNSIGNED_SHORT_5_6_5}}, {{KW|_GL_UNSIGNED_SHORT_5_6_5_REV}}, {{KW|_GL_UNSIGNED_SHORT_4_4_4_4}}, {{KW|_GL_UNSIGNED_SHORT_4_4_4_4_REV}}, {{KW|_GL_UNSIGNED_SHORT_5_5_5_1}}, {{KW|_GL_UNSIGNED_SHORT_1_5_5_5_REV}}, {{KW|_GL_UNSIGNED_INT_8_8_8_8}}, {{KW|_GL_UNSIGNED_INT_8_8_8_8_REV}}, {{KW|_GL_UNSIGNED_INT_10_10_10_2}}, {{KW|_GL_UNSIGNED_INT_2_10_10_10_REV}}, {{KW|_GL_UNSIGNED_INT_24_8}}, {{KW|_GL_UNSIGNED_INT_10F_11F_11F_REV}}, {{KW|_GL_UNSIGNED_INT_5_9_9_9_REV}}, and {{KW|_GL_FLOAT_32_UNSIGNED_INT_24_8_REV}}.
; img
: Returns the texture image. Should be a pointer to an array of the type specified by {{Parameter|type}}.




{{PageDescription}}
{{PageDescription}}
 
* OpenGL's documentation is available in several places, so we won't reproduce it here for another time.
'''_glGetTexImage''' returns a texture image into {{Parameter|img}}. {{Parameter|target}} specifies whether the desired texture image is one specified by {{KW|_glTexImage1D}} ({{KW|_GL_TEXTURE_1D}}), {{KW|_glTexImage2D}} ({{KW|_GL_TEXTURE_1D_ARRAY}}, {{KW|_GL_TEXTURE_RECTANGLE}}, {{KW|_GL_TEXTURE_2D}} or any of {{KW|_GL_TEXTURE_CUBE_MAP_*}}), or {{KW|_glTexImage3D}} ({{KW|_GL_TEXTURE_2D_ARRAY}}, {{KW|_GL_TEXTURE_3D}}). {{Parameter|level}} specifies the level-of-detail number of the desired image. {{Parameter|format}} and {{Parameter|type}} specify the format and type of the desired image array. See the reference page for {{KW|_glTexImage1D}} for a description of the acceptable values for the {{Parameter|format}} and {{Parameter|type}} parameters, respectively.
* The full description for this command can be found at [https://learn.microsoft.com/en-us/windows/win32/opengl/glgetteximage Microsoft Docs] and is also valid for QB64 usage.
 
If a non-zero named buffer object is bound to the {{KW|_GL_PIXEL_PACK_BUFFER}} target (see {{KW|_glBindBuffer}}) while a texture image is requested, {{Parameter|img}} is treated as a byte offset into the buffer object's data store.
 
To understand the operation of '''_glGetTexImage''', consider the selected internal four-component texture image to be an RGBA color buffer the size of the image. The semantics of '''_glGetTexImage''' are then identical to those of {{KW|_glReadPixels}}, with the exception that no pixel transfer operations are performed, when called with the same {{Parameter|format}} and {{Parameter|type}}, with ''x'' and ''y'' set to 0, ''width'' set to the width of the texture image and ''height'' set to 1 for 1D images, or to the height of the texture image for 2D images.
 
If the selected texture image does not contain four components, the following mappings are applied. Single-component textures are treated as RGBA buffers with red set to the single-component value, green set to 0, blue set to 0, and alpha set to 1. Two-component textures are treated as RGBA buffers with red set to the value of component zero, alpha set to the value of component one, and green and blue set to 0. Finally, three-component textures are treated as RGBA buffers with red set to component zero, green set to component one, blue set to component two, and alpha set to 1.
 
To determine the required size of {{Parameter|img}}, use {{KW|_glGetTexLevelParameter}} to determine the dimensions of the internal texture image, then scale the required number of pixels by the storage required for each pixel, based on {{Parameter|format}} and {{Parameter|type}}. Be sure to take the pixel storage parameters into account, especially {{KW|_GL_PACK_ALIGNMENT}}.
 
 
{{PageNotes}}
 
If an error is generated, no change is made to the contents of {{Parameter|img}}.
 
'''_glGetTexImage''' returns the texture image for the active texture unit.
 
 
{{PageErrors}}
 
{{KW|_GL_INVALID_ENUM}} is generated if {{Parameter|target}}, {{Parameter|format}}, or {{Parameter|type}} is not an accepted value.
 
{{KW|_GL_INVALID_VALUE}} is generated if {{Parameter|level}} is less than 0.
 
{{KW|_GL_INVALID_VALUE}} may be generated if {{Parameter|level}} is greater than log<sub>2</sub>(''max''), where ''max'' is the returned value of {{KW|_GL_MAX_TEXTURE_SIZE}}.
 
{{KW|_GL_INVALID_OPERATION}} is returned if {{Parameter|type}} is one of {{KW|_GL_UNSIGNED_BYTE_3_3_2}}, {{KW|_GL_UNSIGNED_BYTE_2_3_3_REV}}, {{KW|_GL_UNSIGNED_SHORT_5_6_5}}, {{KW|_GL_UNSIGNED_SHORT_5_6_5_REV}}, or {{KW|_GL_UNSIGNED_INT_10F_11F_11F_REV}} and {{Parameter|format}} is not {{KW|_GL_RGB}}.
 
{{KW|_GL_INVALID_OPERATION}} is returned if {{Parameter|type}} is one of {{KW|_GL_UNSIGNED_SHORT_4_4_4_4}}, {{KW|_GL_UNSIGNED_SHORT_4_4_4_4_REV}}, {{KW|_GL_UNSIGNED_SHORT_5_5_5_1}}, {{KW|_GL_UNSIGNED_SHORT_1_5_5_5_REV}}, {{KW|_GL_UNSIGNED_INT_8_8_8_8}}, {{KW|_GL_UNSIGNED_INT_8_8_8_8_REV}}, {{KW|_GL_UNSIGNED_INT_10_10_10_2}}, {{KW|_GL_UNSIGNED_INT_2_10_10_10_REV}}, or {{KW|_GL_UNSIGNED_INT_5_9_9_9_REV}} and {{Parameter|format}} is neither {{KW|_GL_RGBA}} or {{KW|_GL_BGRA}}.
 
{{KW|_GL_INVALID_OPERATION}} is generated if a non-zero buffer object name is bound to the {{KW|_GL_PIXEL_PACK_BUFFER}} target and the buffer object's data store is currently mapped.
 
{{KW|_GL_INVALID_OPERATION}} is generated if a non-zero buffer object name is bound to the {{KW|_GL_PIXEL_PACK_BUFFER}} target and the data would be packed to the buffer object such that the memory writes required would exceed the data store size.
 
{{KW|_GL_INVALID_OPERATION}} is generated if a non-zero buffer object name is bound to the {{KW|_GL_PIXEL_PACK_BUFFER}} target and {{Parameter|img}} is not evenly divisible into the number of bytes needed to store in memory a datum indicated by {{Parameter|type}}.
 
 
{{PageUseWith}}
 
{{KW|_glGetTexLevelParameter}} with argument {{KW|_GL_TEXTURE_WIDTH}}
 
{{KW|_glGetTexLevelParameter}} with argument {{KW|_GL_TEXTURE_HEIGHT}}
 
{{KW|_glGetTexLevelParameter}} with argument {{KW|_GL_TEXTURE_INTERNAL_FORMAT}}
 
{{KW|_glGet}} with arguments {{KW|_GL_PACK_ALIGNMENT}} and others
 
{{KW|_glGet}} with argument {{KW|_GL_PIXEL_PACK_BUFFER_BINDING}}




{{PageSeeAlso}}
{{PageSeeAlso}}
* [[_GL|SUB _GL]]
* [[_glBegin]], [[_glDrawPixels]], [[_glEnd]], [https://learn.microsoft.com/en-us/windows/win32/opengl/glgettexlevelparameter _glGetTexLevelParameter]
* [[_glReadPixels]], [[_glTexImage1D]], [[_glTexImage2D]]


[[_GL|SUB _GL]]
{{KW|_glActiveTexture}}, {{KW|_glBindTexture}}, {{KW|_glPixelStore}}, {{KW|_glReadPixels}}, {{KW|_glTexSubImage1D}}, {{KW|_glTexSubImage2D}}, {{KW|_glTexSubImage3D}}
{{PageCopyright}}


Copyright 1991-2006 Silicon Graphics, Inc. Copyright 2010 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see [http://oss.sgi.com/projects/FreeB/ http://oss.sgi.com/projects/FreeB/].
{{PageNavigation}}

Latest revision as of 01:04, 28 January 2023

The _glGetTexImage statement returns a texture image.


Syntax

_glGetTexImage GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels


Parameters

  • OpenGL is using its own set of variable types to describe its command parameters.
  • Use the following table to find the respective QB64 Variable Types.
   Table 2: Relations between the OpenGL variable types vs. C/C++ and QB64.
 ┌──────────────┬────────────────┬──────────────────────────────────────────┐
 │    OpenGLC/C++QB64                                 │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLenum       │ unsigned int   │ _UNSIGNED LONG                           │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLboolean    │ unsigned char  │ _UNSIGNED _BYTE                          │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLbitfield   │ unsigned int   │ _UNSIGNED LONG                           │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLbyte       │ signed char    │ _BYTE                                    │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLshort      │ short          │ INTEGER                                  │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLint        │ int            │ LONG                                     │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLsizei      │ int            │ LONG                                     │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLubyte      │ unsigned char  │ _UNSIGNED _BYTE                          │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLushort     │ unsigned short │ _UNSIGNED INTEGER                        │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLuint       │ unsigned int   │ _UNSIGNED LONG                           │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLfloat      │ float          │ SINGLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLclampf     │ float          │ SINGLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLdouble     │ double         │ DOUBLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLclampd     │ double         │ DOUBLE                                   │
 ├──────────────┼────────────────┼──────────────────────────────────────────┤
 │ GLvoid   (1) │ void           │ _OFFSET(any fixed lenght string or _BYTE │
 │              │                │         array element)                   │
 └──────────────┴────────────────┴──────────────────────────────────────────┘
 Note: If a parameter has an asterisk (*) in front, then it's a pointer to
       the designated OpenGL variable type, rather than a value of that type.
       Those must be passed using the _OFFSET(...) notation.

 E.g.  GLuint *anyParam is actually the offset of a _UNSIGNED LONG (~&)
       variable or array, which must be passed as _OFFSET(anyVar~&) or
       _OFFSET(anyArr~&()) respectively.

  (1)  This type is regularly only used for pointers (with asterisk (*)) to
       any byte sized memory data, hence _BYTE or fixed length strings.


Description

  • OpenGL's documentation is available in several places, so we won't reproduce it here for another time.
  • The full description for this command can be found at Microsoft Docs and is also valid for QB64 usage.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link