UFO: Alien Invasion
r_image.h
Go to the documentation of this file.
1
6/*
7All original material Copyright (C) 2002-2022 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, 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/*
31skins will be outline flood filled and mip mapped
32pics and sprites with alpha will be outline flood filled
33pic won't be mip mapped
34
35model skin
36sprite frame
37wall texture
38pic
39*/
40
41typedef enum {
52
60
61typedef struct image_s {
64 int width, height;
65 int upload_width, upload_height;
69 struct image_s* normalmap;
70 struct image_s* glowmap;
71 struct image_s* specularmap;
72 struct image_s* roughnessmap;
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
81extern int r_numImages;
82
83void R_UploadTexture(const unsigned* data, int width, int height, image_t* image);
84void R_SoftenTexture(byte* in, int width, int height, int bpp);
85void R_GetScaledTextureSize(int width, int height, int* scaledWidth, int* scaledHeight);
86void R_ScaleTexture(const unsigned* in, int inwidth, int inheight, unsigned* out, int outwidth, int outheight);
87image_t* R_RenderToTexture(const char* name, int x, int y, int w, int h);
88
89void R_ImageList_f(void);
90void R_InitImages(void);
91void R_ShutdownImages(void);
92void R_ReloadImages (void);
93void R_FreeWorldImages(void);
94void R_ImageClearMaterials(void);
95void R_UploadAlpha(const image_t* image, const byte* alphaData);
96void R_TextureMode(const char* string);
97void R_TextureAlphaMode(const char* string);
98void R_TextureSolidMode(const char* string);
99
100void R_FreeImage(image_t* image);
101
102image_t* R_LoadImageData(const char* name, const byte* pic, int width, int height, imagetype_t type);
103image_t* R_GetImage(const char* name);
104image_t* R_FindImage(const char* pname, imagetype_t type);
105const image_t* R_FindPics(const char* name);
106
107bool R_ImageExists(const char* pname, ...) __attribute__((format(__printf__, 1, 2)));
109int R_GetImageIndex(image_t* image);
110
111#define MAX_ENVMAPTEXTURES 2
113
114#define NUM_FLARETEXTURES 10
116
117extern image_t* shadow;
118extern image_t* r_noTexture;
119extern image_t* r_warpTexture;
120extern image_t* r_dummyTexture;
#define __attribute__(x)
Definition: cxx.h:37
#define MAX_QPATH
Definition: filesys.h:40
void format(__printf__, 1, 2)))
OpenGL bindings.
QGL_EXTERN GLsizei const GLvoid * data
Definition: r_gl.h:89
QGL_EXTERN GLint i
Definition: r_gl.h:113
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
QGL_EXTERN GLuint
Definition: r_gl.h:124
void R_FreeWorldImages(void)
Any image that is a mesh or world texture will be removed here.
Definition: r_image.cpp:757
bool R_ImageExists(const char *pname,...) __attribute__((format(__printf__
void R_SoftenTexture(byte *in, int width, int height, int bpp)
Applies blurring to a texture.
Definition: r_image.cpp:391
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
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Definition: r_image.cpp:603
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_dummyTexture
Definition: r_main.cpp:53
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
void R_ImageList_f(void)
Shows all loaded images.
Definition: r_image.cpp:85
#define MAX_ENVMAPTEXTURES
Definition: r_image.h:111
void R_ReloadImages(void)
Definition: r_image.cpp:835
void R_TextureAlphaMode(const char *string)
Definition: r_image.cpp:931
#define NUM_FLARETEXTURES
Definition: r_image.h:114
image_t * r_envmaptextures[MAX_ENVMAPTEXTURES]
Definition: r_image.cpp:50
int r_numImages
Definition: r_image.cpp:41
void R_InitImages(void)
Definition: r_image.cpp:774
image_t * r_noTexture
Definition: r_main.cpp:51
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
void R_UploadAlpha(const image_t *image, const byte *alphaData)
Definition: r_image.cpp:423
image_t * r_warpTexture
Definition: r_main.cpp:52
void R_TextureSolidMode(const char *string)
Definition: r_image.cpp:966
void R_ImageClearMaterials(void)
Free previously loaded materials and their stages.
Definition: r_image.cpp:61
image_t * shadow
Definition: r_draw.cpp:35
image_t * R_RenderToTexture(const char *name, int x, int y, int w, int h)
Definition: r_image.cpp:547
void R_ScaleTexture(const unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
Definition: r_image.cpp:172
const image_t * R_FindPics(const char *name)
Searches for an image in the image array.
Definition: r_image.cpp:673
image_t * r_flaretextures[NUM_FLARETEXTURES]
Definition: r_image.cpp:53
void R_ShutdownImages(void)
Definition: r_image.cpp:796
void R_TextureMode(const char *string)
Definition: r_image.cpp:869
image_t * R_GetImage(const char *name)
Definition: r_image.cpp:452
imagetype_t
Definition: r_image.h:41
@ it_pic
Definition: r_image.h:45
@ it_material
Definition: r_image.h:57
@ it_world
Definition: r_image.h:54
@ it_effect
Definition: r_image.h:43
@ it_roughnessmap
Definition: r_image.h:51
@ it_skin
Definition: r_image.h:47
@ it_worldrelated
Definition: r_image.h:58
@ it_static
Definition: r_image.h:44
@ it_specularmap
Definition: r_image.h:50
@ it_normalmap
Definition: r_image.h:48
@ it_chars
Definition: r_image.h:42
@ it_glowmap
Definition: r_image.h:49
@ it_deluxemap
Definition: r_image.h:56
@ it_wrappic
Definition: r_image.h:46
@ it_lightmap
Definition: r_image.h:55
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_UploadTexture(const unsigned *data, int width, int height, image_t *image)
Uploads the opengl texture to the server.
Definition: r_image.cpp:262
Header file for the render material subsystem.
int upload_height
Definition: r_image.h:65
struct image_s * hash_next
Definition: r_image.h:73
int height
Definition: r_image.h:64
struct image_s * specularmap
Definition: r_image.h:71
struct image_s * roughnessmap
Definition: r_image.h:72
GLuint texnum
Definition: r_image.h:66
struct image_s * normalmap
Definition: r_image.h:69
bool has_alpha
Definition: r_image.h:67
struct image_s * glowmap
Definition: r_image.h:70
material_t material
Definition: r_image.h:68
imagetype_t type
Definition: r_image.h:63