| DemoGL::Reference::Functions::DEMOGL_TextureCubeMapLoad |
GLuint DEMOGL_TextureLoad( const char *pszFilename, const int iFileType, const GLint iMinFilter, const GLint iMagFilter, const bool bMipMaps, const bool bCreateAlphaFromColor, const int iBorder, const GLint iTexUploadHint );
| Cube side | String added. |
| Positive X |
posx
This will result in: |
| Negative X |
negx
This will result in: |
| Positive Y |
posy
This will result in: |
| Negative Y |
negy
This will result in: |
| Positive Z |
posz
This will result in: |
| Negative Z |
negz
This will result in: |
| FileType | Description |
| DGL_FTYPE_JPGFILE | Imagedata stored using the JPEG format. |
| DGL_FTYPE_TGAFILE | Imagedata stored using the TGA format. |
| DGL_FTYPE_BMPFILE | Imagedata stored using the BMP format. |
The value of iFileType generates the extension of the files loaded by DEMOGL_TextureCubeMapLoad.
| 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. |
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.
DemoGL doesn't support cubemaps stored in DDS files. DDS files are therefor not supported in this routine.
// include the DemoGL_glext.h file to include definitions for the ARB cubemap
// constants
#include "DemoGL_glext.h"
// ...
// Other code
// ...
// Load the cubemap textures "test_*.jpg" into 1 cubemap texture. F.e. in an
// Init() method
m_iTextureCube = DEMOGL_TextureCubeMapLoad("demotex\\test_",DGL_FTYPE_JPGFILE,
GL_LINEAR, GL_LINEAR, false, false, 0, GL_RGB5_A1);
// ...
// Other code
// ...
// Upload the texture to OpenGL, f.e. in a Prepare() method
DEMOGL_TextureUpload(m_iTextureCube);
// ...
// Other code
// ...
// Render the mesh using the cubemap, f.e. in a RenderFrame() method
// Enable cubemapping. This will overrule GL_TEXTURE_2D.
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
// Bind to the cubemap texture loaded
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, m_iTextureCube);
// Set the reflection generation functions.
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
// Enable texturecoordinate generation. Notice the 'R' coordinate
// function, which is needed.
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glColor4f(1.0f,1.0f,1.0f,1.0f);
// draw all faces of the mesh
for(i=0;i<m_pModel->m_iAmFaces;i++)
{
// draw a face.
glBegin(GL_TRIANGLES);
for(j=0;j<3;j++)
{
glNormal3fv(&m_pModel->m_pFaces[i].m_vVertexNormals[j][0]);
glVertex3fv(
&m_pModel->m_pVertices[
m_pModel->m_pFaces[i].m_iVertexIndices[j]][0]);
glTexCoord2f(0.0f,0.0f);
}
glEnd();
}
// disable cubemap
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
// Disable the texture generation functions.
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_S);
Last changed on 28-may-2001
©1999-2001 Solutions Design