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