| 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
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. Use, distribution,
38 duplication, 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
63 namespace disti
64{
65/// \details The DDSTextureInfo struct. Holds the file header information of the DDS format.
66 struct DDSTextureInfo
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
78 DDSTextureInfo()
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.
92 void DDSInitExtensions();
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.
98 DDSTextureInfo* 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.
104 GLuint BindDDSTexture( DDSTextureInfo* texInfo, unsigned int skipLevels = 0 );
105
106} // namespace disti
107
108#endif // INCLUDED_DISTI_DDSFILE_H
gls_gl.h
The gls_gl.
disti
Definition: bmpimage.h:47
disti::ReadDDSFile
DDSTextureInfo * ReadDDSFile(const char *filename, bool loadTexels)
disti::DDSInitExtensions
void DDSInitExtensions()
Calls necessary GL extension functions for DDS textures.
disti::BindDDSTexture
GLuint BindDDSTexture(DDSTextureInfo *texInfo, unsigned int skipLevels=0)
disti::DDSTextureInfo
Definition: ddsfile.h:67
disti::DDSTextureInfo::_numMipmaps
GLuint _numMipmaps
The number of mip maps generated.
Definition: ddsfile.h:74
disti::DDSTextureInfo::_internalFormat
GLenum _internalFormat
The OpenGL internal format.
Definition: ddsfile.h:72
disti::DDSTextureInfo::_height
GLsizei _height
The height of the texture in pixels.
Definition: ddsfile.h:69
disti::DDSTextureInfo::_textureID
GLuint _textureID
The OpenGL texture id.
Definition: ddsfile.h:73
disti::DDSTextureInfo::_texels
std::vector< GLubyte > _texels
The image data.
Definition: ddsfile.h:76
disti::DDSTextureInfo::_width
GLsizei _width
The width of the texture in pixels.
Definition: ddsfile.h:68
disti::DDSTextureInfo::_pixelType
GLenum _pixelType
The OpenGL pixel type.
Definition: ddsfile.h:71
disti::DDSTextureInfo::_pixelFormat
GLenum _pixelFormat
The OpenGL pixel format.
Definition: ddsfile.h:70