PrevUpHomeNext

Textures

#include <oglplus/texture.hpp>

Subtype

template <>
struct ObjectSubtype<tag::Texture>
{
	typedef TextureTarget Type;
};

Common texture operations

template <>
class ObjCommonOps<tag::Texture>
 : public TextureName
{
public:
	typedef TextureTarget Target; 1

	static TextureName Binding(TextureTarget target); 2
	static void Bind(TextureTarget target, TextureName texture); 3

	void Bind(TextureTarget target) const; 4

#if GL_VERSION_4_2 ||GL_ARB_shader_image_load_store
	static void BindImage(
		ImageUnitSelector unit,
		TextureName texture,
		GLint level,
		Boolean layered,
		GLint layer,
		AccessSpecifier access,
		ImageUnitFormat format
	); 5
#endif

#if GL_VERSION_4_4 || GL_ARB_multi_bind
	static void Bind(
		GLuint first,
		const Sequence<TextureName>& textures
	); 6

	static void BindImage(
		GLuint first,
		const Sequence<TextureName>& textures
	); 7
#endif

	static void Active(TextureUnitSelector index); 8

	static GLint Active(void); 9

	static TextureTarget CubeMapFace(GLuint face); 10

#if GL_VERSION_4_3
	void InvalidateImage(SizeType level); 11

	void InvalidateSubImage(
		SizeType level,
		GLint xoffs,
		GLint yoffs,
		GLint zoffs,
		SizeType width,
		SizeType height,
		SizeType depth
	); 12
#endif

#if GL_VERSION_4_4
	template <typename GLtype>
	void ClearImage(
		SizeType level,
		PixelDataFormat format,
		const GLtype* data
	); 13

	template <typename GLtype>
	void ClearSubImage(
		SizeType level,
		GLint xoffs,
		GLint yoffs,
		GLint zoffs,
		SizeType width,
		SizeType height,
		SizeType depth,
		PixelDataFormat format,
		const GLtype* data
	); 14
#endif

#if GL_VERSION_4_3 || GL_ARB_texture_view
	void View(
		TextureTarget target,
		TextureName orig_texture,
		PixelDataInternalFormat internal_format,
		GLuint min_level,
		GLuint num_levels,
		GLuint min_layer,
		GLuint num_layers
	); 15
#endif
};

1

Texture bind target.

2

Returns the texture currently bound to the specified target. See glGetIntegerv.

3

Binds the specified texture to the specified target. See glBindTexture.

4

Binds this texture to the specified target. See glBindTexture.

5

Binds a level of texture to an image unit. See glBindTextureImage.

6

Sequentially binds textures to texture units starting with first. See glBindTextures.

7

Sequentially binds textures to image units starting with first. See glBindImageTextures.

8

Specifies active texture unit for subsequent commands. See glActiveTexture.

9

Returns the currently active texture unit. See glGet, GL_ACTIVE_TEXTURE.

10

Returns one of the values for cube map faces from the TextureTarget enumeration. The value of face must be between 0 and 5 with the following meaning:

11

Invalidates the specified level of texture image. See glInvalidateTexImage.

12

Invalidates the specified part of texture image. See glInvalidateTexSubImage.

13

Clears the specified level of texture image. See glClearTexImage.

14

Clears the specified part of texture image. See glClearTexSubImage.

15

References and reinteprets a subset of the data of another texture. See glTextureView.

Operations with explicit selector

