Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
texture.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "SDL_opengl.h" // for GLenum, GL_RGB, GL_TEXTURE_2D
7 #include "inexor/shared/cube_types.hpp" // for uchar
8 #include "inexor/texture/additionaltools.hpp" //this one is only to avoid the compiler behaviour that it doesnt build cubescript only files, so we keep a dummy "extern" to it.
9 
10 struct ImageData;
11 
13 enum
14 {
24 };
25 
27 struct Texture
28 {
29  enum
30  {
31  IMAGE = 0,
32  CUBEMAP = 1,
33  TYPE = 0xFF,
34 
35  STUB = 1 << 8,
36  TRANSIENT = 1 << 9,
37  COMPRESSED = 1 << 10,
38  ALPHA = 1 << 11,
39  FLAGS = 0xFF00
40  };
41 
42  char *name;
43  int type, w, h, xs, ys, bpp, clamp;
47 
48  Texture() : alphamask(nullptr) {}
49 };
50 
52 extern Texture *notexture;
53 
54 extern int texalign(void *data, int w, int bpp);
55 extern void cleanuptexture(Texture *t);
56 extern uchar *loadalphamask(Texture *t);
57 extern void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format = GL_RGB, GLenum target = GL_TEXTURE_2D);
58 extern 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);
59 extern void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget);
60 extern bool reloadtexture(Texture &tex);
61 extern bool reloadtexture(const char *name);
62 extern void setuptexcompress();
63 
71 extern Texture *textureload(const char *name, int clamp = 0, bool mipit = true, bool msg = true, bool threadsafe = false);
72 
73 extern Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clamp = 0, bool mipit = true, bool canreduce = false, bool transient = false, int compress = 0);
74 
75 extern bool loadimage(const char *filename, ImageData &image);
76 
77 // Texture Registry:
78 extern Texture *registertexture(const char *name);
79 extern Texture *gettexture(const char *name);
80 
void createcompressedtexture(int tnum, int w, int h, uchar *data, int align, int blocksize, int levels, int clamp, int filter, GLenum format, GLenum subtarget)
Definition: texture.cpp:235
Definition: texture.hpp:38
void cleanuptexture(Texture *t)
Clean up texture t: delete texture from gpu, only remove from registry if transient.
Definition: texture.cpp:528
typedef GLenum(APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target)
Definition: texture.hpp:31
int clamp
Definition: texture.hpp:43
Definition: texture.hpp:33
Definition: texture.hpp:20
bool mipmap
Definition: texture.hpp:44
Structure holding the Raw Pixel Data and minimum image info.
Definition: image.hpp:20
Definition: texture.hpp:18
Texture * registertexture(const char *name)
Registers a texture to the texture registry, so it wont be loaded twice (but looked up the other time...
Definition: texture.cpp:245
uchar * loadalphamask(Texture *t)
Definition: texture.cpp:477
Texture * gettexture(const char *name)
Receives a texture from the hashtable of all loaded textures if name is equal.
Definition: texture.cpp:258
Definition: texture.hpp:36
Definition: texture.hpp:35
Definition: texture.hpp:19
void format(tagval *args, int numargs)
Definition: command.cpp:2584
char * name
Definition: texture.hpp:42
typedef GLuint(APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program
void setuptexparameters(int tnum, void *pixels, int clamp, int filter, GLenum format=GL_RGB, GLenum target=GL_TEXTURE_2D)
Definition: texture.cpp:123
int xs
Definition: texture.hpp:43
Definition: texture.hpp:39
Definition: texture.hpp:32
Definition: texture.hpp:23
Texture * newtexture(Texture *t, const char *rname, ImageData &s, int clamp=0, bool mipit=true, bool canreduce=false, bool transient=false, int compress=0)
Definition: texture.cpp:277
Definition: texture.hpp:17
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)
Definition: texture.cpp:138
GLuint id
Definition: texture.hpp:45
Definition: texture.hpp:21
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glexts.hpp:299
int type
Definition: texture.hpp:43
Texture()
Definition: texture.hpp:48
unsigned char uchar
Basic type definitions.
Definition: cube_types.hpp:7
Definition: texture.hpp:15
bool loadimage(const char *filename, ImageData &image)
Definition: texture.cpp:613
void setuptexcompress()
Definition: texture.cpp:46
Definition: texture.hpp:16
bool canreduce
Definition: texture.hpp:44
int h
Definition: texture.hpp:43
Definition: texture.hpp:37
void compress(const chunk *str, chunk state[3])
Definition: crypto.cpp:36
bool reloadtexture(Texture &tex)
Definition: texture.cpp:558
Texture * textureload(const char *name, int clamp=0, bool mipit=true, bool msg=true, bool threadsafe=false)
Definition: texture.cpp:501
uchar * alphamask
Definition: texture.hpp:46
Texture * notexture
Global used to specify this texture has not be found.
Definition: texture.cpp:266
int texalign(void *data, int w, int bpp)
Definition: texture.cpp:268
Definition: texture.hpp:22
int bpp
Definition: texture.hpp:43
bool target(fpsent *d, aistate &b, int pursue=0, bool force=false, float mindist=0.f)
Definition: ai.cpp:393
int ys
Definition: texture.hpp:43
int w
Definition: texture.hpp:43
A Texture entry, holding info about a texture on the GPU.
Definition: texture.hpp:27