Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

texture.h File Reference

#include <string>
#include <celutil/basictypes.h>
#include <celutil/color.h>
#include <celengine/image.h>

Include dependency graph for texture.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* ProceduralTexEval )(float, float, float, unsigned char *)

Functions

TextureCreateProceduralCubeMap (int size, int format, ProceduralTexEval func)
TextureCreateProceduralTexture (int width, int height, int format, TexelFunctionObject &func, Texture::AddressMode addressMode=Texture::EdgeClamp, Texture::MipMapMode mipMode=Texture::DefaultMipMaps)
TextureCreateProceduralTexture (int width, int height, int format, ProceduralTexEval func, Texture::AddressMode addressMode=Texture::EdgeClamp, Texture::MipMapMode mipMode=Texture::DefaultMipMaps)
TextureLoadHeightMapFromFile (const std::string &filename, float height, Texture::AddressMode addressMode=Texture::EdgeClamp)
TextureLoadTextureFromFile (const std::string &filename, Texture::AddressMode addressMode=Texture::EdgeClamp, Texture::MipMapMode mipMode=Texture::DefaultMipMaps)


Typedef Documentation

typedef void(* ProceduralTexEval)(float, float, float, unsigned char *)
 

Definition at line 19 of file texture.h.


Function Documentation

Texture* CreateProceduralCubeMap int  size,
int  format,
ProceduralTexEval  func
 

Definition at line 901 of file texture.cpp.

References cubeVector(), Image::getComponents(), Image::getPixelRow(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::init().

00903 {
00904     Image* faces[6];
00905     bool failed = false;
00906 
00907     int i = 0;
00908     for (i = 0; i < 6; i++)
00909     {
00910         faces[i] = NULL;
00911         faces[i] = new Image(format, size, size);
00912         if (faces == NULL)
00913             failed = true;
00914     }
00915 
00916     if (!failed)
00917     {
00918         for (int i = 0; i < 6; i++)
00919         {
00920             Image* face = faces[i];
00921             for (int y = 0; y < size; y++)
00922             {
00923                 for (int x = 0; x < size; x++)
00924                 {
00925                     float s = ((float) x + 0.5f) / (float) size * 2 - 1;
00926                     float t = ((float) y + 0.5f) / (float) size * 2 - 1;
00927                     Vec3f v = cubeVector(i, s, t);
00928                     func(v.x, v.y, v.z,
00929                          face->getPixelRow(y) + x * face->getComponents());
00930                 }
00931             }
00932         }
00933     }
00934 
00935     Texture* tex = new CubeMap(faces);
00936 
00937     // Clean up the images
00938     for (i = 0; i < 6; i++)
00939     {
00940         if (faces[i] != NULL)
00941             delete faces[i];
00942     }
00943 
00944     return tex;
00945 }

Texture* CreateProceduralTexture int  width,
int  height,
int  format,
TexelFunctionObject func,
Texture::AddressMode  addressMode = Texture::EdgeClamp,
Texture::MipMapMode  mipMode = Texture::DefaultMipMaps
 

Definition at line 839 of file texture.cpp.

References Image::getComponents(), and Image::getPixelRow().

00844 {
00845     Image* img = new Image(format, width, height);
00846     if (img == NULL)
00847         return NULL;
00848 
00849     for (int y = 0; y < height; y++)
00850     {
00851         for (int x = 0; x < width; x++)
00852         {
00853             float u = (float) x / (float) width * 2 - 1;
00854             float v = (float) y / (float) height * 2 - 1;
00855             func(u, v, 0, img->getPixelRow(y) + x * img->getComponents());
00856         }
00857     }
00858 
00859     Texture* tex = new ImageTexture(*img, addressMode, mipMode);
00860     delete img;
00861 
00862     return tex;
00863 }

Texture* CreateProceduralTexture int  width,
int  height,
int  format,
ProceduralTexEval  func,
Texture::AddressMode  addressMode = Texture::EdgeClamp,
Texture::MipMapMode  mipMode = Texture::DefaultMipMaps
 

Definition at line 812 of file texture.cpp.

References Image::getComponents(), and Image::getPixelRow().

00817 {
00818     Image* img = new Image(format, width, height);
00819     if (img == NULL)
00820         return NULL;
00821 
00822     for (int y = 0; y < height; y++)
00823     {
00824         for (int x = 0; x < width; x++)
00825         {
00826             float u = (float) x / (float) width * 2 - 1;
00827             float v = (float) y / (float) height * 2 - 1;
00828             func(u, v, 0, img->getPixelRow(y) + x * img->getComponents());
00829         }
00830     }
00831 
00832     Texture* tex = new ImageTexture(*img, addressMode, mipMode);
00833     delete img;
00834 
00835     return tex;
00836 }

Texture* LoadHeightMapFromFile const std::string filename,
float  height,
Texture::AddressMode  addressMode = Texture::EdgeClamp
 

Texture* LoadTextureFromFile const std::string filename,
Texture::AddressMode  addressMode = Texture::EdgeClamp,
Texture::MipMapMode  mipMode = Texture::DefaultMipMaps
 


Generated on Sat Jan 14 22:31:26 2006 for Celestia by  doxygen 1.4.1