template <>
class ObjectOps<tag::ExplicitSel, tag::Texture>
 : public ObjZeroOps<tag::ExplicitSel, tag::Texture> 1
{
public:
	struct Property
	{
		typedef TextureCompareMode CompareMode;

		typedef TextureFilter Filter;

		typedef TextureMagFilter MagFilter;

		typedef TextureMinFilter MinFilter;

		typedef TextureSwizzleCoord SwizzleCoord;

		typedef TextureSwizzle Swizzle;

#if GL_VERSION_3_3 || GL_ARB_texture_swizzle
		typedef TextureSwizzleTuple SwizzleTuple;
#endif
		typedef TextureWrapCoord WrapCoord;

		typedef TextureWrap Wrap;

		typedef OneOf<
			DataType,
			PixelDataType
		> PixDataType;
	};

#if GL_VERSION_3_0
	static
	SizeType Width(TextureTarget target, GLint level = 0); 2

	static
	SizeType Height(TextureTarget target, GLint level = 0); 3

	static
	SizeType Depth(TextureTarget target, GLint level = 0); 4

	static
	PixelDataType RedType(TextureTarget target, GLint level = 0); 5

	static
	PixelDataType GreenType(TextureTarget target, GLint level = 0); 6

	static
	PixelDataType BlueType(TextureTarget target, GLint level = 0); 7

	static
	PixelDataType AlphaType(TextureTarget target, GLint level = 0); 8

	static
	PixelDataType DepthType(TextureTarget target, GLint level = 0); 9

	static
	SizeType RedSize(TextureTarget target, GLint level = 0); 10

	static
	SizeType GreenSize(TextureTarget target, GLint level = 0); 11

	static
	SizeType BlueSize(TextureTarget target, GLint level = 0); 12

	static
	SizeType AlphaSize(TextureTarget target, GLint level = 0); 13

	static
	SizeType DepthSize(TextureTarget target, GLint level = 0); 14

	static
	SizeType StencilSize(TextureTarget target, GLint level = 0); 15

	static
	SizeType SharedSize(TextureTarget target, GLint level = 0); (16)

1

Indirectly inherits from ObjCommonOps<tag::Texture>.

2

Returns the width of the texture image on the specified level. See glGetTexLevelParameter, GL_TEXTURE_WIDTH.

3

Returns the height of the texture image on the specified level. See glGetTexLevelParameter, GL_TEXTURE_HEIGHT.

4

Returns the depth of the texture image on the specified level. See glGetTexLevelParameter, GL_TEXTURE_DEPTH.

5

Returns the data type used to store the RED component. See glGetTexLevelParameter, GL_TEXTURE_RED_TYPE.

6

Returns the data type used to store the GREEN component. See glGetTexLevelParameter, GL_TEXTURE_GREEN_TYPE.

7

Returns the data type used to store the BLUE component. See glGetTexLevelParameter, GL_TEXTURE_BLUE_TYPE.

8

Returns the data type used to store the ALPHA component. See glGetTexLevelParameter, GL_TEXTURE_ALPHA_TYPE.

9

Returns the data type used to store the DEPTH component. See glGetTexLevelParameter, GL_TEXTURE_DEPTH_TYPE.

10

Returns the actual resolution of the RED component. See glGetTexLevelParameter, GL_TEXTURE_RED_SIZE.

11

Returns the actual resolution of the GREEN component. See glGetTexLevelParameter, GL_TEXTURE_GREEN_SIZE.

12

Returns the actual resolution of the BLUE component. See glGetTexLevelParameter, GL_TEXTURE_BLUE_SIZE.

13

Returns the actual resolution of the ALPHA component. See glGetTexLevelParameter, GL_TEXTURE_ALPHA_SIZE.

14

Returns the actual resolution of the DEPTH component. See glGetTexLevelParameter, GL_TEXTURE_DEPTH_SIZE.

15

Returns the actual resolution of the STENCIL component. See glGetTexLevelParameter, GL_TEXTURE_STENCIL_SIZE.

(16)

Returns the actual resolution of all texture components. See glGetTexLevelParameter, GL_TEXTURE_SHARED_SIZE.

	static
	SizeType CompressedImageSize(TextureTarget target, GLint level = 0); 1

	static
	PixelDataInternalFormat InternalFormat(TextureTarget target, GLint level = 0); 2

	static void GetImage(
		TextureTarget target,
		GLint level,
		PixelDataFormat format,
		const OutputData& dest
	); 3
	static void GetImage(
		TextureTarget target,
		GLint level,
		PixelDataFormat format,
		Property::PixDataType type,
		SizeType size,
		GLvoid* buffer
	);

	static void GetCompressedImage(
		TextureTarget target,
		GLint level,
		const OutputData& dest
	); 4
	static void GetCompressedImage(
		TextureTarget target,
		GLint level,
		std::vector<GLubyte>& dest
	);
	static void GetCompressedImage(
		TextureTarget target,
		GLint level,
		SizeType size,
		GLubyte* buffer
	);
#endif
	static void Image3D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		SizeType depth,
		GLint border,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	); 5

	static void Image3D(
		TextureTarget target,
		const images::Image& image,
		GLint level = 0,
		GLint border = 0
	);

	static void SubImage3D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint yoffs,
		GLint zoffs,
		SizeType width,
		SizeType height,
		SizeType depth,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	); 6

	static void SubImage3D(
		TextureTarget target,
		const images::Image& image,
		GLint xoffs,
		GLint yoffs,
		GLint zoffs,
		GLint level = 0
	);

	static void Image2D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		GLint border,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	); 7

	static void Image2D(
		TextureTarget target,
		const images::Image& image,
		GLint level = 0,
		GLint border = 0
	);

	static void ImageCM(
		GLuint face,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		GLint border,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	); 8

	static void ImageCM(
		GLuint face,
		const images::Image& image,
		GLint level = 0,
		GLint border = 0
	);

	static void SubImage2D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint yoffs,
		SizeType width,
		SizeType height,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	); 9

	static void SubImage2D(
		TextureTarget target,
		const images::Image& image,
		GLint xoffs,
		GLint yoffs,
		GLint level = 0
	);

#if GL_VERSION_3_0
	static void Image1D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		GLint border,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	); 10

	static void Image1D(
		TextureTarget target,
		const images::Image& image,
		GLint level = 0,
		GLint border = 0
	);

	static void SubImage1D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		SizeType width,
		PixelDataFormat format,
		Property::PixDataType type,
		const void* data
	);  11

	static void SubImage1D(
		TextureTarget target,
		const images::Image& image,
		GLint xoffs,
		GLint level = 0
	);
#endif

	static void Image(
		TextureTarget target,
		const images::Image& image,
		GLint level = 0,
		GLint border = 0
	); 12

	static void Image(
		TextureTarget target,
		const images::ImageSpec& image_spec,
		GLint level = 0,
		GLint border = 0
	);

1

Returns the size (in bytes) of the image array if it is compressed. See glGetTexLevelParameter, GL_TEXTURE_COMPRESSED_IMAGE_SIZE.

