DemoGL::Reference::Functions::DEMOGL_TextureCreateFromFBRegion

DEMOGL_TextureCreateFromFBRegion

DEMOGL_TextureCreateFromFBRegion creates a new texture in the texture store of DemoGL with the data from a given region in the backbuffer of the color buffer. The region is (iX,iY) - ((iX + iWidth + (2*iBorder)),(iY + iHeight + (2*iBorder)))

GLuint
DEMOGL_TextureCreateFromFBRegion(
	const int iX,
	const int iY,
	const int iWidth,
	const int iHeight,
	const char *pszIdentName,
	const int iBorder,
	const GLint iWrapS, 
	const GLint iWrapT,
	const GLint iMinFilter,
	const GLint iMagFilter,
	const GLint iTexUploadHint,
	const int iDimensions
);
	
Parameters.
iX
Specifies the X-coordinate of the left lower corner of the region of the backbuffer which should be read for the texture data. This is a screencoordinate in pixels, starting from the left of the screen.
iY
Specifies the Y-coordinate of the left lower corner of the region of the backbuffer which should be read for the texture data. This is a screencoordinate in pixels, starting from the bottom of the screen.
iWidth
Specifies the width of the texture, which pixeldata is stored in the buffer pointed by pbyBuffer in pixels. Must be 2n + 2(iBorder) for some integer n.
iHeight
Specifies the height of the texture, which pixeldata is stored in the buffer pointed by pbyBuffer in pixels. Must be 2n + 2(iBorder) for some integer n.
pszIdentName
Pointer to a zero-terminated string which represents the name of the texture so other effects which will load the same texture by specifying the same name will receive a reference to this texture instead. Normally textures are globally referenced by the filename of the file with the texturedata, for textures created from a buffer there is no file, so you can specify any string as IdentName.
iBorder
Specifies the width of the textureborder in OpenGL for this texture, normally 0 or 1.
iWrapS
Sets the wrap parameter for texture coordinate s to either GL_CLAMP or GL_REPEAT. GL_CLAMP causes s coordinates to be clamped to the range [0,1] and is useful for preventing wrapping artifacts when mapping a single image onto an object. GL_REPEAT causes the integer part of the s coordinate to be ignored; OpenGL uses only the fractional part, thereby creating a repeating pattern. Border texture elements are accessed only if wrapping is set to GL_CLAMP. Initially, GL_TEXTURE_WRAP_S is set to GL_REPEAT.
iWrapT
As iWrapS but now for texture coordinate t.
iMinFilter
Sets the texture minifying function. Can be one of the following values:

Value Meaning
GL_NEAREST Returns the value of the texture element that is nearest (in Manhattan distance) to the center of the pixel being textured.
GL_LINEAR Returns the weighted average of the four texture elements that are closest to the center of the pixel being textured. These can include border texture elements, depending on the values of iWrapS, iWrapT, and on the exact mapping. GL_NEAREST is generally faster than GL_LINEAR, but it can produce textured images with sharper edges because the transition between texture elements is not as smooth.
GL_NEAREST_MIPMAP_NEAREST Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_NEAREST criterion (the texture element nearest to the center of the pixel) to produce a texture value.
GL_LINEAR_MIPMAP_NEAREST Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_LINEAR criterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value.
GL_NEAREST_MIPMAP_LINEAR Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_NEAREST criterion (the texture element nearest to the center of the pixel) to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.
GL_LINEAR_MIPMAP_LINEAR Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_LINEAR criterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.

iMagFilter
Sets the texture magnification function. The texture magnification function is used when the pixel being textured maps to an area less than or equal to one texture element. It sets the texture magnification function to either GL_NEAREST or GL_LINEAR.
iTexUploadHint
Specifies the upload hint which should be used when DemoGL uploads the texture data to OpenGL. This hint is ment for the situation when the user has selected 16bit textures ONLY. In this situation normally DemoGL selects GL_RGBA4 as texturehint for the upload process to OpenGL, so you'll get better alphachannel support. If this isn't necessary in a situation, because the texture doesn't use the alphavalues, you can specify an overruling hint for DemoGL to pass on to OpenGL in 16bit. A good hint for nonalpha textures is GL_RGB5_A1. In situations where the user has selected 32bit textures (recommended, since the driver will transform these to 16bit if necessary and will dither, which gives better results) this hint is ignored and GL_RGBA8 is used. If DemoGL should use the default hint for this texture whenever it has to, set iTexUploadHint to DGL_TEXHINT_USEDEFAULT.
iDimensions
Specifies the amount of dimensions of the texture, needed for the upload process of the texture data to OpenGL. Can be one of the following values: DGL_TEXTUREDIMENSION_1D for 1D textures (only iWidth is used), DGL_TEXTUREDIMENSION_2D for 2D textures (only iWidth and iHeight are used) or DGL_TEXTUREDIMENSION_3D for 3D textures, which are currently not implemented in full in DemoGL.

Return values.
If the function succeeds, it returns the TextureID, or texture name, usable with functions in OpenGL like glBindTexture.
If the function failes, 0 is returned.

Remarks.
Support for 3D textures is not fully implemented in DemoGL due to the lack of OpenGL 1.2 support in the Windows OpenGL implementation. When you load a texture with a filename the same as pszIdentName DemoGL will increase the reference counter to the texture already created. Textures created with DEMOGL_TextureCreateFromFBRegion can't be unuploaded because they can't be re-uploaded again later. The actual texture data is not stored in main memory but only copied from the framebuffer to the texture storage on the card using OpenGL. DemoGL itself doesn't hold a copy of the texturedata. You also can't get a pointer to this texture data when you call DEMOGL_TextureGetData.

Example.

Requirements.
DemoGL v1.3 (build 0112 or higher)

See also.
DEMOGL_TextureDelete, DEMOGL_TextureGetData, DEMOGL_TextureLoad, DEMOGL_TextureUnUpload, DEMOGL_TextureUpload

Last changed on 01-jun-2001

©1999-2001 Solutions Design