![]() |
naev 0.11.5
|
This file handles the opengl texture wrapper routines. More...
#include "distance_field.h"#include "array.h"#include "conf.h"#include "gui.h"#include "log.h"#include "md5.h"#include "nfile.h"#include "nstring.h"#include "opengl.h"Go to the source code of this file.
Data Structures | |
| struct | glTexList |
| Represents a node in the texture list. More... | |
Functions | |
| static uint8_t | SDL_GetAlpha (SDL_Surface *s, int x, int y) |
| Gets the alpha value of a pixel. | |
| static int | SDL_IsTrans (SDL_Surface *s, int x, int y) |
| Checks to see if a position of the surface is transparent. | |
| static uint8_t * | SDL_MapAlpha (SDL_Surface *s, int w, int h, int tight) |
| Maps the surface transparency. | |
| static size_t | gl_transSize (const int w, const int h) |
| static GLuint | gl_texParameters (unsigned int flags) |
| Sets default texture parameters. | |
| static GLuint | gl_loadSurface (SDL_Surface *surface, unsigned int flags, int freesur, double *vmax) |
| Loads a surface into an opengl texture. | |
| static glTexture * | gl_loadNewImage (const char *path, const unsigned int flags) |
| Only loads the image, does not add to stack unlike gl_newImage. | |
| static glTexture * | gl_loadNewImageRWops (const char *path, SDL_RWops *rw, unsigned int flags) |
| Only loads the image, does not add to stack unlike gl_newImage. | |
| static glTexture * | gl_texExists (const char *path, int sx, int sy) |
| Check to see if a texture matching a path already exists. | |
| static int | gl_texAdd (glTexture *tex, int sx, int sy) |
| Adds a texture to the list under the name of path. | |
| static int | tex_cmp (const void *p1, const void *p2) |
| static void | tex_ctxSet (void) |
| static void | tex_ctxUnset (void) |
| void | gl_contextSet (void) |
| void | gl_contextUnset (void) |
| int | gl_fboCreate (GLuint *fbo, GLuint *tex, GLsizei width, GLsizei height) |
| Creates a framebuffer and its associated texture. | |
| glTexture * | gl_loadImageData (float *data, int w, int h, int sx, int sy, const char *name) |
| glTexture * | gl_loadImagePadTrans (const char *name, SDL_Surface *surface, SDL_RWops *rw, unsigned int flags, int w, int h, int sx, int sy, int freesur) |
| Wrapper for gl_loadImagePad that includes transparency mapping. | |
| glTexture * | gl_loadImagePad (const char *name, SDL_Surface *surface, unsigned int flags, int w, int h, int sx, int sy, int freesur) |
| Loads the already padded SDL_Surface to a glTexture. | |
| glTexture * | gl_loadImage (SDL_Surface *surface, unsigned int flags) |
| Loads the SDL_Surface to a glTexture. | |
| glTexture * | gl_newImage (const char *path, const unsigned int flags) |
| Loads an image as a texture. | |
| glTexture * | gl_newImageRWops (const char *path, SDL_RWops *rw, const unsigned int flags) |
| Loads an image as a texture. | |
| glTexture * | gl_newSprite (const char *path, const int sx, const int sy, const unsigned int flags) |
| Loads the texture immediately, but also sets it as a sprite. | |
| glTexture * | gl_newSpriteRWops (const char *path, SDL_RWops *rw, const int sx, const int sy, const unsigned int flags) |
| Loads the texture immediately, but also sets it as a sprite. | |
| void | gl_freeTexture (glTexture *texture) |
| Frees a texture. | |
| glTexture * | gl_dupTexture (const glTexture *texture) |
| Duplicates a texture. | |
| int | gl_isTrans (const glTexture *t, const int x, const int y) |
| Checks to see if a pixel is transparent in a texture. | |
| void | gl_getSpriteFromDir (int *x, int *y, const glTexture *t, const double dir) |
| Sets x and y to be the appropriate sprite for glTexture using dir. | |
| int | gl_initTextures (void) |
| Initializes the opengl texture subsystem. | |
| void | gl_exitTextures (void) |
| Cleans up the opengl texture subsystem. | |
| glTexture ** | gl_copyTexArray (glTexture **tex) |
| Copy a texture array. | |
| glTexture ** | gl_addTexArray (glTexture **tex, glTexture *t) |
| Adds an element to a texture array. | |
Variables | |
| static glTexList * | texture_list = NULL |
| static SDL_threadID | tex_mainthread |
| static SDL_mutex * | tex_lock = NULL |
This file handles the opengl texture wrapper routines.
Definition in file opengl_tex.c.
Adds an element to a texture array.
Definition at line 1055 of file opengl_tex.c.
| void gl_contextSet | ( | void | ) |
Definition at line 79 of file opengl_tex.c.
| void gl_contextUnset | ( | void | ) |
Definition at line 85 of file opengl_tex.c.
Copy a texture array.
Definition at line 1038 of file opengl_tex.c.
Duplicates a texture.
| texture | Texture to duplicate. |
Definition at line 917 of file opengl_tex.c.
| void gl_exitTextures | ( | void | ) |
Cleans up the opengl texture subsystem.
Definition at line 1014 of file opengl_tex.c.
| int gl_fboCreate | ( | GLuint * | fbo, |
| GLuint * | tex, | ||
| GLsizei | width, | ||
| GLsizei | height ) |
Creates a framebuffer and its associated texture.
| [out] | fbo | Framebuffer object id. |
| [out] | tex | Texture id. |
| width | Width to use. | |
| height | Height to use. |
Definition at line 252 of file opengl_tex.c.
| void gl_freeTexture | ( | glTexture * | texture | ) |
Frees a texture.
| texture | Texture to free. (If NULL, function does nothing.) |
Definition at line 862 of file opengl_tex.c.
| void gl_getSpriteFromDir | ( | int * | x, |
| int * | y, | ||
| const glTexture * | t, | ||
| const double | dir ) |
Sets x and y to be the appropriate sprite for glTexture using dir.
Very slow, try to cache if possible like the pilots do instead of using in O(n^2) or worse functions.
| [out] | x | X sprite to use. |
| [out] | y | Y sprite to use. |
| t | Texture to get sprite from. | |
| dir | Direction to get sprite from. |
Definition at line 967 of file opengl_tex.c.
| int gl_initTextures | ( | void | ) |
Initializes the opengl texture subsystem.
Definition at line 1004 of file opengl_tex.c.
| int gl_isTrans | ( | const glTexture * | t, |
| const int | x, | ||
| const int | y ) |
Checks to see if a pixel is transparent in a texture.
| t | Texture to check for transparency. |
| x | X position of the pixel. |
| y | Y position of the pixel. |
Definition at line 948 of file opengl_tex.c.
| glTexture * gl_loadImage | ( | SDL_Surface * | surface, |
| unsigned int | flags ) |
Loads the SDL_Surface to a glTexture.
| surface | Surface to load. |
| flags | Flags to use. |
Definition at line 599 of file opengl_tex.c.
| glTexture * gl_loadImageData | ( | float * | data, |
| int | w, | ||
| int | h, | ||
| int | sx, | ||
| int | sy, | ||
| const char * | name ) |
Definition at line 292 of file opengl_tex.c.
| glTexture * gl_loadImagePad | ( | const char * | name, |
| SDL_Surface * | surface, | ||
| unsigned int | flags, | ||
| int | w, | ||
| int | h, | ||
| int | sx, | ||
| int | sy, | ||
| int | freesur ) |
Loads the already padded SDL_Surface to a glTexture.
| name | Name to load with. |
| surface | Surface to load. |
| flags | Flags to use. |
| w | Non-padded width. |
| h | Non-padded height. |
| sx | X sprites. |
| sy | Y sprites. |
| freesur | Whether or not to free the surface. |
Definition at line 543 of file opengl_tex.c.
| glTexture * gl_loadImagePadTrans | ( | const char * | name, |
| SDL_Surface * | surface, | ||
| SDL_RWops * | rw, | ||
| unsigned int | flags, | ||
| int | w, | ||
| int | h, | ||
| int | sx, | ||
| int | sy, | ||
| int | freesur ) |
Wrapper for gl_loadImagePad that includes transparency mapping.
| name | Name to load with. |
| surface | Surface to load. |
| rw | RWops containing data to hash. |
| flags | Flags to use. |
| w | Non-padded width. |
| h | Non-padded height. |
| sx | X sprites. |
| sy | Y sprites. |
| freesur | Whether or not to free the surface. |
Definition at line 427 of file opengl_tex.c.
|
static |
Only loads the image, does not add to stack unlike gl_newImage.
| path | Image to load. |
| flags | Flags to control image parameters. |
Definition at line 720 of file opengl_tex.c.
|
static |
Only loads the image, does not add to stack unlike gl_newImage.
| path | Only used for debugging. Can be set to NULL. |
| rw | SDL_Rwops structure to use to load. |
| flags | Flags to control image parameters. |
Definition at line 751 of file opengl_tex.c.
|
static |
Loads a surface into an opengl texture.
| surface | Surface to load into a texture. | |
| flags | Flags to use. | |
| freesur | Whether or not to free the surface. | |
| [out] | vmax | The maximum value in the case of an SDF texture. |
Definition at line 342 of file opengl_tex.c.
| glTexture * gl_newImage | ( | const char * | path, |
| const unsigned int | flags ) |
Loads an image as a texture.
May not necessarily load the image but use one if it's already open.
| path | Image to load. |
| flags | Flags to control image parameters. |
Definition at line 675 of file opengl_tex.c.
| glTexture * gl_newImageRWops | ( | const char * | path, |
| SDL_RWops * | rw, | ||
| const unsigned int | flags ) |
Loads an image as a texture.
May not necessarily load the image but use one if it's already open.
| path | Path name used for checking cache and error reporting. |
| rw | SDL_RWops structure to load from. |
| flags | Flags to control image parameters. |
Definition at line 700 of file opengl_tex.c.
| glTexture * gl_newSprite | ( | const char * | path, |
| const int | sx, | ||
| const int | sy, | ||
| const unsigned int | flags ) |
Loads the texture immediately, but also sets it as a sprite.
| path | Image to load. |
| sx | Number of X sprites in image. |
| sy | Number of Y sprites in image. |
| flags | Flags to control image parameters. |
Definition at line 791 of file opengl_tex.c.
| glTexture * gl_newSpriteRWops | ( | const char * | path, |
| SDL_RWops * | rw, | ||
| const int | sx, | ||
| const int | sy, | ||
| const unsigned int | flags ) |
Loads the texture immediately, but also sets it as a sprite.
| path | Image name for deduplication. |
| rw | SDL_RWops structure to load for. |
| sx | Number of X sprites in image. |
| sy | Number of Y sprites in image. |
| flags | Flags to control image parameters. |
Definition at line 829 of file opengl_tex.c.
|
static |
Adds a texture to the list under the name of path.
Definition at line 645 of file opengl_tex.c.
|
static |
Check to see if a texture matching a path already exists.
Note this increments the used counter if it exists.
| path | Path to the texture. |
| sx | X sprites. |
| sy | Y sprites. |
Definition at line 614 of file opengl_tex.c.
|
static |
Sets default texture parameters.
Definition at line 211 of file opengl_tex.c.
|
static |
Definition at line 202 of file opengl_tex.c.
|
static |
Gets the alpha value of a pixel.
| s | Surface to get value from. |
| x | X position of the pixel to check. |
| y | Y position of the pixel to check. |
Definition at line 112 of file opengl_tex.c.
|
static |
Checks to see if a position of the surface is transparent.
| s | Surface to check for transparency. |
| x | X position of the pixel to check. |
| y | Y position of the pixel to check. |
Definition at line 139 of file opengl_tex.c.
|
static |
Maps the surface transparency.
Basically generates a map of what pixels are transparent. Good for pixel perfect collision routines.
| s | Surface to map it's transparency. |
| w | Width to map. |
| h | Height to map. |
| tight | Whether or not to store transparency per bit or |
Definition at line 159 of file opengl_tex.c.
|
static |
Definition at line 91 of file opengl_tex.c.
|
static |
Definition at line 67 of file opengl_tex.c.
|
static |
Definition at line 73 of file opengl_tex.c.
|
static |
Definition at line 47 of file opengl_tex.c.
|
static |
Definition at line 46 of file opengl_tex.c.
|
static |
Texture list.
Definition at line 45 of file opengl_tex.c.