2

Returns the internal data format of the image array. See glGetTexLevelParameter, GL_TEXTURE_INTERNAL_FORMAT.

3

Stores the image of the texture bound to the specified texture target with the specified level of detail in uncompressed form into the dest buffer. See glGetTexImage.

[Note] Note

This function, unlike GetCompressedImage, does NOT automatically resize the destination buffer so that it can accomodate the texture data. The caller is responsible for keeping track or querying the type of the texture, its dimensions and current pixel transfer settings and resize the dest buffer accordingly.

4

Stores the image of the texture bound to the specified texture target with the specified level of detail in compressed form into the dest buffer. See glGetCompressedTexImage. This function automatically resizes the buffer so that it can accomodate the texture data.

5

Specifies a three dimensional texture image. See glTexImage3D.

6

Specifies a three dimensional texture subimage. See glTexSubImage3D.

7

Specifies a two dimensional texture image. See glTexImage2D.

8

Specifies the image of the selected cube-map face. See glTexImage2D.

9

Specifies a two dimensional texture subimage. See glTexSubImage2D.

10

Specifies a one dimensional texture image. See glTexImage1D.

11

Specifies a one dimensional texture subimage. See glTexSubImage1D.

12

Specifies one, two or three dimensional texture image.

	static void CopyImage2D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		GLint x,
		GLint y,
		SizeType width,
		SizeType height,
		GLint border
	); 1

#if GL_VERSION_3_0
	static void CopyImage1D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		GLint x,
		GLint y,
		SizeType width,
		GLint border
	); 2
#endif

	static void CopySubImage3D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint yoffs,
		GLint zoffs,
		GLint x,
		GLint y,
		SizeType width,
		SizeType height
	); 3

	static void CopySubImage2D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint yoffs,
		GLint x,
		GLint y,
		SizeType width,
		SizeType height
	); 4

#if GL_VERSION_3_0
	static void CopySubImage1D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint x,
		GLint y,
		SizeType width
	); 5
#endif

	static void CompressedImage3D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		SizeType depth,
		GLint border,
		SizeType image_size,
		const void* data
	); 6

	static void CompressedImage2D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		GLint border,
		SizeType image_size,
		const void* data
	); 7

#if GL_VERSION_3_0
	static void CompressedImage1D(
		TextureTarget target,
		GLint level,
		PixelDataInternalFormat internal_format,
		SizeType width,
		GLint border,
		SizeType image_size,
		const void* data
	); 8
#endif

	static void CompressedSubImage3D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint yoffs,
		GLint zoffs,
		SizeType width,
		SizeType height,
		SizeType depth,
		PixelDataFormat format,
		SizeType image_size,
		const void* data
	); 9

	static void CompressedSubImage2D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		GLint yoffs,
		SizeType width,
		SizeType height,
		PixelDataFormat format,
		SizeType image_size,
		const void* data
	); 10

#if GL_VERSION_3_0
	static void CompressedSubImage1D(
		TextureTarget target,
		GLint level,
		GLint xoffs,
		SizeType width,
		PixelDataFormat format,
		SizeType image_size,
		const void* data
	); 11
#endif

1

Copies a two dimensional texture image from the current framebuffer. See glCopyTexImage2D.

2

Copies a one dimensional texture image from the current framebuffer. See glCopyTexImage1D.

3

Copies a three dimensional texture subimage from the current framebuffer. See glCopyTexSubImage3D.

4

Copies a two dimensional texture subimage from the current framebuffer. See glCopyTexSubImage2D.

5

Copies a one dimensional texture subimage from the current framebuffer. See glCopyTexSubImage2D.

6

Specifies a three dimensional compressed texture image. See glCompressedTexImage3D.

7

Specifies a two dimensional compressed texture image. See glCompressedTexImage2D.

8

Specifies a one dimensional compressed texture image. See glCompressedTexImage1D.

9

Specifies a three dimensional compressed texture subimage. See glCompressedTexSubImage3D.

10

Specifies a two dimensional compressed texture subimage. See glCompressedTexSubImage2D.

11

Specifies a one dimensional compressed texture subimage. See glCompressedTexSubImage1D.

#if GL_VERSION_3_2 || GL_ARB_texture_multisample
	static void Image3DMultisample(
		TextureTarget target,
		SizeType samples,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		SizeType depth,
		Boolean fixed_sample_locations
	); 1

	static void Image2DMultisample(
		TextureTarget target,
		SizeType samples,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		Boolean fixed_sample_locations
	); 2

#endif

#if GL_VERSION_3_1
	static void Buffer(
		TextureTarget target,
		PixelDataInternalFormat internal_format,
		BufferName buffer
	); 3
#endif

#if GL_VERSION_4_3
	static void BufferRange(
		TextureTarget target,
		PixelDataInternalFormat internal_format,
		BufferName buffer,
		GLintptr offset,
		BigSizeType size
	); 4
#endif

#if GL_VERSION_4_2 || GL_ARB_texture_storage
	static void Storage3D(
		TextureTarget target,
		SizeType levels,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height,
		SizeType depth
	); 5

	static void Storage2D(
		TextureTarget target,
		SizeType levels,
		PixelDataInternalFormat internal_format,
		SizeType width,
		SizeType height
	); 6

	static void Storage1D(
		TextureTarget target,
		SizeType levels,
		PixelDataInternalFormat internal_format,
		SizeType width
	); 7
