GL Studio C++ Runtime API
ddsfile.h
Go to the documentation of this file.
1/// \file ddsfile.h
2/// \brief DDS file loading functions
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef INCLUDED_DISTI_DDSFILE_H
40#define INCLUDED_DISTI_DDSFILE_H
41
42#include "gls_gl.h"
43#include <memory>
44#include <vector>
45
46#ifndef GL_COMPRESSED_RED_RGTC1
47# define GL_COMPRESSED_RED_RGTC1 0x8DBB ///< Redefined from glext.h.
48# define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC ///< Redefined from glext.h.
49# define GL_COMPRESSED_RG_RGTC2 0x8DBD ///< Redefined from glext.h.
50# define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE ///< Redefined from glext.h.
51#endif
52
53#ifndef GL_COMPRESSED_LUMINANCE_LATC1_EXT
54# define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 ///< Redefined from glext.h.
55# define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 ///< Redefined from glext.h.
56# define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 ///< Redefined from glext.h.
57# define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 ///< Redefined from glext.h.
58#endif
59
60namespace disti
61{
62/// \details The DDSTextureInfo struct. Holds the file header information of the DDS format.
64{
65 GLsizei _width; ///< The width of the texture in pixels.
66 GLsizei _height; ///< The height of the texture in pixels.
67 GLenum _pixelFormat; ///< The OpenGL pixel format.
68 GLenum _pixelType; ///< The OpenGL pixel type.
69 GLenum _internalFormat; ///< The OpenGL internal format.
70 GLuint _textureID; ///< The OpenGL texture id.
71 GLuint _numMipmaps; ///< The number of mip maps generated.
72
73 std::vector<GLubyte> _texels; ///< The image data.
74
76 : _width( 0 )
77 , _height( 0 )
78 , _pixelFormat( 0 )
79 , _pixelType( 0 )
80 , _internalFormat( 0 )
81 , _textureID( 0 )
82 , _numMipmaps( 0 )
83 , _texels()
84 {
85 }
86};
87
88/// Calls necessary GL extension functions for DDS textures.
90
91/// Note: Caller takes ownership of returned data
92/// \param filename The path to the DDS file.
93/// \param loadTexels If true, load image data, otherwise just header information.
94/// \return A new DDSTextureInfo instance containing read data, or NULL.
95DDSTextureInfo* ReadDDSFile( const char* filename, bool loadTexels );
96
97/// Calls the necessary OpenGL functions to bind a DDS texture for drawing.
98/// \param texInfo The texture to draw.
99/// \param skipLevels The number of mip maps to skip.
100/// \return The texture id if successful.
101GLuint BindDDSTexture( DDSTextureInfo* texInfo, unsigned int skipLevels = 0 );
102
103} // namespace disti
104
105#endif // INCLUDED_DISTI_DDSFILE_H
The gls_gl.
Definition: bmpimage.h:46
DDSTextureInfo * ReadDDSFile(const char *filename, bool loadTexels)
void DDSInitExtensions()
Calls necessary GL extension functions for DDS textures.
GLuint BindDDSTexture(DDSTextureInfo *texInfo, unsigned int skipLevels=0)
Definition: ddsfile.h:64
GLuint _numMipmaps
The number of mip maps generated.
Definition: ddsfile.h:71
GLenum _internalFormat
The OpenGL internal format.
Definition: ddsfile.h:69
GLsizei _height
The height of the texture in pixels.
Definition: ddsfile.h:66
GLuint _textureID
The OpenGL texture id.
Definition: ddsfile.h:70
std::vector< GLubyte > _texels
The image data.
Definition: ddsfile.h:73
GLsizei _width
The width of the texture in pixels.
Definition: ddsfile.h:65
GLenum _pixelType
The OpenGL pixel type.
Definition: ddsfile.h:68
GLenum _pixelFormat
The OpenGL pixel format.
Definition: ddsfile.h:67