UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_image.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 #include "r_gl.h"
29 #include "r_material.h"
30 /*
31 skins will be outline flood filled and mip mapped
32 pics and sprites with alpha will be outline flood filled
33 pic won't be mip mapped
34 
35 model skin
36 sprite frame
37 wall texture
38 pic
39 */
40 
41 typedef enum {
52 
59 } imagetype_t;
60 
61 typedef struct image_s {
62  char name[MAX_QPATH];
64  int width, height;
67  bool has_alpha;
69  struct image_s* normalmap;
70  struct image_s* glowmap;
71  struct image_s* specularmap;
73  struct image_s* hash_next;
74 } image_t;
75 
76 #define MAX_GL_TEXTURES 1024
77 #define MAX_GL_LIGHTMAPS 256
78 #define MAX_GL_DELUXEMAPS 256
79 #define MAX_GL_FRAMEBUFFERS 256
80 
81 extern int r_numImages;
82 
83 void R_UploadTexture(const unsigned* data, int width, int height, image_t* image);
84 void R_SoftenTexture(byte* in, int width, int height, int bpp);
85 void R_GetScaledTextureSize(int width, int height, int* scaledWidth, int* scaledHeight);
86 void R_ScaleTexture(const unsigned* in, int inwidth, int inheight, unsigned* out, int outwidth, int outheight);
87 image_t* R_RenderToTexture(const char* name, int x, int y, int w, int h);
88 
89 void R_ImageList_f(void);
90 void R_InitImages(void);
91 void R_ShutdownImages(void);
92 void R_ReloadImages (void);
93 void R_FreeWorldImages(void);
94 void R_ImageClearMaterials(void);
95 void R_UploadAlpha(const image_t* image, const byte* alphaData);
96 void R_TextureMode(const char* string);
97 void R_TextureAlphaMode(const char* string);
98 void R_TextureSolidMode(const char* string);
99 
100 void R_FreeImage(image_t* image);
101 
102 image_t* R_LoadImageData(const char* name, const byte* pic, int width, int height, imagetype_t type);
103 image_t* R_GetImage(const char* name);
104 image_t* R_FindImage(const char* pname, imagetype_t type);
105 const image_t* R_FindPics(const char* name);
106 
107 bool R_ImageExists(const char* pname, ...) __attribute__((format(__printf__, 1, 2)));
109 int R_GetImageIndex(image_t* image);
110 
111 #define MAX_ENVMAPTEXTURES 2
113 
114 #define NUM_FLARETEXTURES 10
116 
117 extern image_t* shadow;
118 extern image_t* r_noTexture;
119 extern image_t* r_warpTexture;
120 extern image_t* r_dummyTexture;
image_t * r_envmaptextures[MAX_ENVMAPTEXTURES]
Definition: r_image.cpp:50
image_t * r_dummyTexture
Definition: r_main.cpp:53
int r_numImages
Definition: r_image.cpp:41
void R_TextureSolidMode(const char *string)
Definition: r_image.cpp:966
void R_FreeImage(image_t *image)
Free the image and its assigned maps (roughness, normal, specular, glow - if there are any) ...
Definition: r_image.cpp:735
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
imagetype_t
Definition: r_image.h:41
void R_ImageList_f(void)
Shows all loaded images.
Definition: r_image.cpp:85
void R_TextureAlphaMode(const char *string)
Definition: r_image.cpp:931
struct image_s image_t
void R_UploadTexture(const unsigned *data, int width, int height, image_t *image)
Uploads the opengl texture to the server.
Definition: r_image.cpp:262
bool image_t * R_GetImageAtIndex(int i)
Returns an image pointer from the r_images linked list, as if r_images would be a plain contiguous ar...
Definition: r_image.cpp:718
void R_ScaleTexture(const unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
Definition: r_image.cpp:172
void R_ImageClearMaterials(void)
Free previously loaded materials and their stages.
Definition: r_image.cpp:61
const image_t * R_FindPics(const char *name)
Searches for an image in the image array.
Definition: r_image.cpp:673
void R_ShutdownImages(void)
Definition: r_image.cpp:796
image_t * r_noTexture
Definition: r_main.cpp:51
Definition: r_image.h:45
int width
Definition: r_image.h:64
QGL_EXTERN GLuint
Definition: r_gl.h:124
#define __attribute__(x)
Definition: cxx.h:37
imagetype_t type
Definition: r_image.h:63
void R_UploadAlpha(const image_t *image, const byte *alphaData)
Definition: r_image.cpp:423
image_t * shadow
Definition: r_draw.cpp:35
struct image_s * roughnessmap
Definition: r_image.h:72
char name[MAX_QPATH]
Definition: r_image.h:62
bool R_ImageExists(const char *pname,...) __attribute__((format(__printf__
#define MAX_ENVMAPTEXTURES
Definition: r_image.h:111
#define NUM_FLARETEXTURES
Definition: r_image.h:114
void R_InitImages(void)
Definition: r_image.cpp:774
struct image_s * glowmap
Definition: r_image.h:70
struct image_s * specularmap
Definition: r_image.h:71
void R_GetScaledTextureSize(int width, int height, int *scaledWidth, int *scaledHeight)
Calculates the texture size that should be used to upload the texture data.
Definition: r_image.cpp:220
struct image_s * hash_next
Definition: r_image.h:73
image_t * R_LoadImageData(const char *name, const byte *pic, int width, int height, imagetype_t type)
Creates a new image from RGBA data. Stores it in the gltextures array and also uploads it...
Definition: r_image.cpp:475
image_t * r_flaretextures[NUM_FLARETEXTURES]
Definition: r_image.cpp:53
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Definition: r_image.cpp:603
#define MAX_QPATH
Definition: filesys.h:40
QGL_EXTERN GLint i
Definition: r_gl.h:113
int upload_width
Definition: r_image.h:65
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
int height
Definition: r_image.h:64
int R_GetImageIndex(image_t *image)
Returns an index of the image pointer in the r_images linked list, as if r_images would be a plain co...
Definition: r_image.cpp:702
image_t * r_warpTexture
Definition: r_main.cpp:52
void R_SoftenTexture(byte *in, int width, int height, int bpp)
Applies blurring to a texture.
Definition: r_image.cpp:391
void R_ReloadImages(void)
Definition: r_image.cpp:835
void R_TextureMode(const char *string)
Definition: r_image.cpp:869
void R_FreeWorldImages(void)
Any image that is a mesh or world texture will be removed here.
Definition: r_image.cpp:757
GLsizei const GLvoid * data
Definition: r_gl.h:152
struct image_s * normalmap
Definition: r_image.h:69
bool has_alpha
Definition: r_image.h:67
image_t * R_GetImage(const char *name)
Definition: r_image.cpp:452
image_t * R_RenderToTexture(const char *name, int x, int y, int w, int h)
Definition: r_image.cpp:547
uint8_t byte
Definition: ufotypes.h:34
material_t material
Definition: r_image.h:68
int upload_height
Definition: r_image.h:65
void format(__printf__, 1, 2)))
Header file for the render material subsystem.
GLuint texnum
Definition: r_image.h:66
OpenGL bindings.