#endif
	static GLuint BaseLevel(TextureTarget target); 8

	static void BaseLevel(TextureTarget target, GLuint level); 9

#if GL_VERSION_3_0
	static Vector<GLfloat, 4> BorderColor(
		TextureTarget target,
		TypeTag<GLfloat>
	); 10
	static Vector<GLint, 4> BorderColor(
		TextureTarget target,
		TypeTag<GLint>
	);
	static Vector<GLuint, 4> BorderColor(
		TextureTarget target,
		TypeTag<GLuint>
	);

	static void BorderColor(
		TextureTarget target,
		Vector<GLfloat, 4> color
	); 11
	static void BorderColor(
		TextureTarget target,
		Vector<GLint, 4> color
	);
	static void BorderColor(
		TextureTarget target,
		Vector<GLuint, 4> color
	);
#endif
	static TextureCompareMode CompareMode(TextureTarget target); 12

	static void CompareMode(
		TextureTarget target,
		TextureCompareMode mode
	); 13

	static CompareFunction CompareFunc(TextureTarget target); 14

	static void CompareFunc(
		TextureTarget target,
		CompareFunction func
	); 15

1

Sets-up a three dimensional multisample texture. See glTexImage3DMultisample.

2

Sets-up a two dimensional multisample texture. See glTexImage3DMultisample.

3

Assigns a buffer storing the texel data to the texture. See glTexBuffer.

4

Assigns a buffer range storing the texel data to the texture. See glTexBufferRange.

5

Specifies all levels of 3D texture at the same time. See glTexStorage3D.

6

Specifies all levels of 2D texture at the same time. See glTexStorage2D.

7

Specifies all levels of 1D texture at the same time. See glTexStorage1D.

8

Returns the texture base level. See glGetTexParameter, GL_TEXTURE_BASE_LEVEL.

9

Sets the texture base level. See glTexParameter, GL_TEXTURE_BASE_LEVEL.

10

Gets the texture border color. See glGetTexParameter, GL_TEXTURE_BORDER_COLOR.

11

Sets the texture border color. See glTexParameter, GL_TEXTURE_BORDER_COLOR.

12

Gets the texture compare mode. See glGetTexParameter, GL_TEXTURE_COMPARE_MODE.

13

Sets the texture compare mode. See glTexParameter, GL_TEXTURE_COMPARE_MODE.

14

Gets the texture compare function. See glGetTexParameter, GL_TEXTURE_COMPARE_FUNC.

15

Sets the texture compare function. See glTexParameter, GL_TEXTURE_COMPARE_FUNC.

#if GL_VERSION_3_0
	static GLfloat LODBias(TextureTarget target); 1

	static void LODBias(TextureTarget target, GLfloat value); 2
#endif // GL_VERSION_3_0

	static void Filter(
		TextureTarget target,
		TextureFilter filter
	); 3

	static TextureMagFilter MagFilter(TextureTarget target); 4

	static void MagFilter(
		TextureTarget target,
		TextureMagFilter filter
	); 5

	static TextureMinFilter MinFilter(TextureTarget target); 6

	static void MinFilter(
		TextureTarget target,
		TextureMinFilter filter
	); 7

	static GLfloat MinLOD(TextureTarget target); 8

	static void MinLOD(TextureTarget target, GLfloat value); 9

	static GLfloat MaxLOD(TextureTarget target); 10

	static void MaxLOD(TextureTarget target, GLfloat value); 11

	static GLint MaxLevel(TextureTarget target); 12

	static void MaxLevel(TextureTarget target, GLint value); 13

1

Gets the level-of-detail bias value. See glGetTexParameter, GL_TEXTURE_LOD_BIAS.

2

Sets the level-of-detail bias value. See glTexParameter, GL_TEXTURE_LOD_BIAS.

3

Sets both the minification and magnification filter. See glTexParameter, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER.

4

Gets the magnification filter. See glGetTexParameter, GL_TEXTURE_MAG_FILTER.

5

Sets the magnification filter. See glTexParameter, GL_TEXTURE_MAG_FILTER.

6

Gets the minification filter. See glGetTexParameter, GL_TEXTURE_MIN_FILTER.

7

Sets the minification filter. See glTexParameter, GL_TEXTURE_MIN_FILTER.

8

Gets minimal level-of-detail value. See glGetTexParameter, GL_TEXTURE_MIN_LOD.

9

Sets minimal level-of-detail value. See glTexParameter, GL_TEXTURE_MIN_LOD.

10

Gets maximal level-of-detail value. See glGetTexParameter, GL_TEXTURE_MAX_LOD.

11

Sets maximal level-of-detail value. See glTexParameter, GL_TEXTURE_MAX_LOD.

12

Gets the maximum level value. See glGetTexParameter, GL_TEXTURE_MAX_LEVEL.

13

Sets the maximum level value. See glTexParameter, GL_TEXTURE_MAX_LEVEL.

	static GLfloat MaxAnisotropy(TextureTarget target); 1

	static GLfloat Anisotropy(TextureTarget target); 2

	static void Anisotropy(TextureTarget target, GLfloat value); 3

