DemoGL::Reference::Functions::DEMOGL_TextureCubeMapCreateDynamic

DEMOGL_TextureCubeMapCreateDynamic

DEMOGL_TextureCubeMapCreateDynamic creates a new cubemap texture in the texture store of DemoGL. The texture contains however no data, that is: the textures are black with an alpha of 0.0f. The advantage of this routine is that when you want to use dynamic cubemaps, you can only update existing cubesides, i.e. an existing, uploaded cubemap. To get an uploaded cubemap, you can load a dummy cubemap with DEMOGL_TextureCubeMapLoad, upload it and then update the sides of that cubemap texture using DEMOGL_TextureCubeMapUpdateWithFBRegion. However, avoiding the overhead of including a dummy cubemap, just call DEMOGL_TextureCubeMapCreateDynamic and update the sides of that texture.

GLuint
DEMOGL_TextureCubeMapCreateDynamic(
	const int iWidth,
	const int iHeight,
	const char *pszIdentName,
	const int iBorder,
	const GLint iMinFilter,
	const GLint iMagFilter,
	const GLint iTexUploadHint
);
	
Parameters.
iWidth
Width of the cubemap sides, in pixels. Has to be a power of 2 and great than 0.
iHeight
Height of the cubemap sides, in pixels. Has to be a power of 2 and great than 0.
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 cubemap textures created with DEMOGL_TextureCubeCreateDynamic 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.
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. 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.

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.
If the videocard doesn't support cubemaps, DEMOGL_TextureCubeMapCreateDynamic will fail. When you create or load a cubemap texture with the same value for pszIdentName, DemoGL will increase the reference counter to the loaded texture instead of loading / creating the texturedata again. The texture created with DEMOGL_TextureCubeMapCreateDynamic can be used with the normal upload/unupload and delete functions for textures: DEMOGL_TextureDelete, DEMOGL_TextureUnUpload and DEMOGL_TextureUpload. However, dynamic updated cubesides can't be re-uploaded, once the texture is un-uploaded. To keep dynamic created cubemaps available, don't un-upload the cubemap texture.

Cubemapping is implemented in hardware using the DirectX concepts. This means that negative Z en positive Z are switched. See DemoGL Example 6 for example code on how to use DemoGL to render objects using cubemaps. It's recommended to read nVidia's documentation about cubemaps and OpenGL also on their developer site, especially CubeEnvMapping2.pdf.

DemoGL_glext.h contains all necessary constant definitions for cubemapping. When you use cubemaps in your code, be sure to include DemoGL_glext.h.

Example.
See DemoGL Example 6 for an example of dynamic created cubemaps and a usage of DEMOGL_TextureCubeMapCreateDynamic

Requirements.
DemoGL v1.31 (build 0528 or higher), Cubemap support in hardware (GeForce card series and ATi Radeon card series)

See also.
DEMOGL_TextureDelete, DEMOGL_TextureUnUpload, DEMOGL_TextureUpload, DEMOGL_TextureCubeMapCreateDynamic, DEMOGL_TextureCubeMapUpdateWithFBRegion

Last changed on 31-may-2001

©1999-2001 Solutions Design