Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Enumerations | Functions | Variables
texture.hpp File Reference

internal texture loading and organizing routines + main texture structures. More...

#include "SDL_opengl.h"
#include "inexor/shared/cube_types.hpp"
#include "inexor/texture/additionaltools.hpp"

Go to the source code of this file.

Classes

struct  Texture
 A Texture entry, holding info about a texture on the GPU. More...
 

Enumerations

enum  {
  TEX_DIFFUSE = 0, TEX_UNKNOWN, TEX_DECAL, TEX_NORMAL,
  TEX_GLOW, TEX_SPEC, TEX_DEPTH, TEX_ENVMAP,
  TEX_NUM
}
 Different Texture Types. More...
 

Functions

int texalign (void *data, int w, int bpp)
 
void cleanuptexture (Texture *t)
 Clean up texture t: delete texture from gpu, only remove from registry if transient. More...
 
ucharloadalphamask (Texture *t)
 
void setuptexparameters (int tnum, void *pixels, int clamp, int filter, GLenum format=GL_RGB, GLenum target=GL_TEXTURE_2D)
 
void createtexture (int tnum, int w, int h, void *pixels, int clamp, int filter, GLenum component=GL_RGB, GLenum target=GL_TEXTURE_2D, int pw=0, int ph=0, int pitch=0, bool resize=true, GLenum format=GL_FALSE)
 
void createcompressedtexture (int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget)
 
bool reloadtexture (Texture &tex)
 
bool reloadtexture (const char *name)
 
void setuptexcompress ()
 
Texturetextureload (const char *name, int clamp=0, bool mipit=true, bool msg=true, bool threadsafe=false)
 
Texturenewtexture (Texture *t, const char *rname, ImageData &s, int clamp=0, bool mipit=true, bool canreduce=false, bool transient=false, int compress=0)
 
bool loadimage (const char *filename, ImageData &image)
 
Textureregistertexture (const char *name)
 Registers a texture to the texture registry, so it wont be loaded twice (but looked up the other time). More...
 
Texturegettexture (const char *name)
 Receives a texture from the hashtable of all loaded textures if name is equal. More...
 

Variables

Texturenotexture
 Global used to specify this texture has not be found. More...
 

Detailed Description

internal texture loading and organizing routines + main texture structures.

Enumeration Type Documentation

anonymous enum

Different Texture Types.

Enumerator
TEX_DIFFUSE 
TEX_UNKNOWN 
TEX_DECAL 
TEX_NORMAL 
TEX_GLOW 
TEX_SPEC 
TEX_DEPTH 
TEX_ENVMAP 
TEX_NUM 

Function Documentation

void cleanuptexture ( Texture t)

Clean up texture t: delete texture from gpu, only remove from registry if transient.

References Texture::alphamask, DELETEA, Texture::id, Texture::name, Texture::TRANSIENT, and Texture::type.

Referenced by cleanuptextures(), and clearenvmaps().

void createcompressedtexture ( int  tnum,
int  w,
int  h,
uchar data,
int  align,
int  blocksize,
int  levels,
int  clamp,
int  filter,
GLenum  format,
GLenum  subtarget 
)
void createtexture ( int  tnum,
int  w,
int  h,
void pixels,
int  clamp,
int  filter,
GLenum  component = GL_RGB,
GLenum  target = GL_TEXTURE_2D,
int  pw = 0,
int  ph = 0,
int  pitch = 0,
bool  resize = true,
GLenum  format = GL_FALSE 
)
Texture* gettexture ( const char *  name)

Receives a texture from the hashtable of all loaded textures if name is equal.

Warning
not threadsafe.

References copystring(), and path().

Referenced by Slot::combinetextures(), cubemaploadwildcard(), gendds(), Slot::loadthumbnail(), reloadtex(), reloadtexture(), and textureload().

uchar* loadalphamask ( Texture t)
bool loadimage ( const char *  filename,
ImageData image 
)
Texture* newtexture ( Texture t,
const char *  rname,
ImageData s,
int  clamp = 0,
bool  mipit = true,
bool  canreduce = false,
bool  transient = false,
int  compress = 0 
)
Texture* registertexture ( const char *  name)

Registers a texture to the texture registry, so it wont be loaded twice (but looked up the other time).

References copystring(), Texture::name, newstring(), path(), and anonymous_namespace{utilTest.cpp}::t().

Referenced by cubemaploadwildcard(), and newtexture().

bool reloadtexture ( Texture tex)
bool reloadtexture ( const char *  name)
void setuptexcompress ( )

References GLenum(), texcompressquality, and usetexcompress.

Referenced by gendds(), and gl_init().

void setuptexparameters ( int  tnum,
void pixels,
int  clamp,
int  filter,
GLenum  format = GL_RGB,
GLenum  target = GL_TEXTURE_2D 
)
int texalign ( void data,
int  w,
int  bpp 
)
Texture* textureload ( const char *  name,
int  clamp = 0,
bool  mipit = true,
bool  msg = true,
bool  threadsafe = false 
)
Parameters
nameName of texture
clampthe last pixel of texture image will be stretched to infinity
mipitspecifies whether mipmap (lower quality versions; usually used when far away or small) textures should be created.
msgspecifies whether a renderprogress bar should be displayed while loading. Always off if threadsafe = true.
threadsafeif true, the texture wont be automatically registerd to the global texture registry, you need to check whether it is loaded via gettexture beforehand in a nonthreaded environment and register it afterwards with registertexture.

References tiger::compress(), copystring(), gettexture(), newtexture(), notexture, anonymous_namespace{utilTest.cpp}::t(), and texturedata().

Referenced by bind_bomb_items_texture(), bind_items_texture(), gui::button_(), draw_g3d_cursor(), drawdamagescreen(), gui::drawskin(), fonttex(), gendds(), gengrassquads(), guiimage(), gui::icon_(), decalrenderer::init(), blobrenderer::init(), gui::line_(), md5::md5mesh::load(), load_world(), loadcaustics(), loadcrosshair(), loadsky(), loadskyoverlay(), main(), gui::modelpreview(), newfont(), gui::playerpreview(), gui::prefabpreview(), gui::previewslot(), flarerenderer::render(), listrenderer::render(), varenderer< T >::render(), renderbackground(), renderprogress(), modelcommands< MDL, struct MDL::vertmesh >::setbumpmap(), modelcommands< MDL, struct MDL::vertmesh >::setskin(), and settexture().

Variable Documentation

Texture* notexture