#if GL_VERSION_3_3 || GL_ARB_texture_swizzle
	static TextureSwizzle Swizzle(
		TextureTarget target,
		TextureSwizzleCoord coord
	); 4
	static TextureSwizzle SwizzleR(TextureTarget target);
	static TextureSwizzle SwizzleG(TextureTarget target);
	static TextureSwizzle SwizzleB(TextureTarget target);
	static TextureSwizzle SwizzleA(TextureTarget target);
	static TextureSwizzleTuple SwizzleRGBA(TextureTarget target);

	static void Swizzle(
		TextureTarget target,
		TextureSwizzleCoord coord,
		TextureSwizzle mode
	); 5
	static void SwizzleR(TextureTarget target, TextureSwizzle mode);
	static void SwizzleG(TextureTarget target, TextureSwizzle mode);
	static void SwizzleB(TextureTarget target, TextureSwizzle mode);
	static void SwizzleA(TextureTarget target, TextureSwizzle mode);
	static void SwizzleRGBA(
		TextureTarget target,
		TextureSwizzle mode
	);
	static void SwizzleRGBA(
		TextureTarget target,
		TextureSwizzle mode_r,
		TextureSwizzle mode_g,
		TextureSwizzle mode_b,
		TextureSwizzle mode_a
	);
	static void SwizzleRGBA(
		TextureTarget target,
		const TextureSwizzleTuple& modes
	);
#endif

	static TextureWrap Wrap(
		TextureTarget target,
		TextureWrapCoord coord
	); 6
	static TextureWrap WrapS(TextureTarget target);
	static TextureWrap WrapT(TextureTarget target);
	static TextureWrap WrapR(TextureTarget target);


	static void Wrap(
		TextureTarget target,
		TextureWrapCoord coord,
		TextureWrap mode
	); 7
	static void WrapS(TextureTarget target, TextureWrap mode);
	static void WrapT(TextureTarget target, TextureWrap mode);
	static void WrapR(TextureTarget target, TextureWrap mode);

	static void Wrap(TextureTarget target, TextureWrap mode); 8

#if GL_VERSION_4_3
	static PixelDataFormat DepthStencilMode(TextureTarget target); 9

	static void DepthStencilMode(
		TextureTarget target,
		PixelDataFormat mode
	); 10
#endif

#if GL_ARB_seamless_cubemap_per_texture
	static Boolean Seamless(TextureTarget target); 11

	static void Seamless(TextureTarget target, Boolean enable); 12
#endif

#if GL_VERSION_4_5 || GL_ARB_texture_barrier || GL_NV_texture_barrier
	static void Barrier(void); 13
#endif

	static void GenerateMipmap(TextureTarget target) 14
};

1

Gets the maximum anisotropy value. See glTexParameter, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT.

2

Gets the current anisotropy level. See glGetTexParameter, GL_TEXTURE_MAX_ANISOTROPY_EXT.

3

Sets the anisotropy level. See glTexParameter, GL_TEXTURE_MAX_ANISOTROPY_EXT.

4

Gets the swizzle parameter. See glGetTexParameter, GL_TEXTURE_SWIZZLE_R, GL_TEXTURE_SWIZZLE_G, GL_TEXTURE_SWIZZLE_B, GL_TEXTURE_SWIZZLE_A, GL_TEXTURE_SWIZZLE_RGBA.

5

Sets the swizzle parameter. See glTexParameter, GL_TEXTURE_SWIZZLE_R, GL_TEXTURE_SWIZZLE_G, GL_TEXTURE_SWIZZLE_B, GL_TEXTURE_SWIZZLE_A, GL_TEXTURE_SWIZZLE_RGBA.

6

Gets the texture wrap parameter. See glGetTexParameter, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_TEXTURE_WRAP_R.

7

Sets the texture wrap mode on the specified coordinate. See glTexParameter, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_TEXTURE_WRAP_R.

8

Sets the texture wrap mode on all coordinates meaningful for the specified texture target.

9

Gets the depth stencil mode parameter. See glGetTexParameter, GL_DEPTH_STENCIL_TEXTURE_MODE.

10

Sets the depth stencil mode parameter. See glTexParameter, GL_DEPTH_STENCIL_TEXTURE_MODE.

11

Gets the seamless cubemap setting value. See glGetTexParameter, GL_TEXTURE_CUBE_MAP_SEAMLESS.

12

Changes the seamless cubemap setting value. See glTexParameter, GL_TEXTURE_CUBE_MAP_SEAMLESS.

13

Ensures that texture writes have been completed. See glTextureBarrier.

14

Generates mipmap for the texture bound to the specified target. See glGenerateMipmap.

Definition

typedef ObjectOps<tag::ExplicitSel, tag::Texture>
	TextureOps;

typedef Object<TextureOps> Texture;

typedef ObjectZero<ObjZeroOps<tag::ExplicitSel, tag::Texture>> 1
	DefaultTexture;

1

Indirectly inherits from ObjCommonOps<tag::Texture>.

Syntax sugar

struct TextureTargetAndSlot { }; 1

