1 /** @file texturecontent.h  GL-texture content.
2  *
3  * @author Copyright © 2006-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  * @author Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
5  *
6  * @par License
7  * GPL: http://www.gnu.org/licenses/gpl.html
8  *
9  * <small>This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version. This program is distributed in the hope that it
13  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details. You should have received a copy of the GNU
16  * General Public License along with this program; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA</small>
19  */
20 
21 #ifndef DENG_CLIENT_GL_TEXTURECONTENT_H
22 #define DENG_CLIENT_GL_TEXTURECONTENT_H
23 
24 #include "api_gl.h"
25 #include "gl/gl_defer.h"
26 #include <doomsday/res/TextureManifest>
27 
28 /**
29  * @defgroup textureContentFlags  Texture Content Flags
30  * @ingroup flags
31  */
32 /*@{*/
33 #define TXCF_NO_COMPRESSION             0x1
34 #define TXCF_MIPMAP                     0x2
35 #define TXCF_GRAY_MIPMAP                0x4
36 #define TXCF_CONVERT_8BIT_TO_ALPHA      0x8
37 #define TXCF_APPLY_GAMMACORRECTION      0x10
38 #define TXCF_UPLOAD_ARG_NOSTRETCH       0x20
39 #define TXCF_UPLOAD_ARG_NOSMARTFILTER   0x40
40 #define TXCF_NEVER_DEFER                0x80
41 /*@}*/
42 
43 /**
44  * Defines the content of a GL texture. Used when creating textures either
45  * immediately or in deferred mode (when busy).
46  */
47 typedef struct texturecontent_s {
48     dgltexformat_t format;
49     GLuint name;
50     uint8_t const *pixels;
51     colorpaletteid_t paletteId;
52     int width;
53     int height;
54     int minFilter;
55     int magFilter;
56     int anisoFilter;
57     int wrap[2];
58     int grayMipmap;
59     int flags; /// @ref textureContentFlags
60 } texturecontent_t;
61 
62 /**
63  * Initializes a texture content struct with default params.
64  */
65 void GL_InitTextureContent(texturecontent_t *content);
66 
67 texturecontent_t *GL_ConstructTextureContentCopy(texturecontent_t const *other);
68 
69 void GL_DestroyTextureContent(texturecontent_t *content);
70 
71 /**
72  * Prepare the texture content @a c, using the given image in accordance with
73  * the supplied specification. The image data will be transformed in-place.
74  *
75  * @param c             Texture content to be completed.
76  * @param glTexName     GL name for the texture we intend to upload.
77  * @param image         Source image containing the pixel data to be prepared.
78  * @param spec          Specification describing any transformations which
79  *                      should be applied to the image.
80  *
81  * @param textureManifest  Manifest for the logical texture being prepared.
82  *                      (for informational purposes, i.e., logging)
83  */
84 void GL_PrepareTextureContent(texturecontent_t &c,
85                               GLuint glTexName,
86                               image_t &image,
87                               TextureVariantSpec const &spec,
88                               res::TextureManifest const &textureManifest);
89 
90 /**
91  * @param method  GL upload method. By default the upload is deferred.
92  *
93  * @note Can be rather time-consuming due to forced scaling operations and
94  * the generation of mipmaps.
95  */
96 void GL_UploadTextureContent(texturecontent_t const &content,
97                              de::gl::UploadMethod method = de::gl::Deferred);
98 
99 #endif // DENG_CLIENT_GL_TEXTURECONTENT_H
100