GL Studio C++ Runtime API
texture_loader.h
Go to the documentation of this file.
1/*! \file
2 \brief The TextureLoader and TextureLoaderList classes.
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.
38
39*/
40#ifndef INCLUDED_TEXTURE_LOADER_H
41#define INCLUDED_TEXTURE_LOADER_H
42
43#include "gls_include.h"
44#include "image.h"
45#include "list.h"
46#include "plugin.h"
47
48namespace disti
49{
50class TextureLoader;
51
52/**
53 A list of (pointers to) texture loader objects.
54*/
56{
57 static GLS_EXPORT TextureLoaderList* _instance; /** A singleton interface */
58
59public:
61
62 /** A singleton interface
63 * \return A pointer to the one and only instance
64 */
66
67 /** enable / disable texture loading optimization (defaults to enabled)
68 * \param enable true to enable else false
69 */
70 static GLS_EXPORT void SetOptimizeTextureLoading( const bool enable );
71
72 /** determine if texture loading optimization is enabled
73 * \return true if enabled else false
74 */
76
77 /** Insert the loader into the list at the specified location
78 * \param importer
79 */
81
82 /** Creates and returns a file filter string for all of the file types that have been
83 * registered by Texture Loaders
84 * \return Filter string */
86
87 /** Load the specified texture file. Try all loaders to see if any of them support
88 * the given file type.
89 * \param filename The file to load the image from
90 * \param options Options to load the image with
91 * \param allowNPOT If the image is allowed to be non-power of two (NPOT)
92 * \return NULL if the file type isn't supported or if loading fails
93 */
94 GLS_EXPORT Image* LoadTexture( const char* filename, const Image::LoadOptions& options, bool allowNPOT = true );
95
96 /** Load the specified texture file optionally attempting to optimize the load by looking at
97 * previously loaded images. Try all loaders to see if any of them support
98 * the given file type.
99 * \param filename The file to load the image from
100 * \param options Options to load the image with
101 * \param optimizeTextureLoad true to attempt loading optimization else false to force a load
102 * \param allowNPOT If the image is allowed to be non-power of two (NPOT)
103 * \return NULL if the file type isn't supported or if loading fails
104 */
105 GLS_EXPORT Image* LoadTextureWithOptimization( const char* filename, const Image::LoadOptions& options, const bool optimizeTextureLoad, bool allowNPOT = true );
106
107#ifdef __APPLE__
108 /** Load the specified texture file optionally attempting to optimize the load by looking at
109 * previously loaded images.
110 *
111 * This method uses the iOS image loader classes to load the textures and thus supports whatever platform native loaders
112 * are supported by the iOS SDK.
113 *
114 * NOTE: This code will also give preference to texture files compressed using PowerVR Texture compression.
115 * The way that works is that if this code is asked to load 'xyz.png' and 'xyz.pvr' is found, then the .pvr
116 * file will be loaded instead.
117 *
118 * \return NULL if the file type isn't supported or if loading fails */
119 GLS_EXPORT Image* LoadTextureIOS( const char* filename, const Image::LoadOptions& options, const bool optimizeTextureLoad );
120#endif
121
122 /** Finds the registered texture loader, if any, that supports the given file
123 * extension.
124 * \param ext The (case insensitive) file extension
125 * \return A pointer to the registered loader, or NULL if no loader exists
126 */
128};
129
130/** The TextureLoader class
131 */
132class TextureLoader : public Plugin
133{
134protected:
136
137public:
138 /** \return A filter string that is used by the windows FileBrowser to build the list of files to
139 * display in the browser
140 */
141 virtual const char* FilterString() = 0;
142
143 /** \return A filter string description that is used by the windows FileBrowser to build the list
144 * of files to display in the browser
145 */
146 virtual const char* FilterDescription() = 0;
147
148 /** \return The name of the header file to include when generating code
149 * for this plugin
150 */
151 virtual const char* GenerateHeader() = 0;
152
153 /** \return The string to be generated to generate an instance of this object
154 */
155 virtual const char* GenerateDeclaration() = 0;
156
157 /** \return The type of plugin
158 */
159 virtual GLS_EXPORT const char* PluginType();
160
161 /// \return TRUE if the file pointer appears to contain an image that can be loaded by this class.
162 /// This method must close the file if it returns TRUE. It must rewind the file if it returns FALSE.
163 /// \param filename The file name to check.
164 virtual bool IsFileType( const char* filename ) = 0;
165
166 /// \return TRUE if the class can load files with the given extension.
167 /// \param ext The file extension to check.
168 virtual bool SupportsExtension( const char* ext ) = 0;
169
170 /** Load the specified texture file. Try all loaders to see if any of them support
171 * the given file type.
172 * \param filename The file to load the image from
173 * \param options Options to load the image with
174 * \param allowNPOT If the image is allowed to be non-power of two (NPOT)
175 * \return NULL if the file type isn't supported or if loading fails
176 */
177 virtual Image* LoadTexture( const char* filename, const Image::LoadOptions& options, bool allowNPOT = true ) = 0;
178
179 /** Adds this file importer to a texture loader list
180 * \param list The texture loader list to add to
181 */
183};
184
185} // namespace disti
186
187#endif
Definition: image.h:286
Definition: image.h:178
Definition: list.h:135
Definition: plugin.h:55
Definition: texture_loader.h:56
TextureLoader * SupportsExtension(const char *ext)
Image * LoadTexture(const char *filename, const Image::LoadOptions &options, bool allowNPOT=true)
static bool IsOptimizeTextureLoading()
Image * LoadTextureWithOptimization(const char *filename, const Image::LoadOptions &options, const bool optimizeTextureLoad, bool allowNPOT=true)
void InsertObject(TextureLoader *importer)
static void SetOptimizeTextureLoading(const bool enable)
static TextureLoaderList * Instance()
Definition: texture_loader.h:133
virtual const char * GenerateHeader()=0
void AddToList(TextureLoaderList *list=TextureLoaderList::Instance())
virtual const char * FilterDescription()=0
virtual const char * GenerateDeclaration()=0
virtual const char * PluginType()
virtual Image * LoadTexture(const char *filename, const Image::LoadOptions &options, bool allowNPOT=true)=0
virtual bool IsFileType(const char *filename)=0
virtual const char * FilterString()=0
virtual bool SupportsExtension(const char *ext)=0
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
The Image class. All textures are converted internally into Images.
The List_c class. Generic linked list.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
The base class for GL Studio plugin file loaders, disti::Plugin.