TextureTargetAndSlot operator | (
	TextureTarget target,
	GLuint slot
);

struct TextureUnitAndTarget { }; 2

TextureUnitAndTarget operator | (
	TextureUnitSelector unit,
	TextureTarget tex
);

TextureTarget operator << (
	const TextureOps& tex,
	TextureTarget target
); 3

TextureTarget operator << (
	TextureTarget target,
	TextureFilter filter
); 4

TextureTarget operator << (
	TextureTarget target,
	TextureMinFilter filter
); 5

TextureTarget operator << (
	TextureTarget target,
	TextureMagFilter filter
); 6

TextureTarget operator << (
	TextureTarget target,
	TextureCompareMode mode
); 7

TextureTarget operator << (
	TextureTarget target,
	CompareFunction func
); 8

1

Helper class used with syntax-sugar operators. Stores a texture target and an integer slot number. Depending on the context the slot may be interpreted as the swizzle or wrap coordinate or image level number.

2

Helper class used with syntax-sugar operators. Stores a texture unit number and a texture target.

3

Binds a texture object to the specified target.

4

Sets texture minification and magnification filter on the texture currently bound to target.

5

Sets a texture minification filter on the texture currently bound to target.

6

Sets a texture magification filter on the texture currently bound to target.

7

Sets a texture compare mode on the texture currently bound to target.

8

Sets a texture compare function on the texture currently bound to target.

TextureTarget operator << (
	TextureTarget target,
	TextureWrap wrap
); 1

TextureTargetAndSlot operator << (
	TextureTargetAndSlot tas,
	TextureWrap wrap
); 2

#if GL_VERSION_3_3 || GL_ARB_texture_swizzle
TextureTarget operator << (
	TextureTarget target,
	TextureSwizzle swizzle
); 3

TextureTargetAndSlot operator << (
	TextureTargetAndSlot tas,
	TextureSwizzle swizzle
); 4

#endif

#if GL_VERSION_3_0
template <typename T>
TextureTarget operator << (
	TextureTarget target,
	const Vector<T, 4>& col
); 5
#endif

TextureTarget operator << (
	TextureTarget target,
	const images::Image& image
); 6

TextureTarget operator << (
	TextureTarget target,
	const images::ImageSpec& image_spec
);

TextureTarget operator << (
	TextureTargetAndSlot tas,
	const images::Image& image
); 7

TextureTarget operator << (
	TextureTargetAndSlot tas,
	const images::ImageSpec& image_spec
);

struct TextureMipmap { }; 8

TextureTarget operator << (
	TextureTarget target,
	TextureMipmap
); 9

1

Sets a texture wrap mode on the texture currently bound to target on all texture dimensions.

2

Sets a texture wrap mode on the texture currently bound to target on the dimension specified by the slot number in tas.

3

Sets a texture swizzle mode on the texture currently bound to target on all texture dimensions.

4

Sets a texture swizzle mode on the texture currently bound to target on the dimension specified by the slot number in tas.

5

Sets a texture border color on the texture currently bound to target.

6

Specifies the level 0 texture image on the texture currently bound to target.

7

Specifies the texture image on the level specified by the slot number in tas of the texture currently bound to target.

8

Helper class used with syntax-sugar operators. Selects the GenerateMipmap member function.

9

Generates mipmap on the texture currently bound to target.

Target

#include <oglplus/texture_target.hpp>

enum class TextureTarget : GLenum
{
	_1D                 = GL_TEXTURE_1D,
	_2D                 = GL_TEXTURE_2D,
	_3D                 = GL_TEXTURE_3D,
	_1DArray            = GL_TEXTURE_1D_ARRAY,
	_2DArray            = GL_TEXTURE_2D_ARRAY,
	Rectangle           = GL_TEXTURE_RECTANGLE,
	Buffer              = GL_TEXTURE_BUFFER,
	CubeMap             = GL_TEXTURE_CUBE_MAP,
	CubeMapArray        = GL_TEXTURE_CUBE_MAP_ARRAY,
	_2DMultisample      = GL_TEXTURE_2D_MULTISAMPLE,
	_2DMultisampleArray = GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
	CubeMapPositiveX    = GL_TEXTURE_CUBE_MAP_POSITIVE_X,
	CubeMapNegativeX    = GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
	CubeMapPositiveY    = GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
	CubeMapNegativeY    = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
	CubeMapPositiveZ    = GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
	CubeMapNegativeZ    = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};

template <>
Range<TextureTarget> EnumValueRange<TextureTarget>(void);

StrCRef EnumValueName(TextureTarget);

Target to class

#if !OGLPLUS_NO_ENUM_VALUE_CLASSES
namespace enums {

template <typename Base, template<TextureTarget> class Transform>
class EnumToClass<Base, TextureTarget, Transform> 1
 : public Base
{
public:
	EnumToClass(void);
	EnumToClass(Base&& base);

	Transform<TextureTarget::_1D>
		_1D;
	Transform<TextureTarget::_2D>
		_2D;
	Transform<TextureTarget::_3D>
		_3D;
	Transform<TextureTarget::_1DArray>
		_1DArray;
	Transform<TextureTarget::_2DArray>
		_2DArray;
	Transform<TextureTarget::Rectangle>
		Rectangle;
	Transform<TextureTarget::Buffer>
		Buffer;
	Transform<TextureTarget::CubeMap>
		CubeMap;
	Transform<TextureTarget::CubeMapArray>
		CubeMapArray;
	Transform<TextureTarget::_2DMultisample>
		_2DMultisample;
	Transform<TextureTarget::_2DMultisampleArray>
		_2DMultisampleArray;
	Transform<TextureTarget::CubeMapPositiveX>
		CubeMapPositiveX;
	Transform<TextureTarget::CubeMapNegativeX>
		CubeMapNegativeX;
	Transform<TextureTarget::CubeMapPositiveY>
		CubeMapPositiveY;
	Transform<TextureTarget::CubeMapNegativeY>
		CubeMapNegativeY;
	Transform<TextureTarget::CubeMapPositiveZ>
		CubeMapPositiveZ;
	Transform<TextureTarget::CubeMapNegativeZ>
		CubeMapNegativeZ;
};

} // namespace enums
#endif

1

Specialization of EnumToClass for the TextureTarget enumeration.

Compare mode

#include <oglplus/texture_compare.hpp>

enum class TextureCompareMode : GLenum
{
	None                = GL_NONE,
	CompareRefToTexture = GL_COMPARE_REF_TO_TEXTURE
};

template <>
Range<TextureCompareMode> EnumValueRange<TextureCompareMode>(void);

StrCRef EnumValueName(TextureCompareMode);

Minification and magnification filters

#include <oglplus/texture_filter.hpp>

enum class TextureFilter : GLenum
{
	Nearest = GL_NEAREST,
	Linear  = GL_LINEAR
};

template <>
Range<TextureFilter> EnumValueRange<TextureFilter>(void);

StrCRef EnumValueName(TextureFilter);
enum class TextureMinFilter : GLenum
{
	Nearest              = GL_NEAREST,
	Linear               = GL_LINEAR,
	NearestMipmapNearest = GL_NEAREST_MIPMAP_NEAREST,
	NearestMipmapLinear  = GL_NEAREST_MIPMAP_LINEAR,
	LinearMipmapNearest  = GL_LINEAR_MIPMAP_NEAREST,
	LinearMipmapLinear   = GL_LINEAR_MIPMAP_LINEAR
};

template <>
Range<TextureMinFilter> EnumValueRange<TextureMinFilter>(void);

StrCRef EnumValueName(TextureMinFilter);
enum class TextureMagFilter : GLenum
{
	Nearest = GL_NEAREST,
	Linear  = GL_LINEAR
};

template <>
Range<TextureMagFilter> EnumValueRange<TextureMagFilter>(void);

StrCRef EnumValueName(TextureMagFilter);

Swizzle coordinate

#include <oglplus/texture_swizzle.hpp>

enum class TextureSwizzleCoord : GLenum
{
	R    = GL_TEXTURE_SWIZZLE_R,
	G    = GL_TEXTURE_SWIZZLE_G,
	B    = GL_TEXTURE_SWIZZLE_B,
	A    = GL_TEXTURE_SWIZZLE_A,
	RGBA = GL_TEXTURE_SWIZZLE_RGBA
};

template <>
Range<TextureSwizzleCoord> EnumValueRange<TextureSwizzleCoord>(void);

StrCRef EnumValueName(TextureSwizzleCoord);

Swizzle mode

#include <oglplus/texture_swizzle.hpp>

enum class TextureSwizzle : GLenum
{
	Red   = GL_RED,
	Green = GL_GREEN,
	Blue  = GL_BLUE,
	Alpha = GL_ALPHA,
	Zero  = GL_ZERO,
	One   = GL_ONE
};

template <>
Range<TextureSwizzle> EnumValueRange<TextureSwizzle>(void);

StrCRef EnumValueName(TextureSwizzle);

Swizzle tuple

#include <oglplus/texture_swizzle.hpp>

#if GL_VERSION_3_3 || GL_ARB_texture_swizzle
class TextureSwizzleTuple
{
public:
	TextureSwizzleTuple(void); 1

	TextureSwizzleTuple(
		TextureSwizzle mode_r,
		TextureSwizzle mode_g,
		TextureSwizzle mode_b,
		TextureSwizzle mode_a
	); 2

	TextureSwizzleTuple& SwizzleR(TextureSwizzle mode); 3
	TextureSwizzleTuple& Red(TextureSwizzle mode);
	TextureSwizzle SwizzleR(void) const; 4
	TextureSwizzle Red(void) const;

	TextureSwizzleTuple& SwizzleG(TextureSwizzle mode); 5
	TextureSwizzleTuple& Green(TextureSwizzle mode);
	TextureSwizzle SwizzleG(void) const; 6
	TextureSwizzle Green(void) const;

	TextureSwizzleTuple& SwizzleB(TextureSwizzle mode); 7
	TextureSwizzleTuple& Blue(TextureSwizzle mode);
	TextureSwizzle SwizzleB(void) const; 8
	TextureSwizzle Blue(void) const;

	TextureSwizzleTuple& SwizzleA(TextureSwizzle mode); 9
	TextureSwizzleTuple& Alpha(TextureSwizzle mode);
	TextureSwizzle SwizzleA(void) const; 10
	TextureSwizzle Alpha(void) const;

	TextureSwizzleTuple& Swizzle(
		TextureSwizzleCoord coordinate,
		TextureSwizzle mode
	); 11
	TextureSwizzle Swizzle(TextureSwizzleCoord coordinate) const; 12
};
#endif

1

No swizzling.

2

Specifies modes for all texture components/coordinates.

3

Sets the swizzle value for the red component.

4

Returns the swizzle value for the red component.

5

Sets the swizzle value for the green component.

6

Returns the swizzle value for the green component.

7

Sets the swizzle value for the blue component.

8

Returns the swizzle value for the blue component.

9

Sets the swizzle value for the alpha component.

10

Returns the swizzle value for the alpha component.

11

Sets the swizzle mode for the specified coordinate.

12

Returns the swizzle mode for the specified coordinate.

Wrap coordinate

#include <oglplus/texture_wrap.hpp>

enum class TextureWrapCoord : GLenum
{
	S = GL_TEXTURE_WRAP_S,
	T = GL_TEXTURE_WRAP_T,
	R = GL_TEXTURE_WRAP_R
};

template <>
Range<TextureWrapCoord> EnumValueRange<TextureWrapCoord>(void);

StrCRef EnumValueName(TextureWrapCoord);

Wrap mode

#include <oglplus/texture_wrap.hpp>

enum class TextureWrap : GLenum
{
	ClampToEdge       = GL_CLAMP_TO_EDGE,
	Repeat            = GL_REPEAT,
	ClampToBorder     = GL_CLAMP_TO_BORDER,
	MirroredRepeat    = GL_MIRRORED_REPEAT,
	MirrorClampToEdge = GL_MIRROR_CLAMP_TO_EDGE
};

template <>
Range<TextureWrap> EnumValueRange<TextureWrap>(void);

StrCRef EnumValueName(TextureWrap);

Unit selector

#include <oglplus/texture_unit.hpp>

class TextureUnitSelector
 : public LimitedCount<GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS>
{
public:
	TextureUnitSelector(GLuint number); 1
};

#if GL_VERSION_4_2 || GL_ARB_shader_image_load_store
class ImageUnitSelector
 : public LimitedCount<GL_MAX_IMAGE_UNITS>
{
public:
	ImageUnitSelector(GLuint number); 2
};
#endif

1

Throws LimitError if number is greater than the implementation-dependent maximum number of texture units. See GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS.

2

Throws LimitError if number is greater than the implementation-dependent maximum number of image units. See GL_MAX_IMAGE_UNITS.

Examples of usage

Typical setup of a 2D texture

This code snippet shows a typical setup for a 2D texture. See also a more convenient way how to setup textures by using the currently bound objects.

using namespace oglplus;

Texture tex; 1

TextureUnitSelector tex_unit = /* ... */; 2
Texture::Active(tex_unit); 3

TextureTarget tex_tgt = Texture::Target::_2D; 4
tex.Bind(tex_tgt); 5

Texture::MinFilter(tex_tgt, TextureMinFilter::Linear); 6
Texture::MagFilter(tex_tgt, TextureMagFilter::Nearest);
Texture::WrapS(tex_tgt, TextureWrap::ClampToEdge);
Texture::WrapT(tex_tgt, TextureWrap::ClampToEdge);
Texture::CompareMode(tex_tgt, TextureCompareMode::CompareRefToTexture);

std::vector<GLfloat> image = /* ... */; 7
GLsizei width = /* ... */, height = /* ... */;

Texture::Image2D( 8
	tex_tgt,
	0,
	PixelDataInternalFormat::DepthComponent32,
	width, height,
	0,
	PixelDataFormat::DepthComponent,
	PixelDataType::Float,
	image.data() 9
);

1

Create a texture object.

2

Choose a texture unit for the texture.

3

Make the texture unit current (active).

4

Choose binding point for the texture.

5

Bind the texture object to the texture target.

6

Setup various texture parameters for the texture currently bound to the specified texture target on the currenly active texture unit.

7

Obtain the texture image data.

8

Setup the texture image data.

9

The buffer pointed-to by this parameter must hold enough data to be consumed, depending on the width, height, data type and other parameters. Optionally this pointer can be null, which causes a blank texture to be created.

The syntax sugar operators provide another convenient alternative for setting up texture parameters and image data.

Texture tex; 1

TextureUnitSelector tex_unit = /* ... */; 2
Texture::Active(tex_unit);

std::vector<GLubyte> image = /* ... */;
GLsizei width = /* ... */, height = /* ... */;

tex	<< TextureTarget::_2D 3
	<< TextureMinFilter::Linear 4
	<< TextureMagFilter::Nearest 5
	<< TextureWrap::ClampToEdge 6
	<< images::ImageSpec( 7
		width, height,
		PixelDataFormat::RGBA,
		image.data()
	);

1

Create a texture object.

2

Choose a texture unit for the texture and make it current.

3

This expression creates a pair of a texture object and a texture target which allows to chain the other operands which in turn call various Texture's functions.

4

Texture::MinFilter(...)

5

Texture::MagFilter(...)

6

Texture::Wrap(...)

7

Texture::Image(...)


PrevUpHomeNext