1 /*
2  * Copyright © 2008 Ben Smith
3  * Copyright © 2010-2011 Linaro Limited
4  *
5  * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6  *
7  * glmark2 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * glmark2.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Authors:
21  *  Ben Smith (original glmark benchmark)
22  *  Alexandros Frantzis (glmark2)
23  */
24 #ifndef GLMARK2_TEXTURE_H_
25 #define GLMARK2_TEXTURE_H_
26 
27 #include "gl-headers.h"
28 
29 #include <string>
30 #include <map>
31 
32 /**
33  * A descriptor for a texture file.
34  */
35 class TextureDescriptor
36 {
37 public:
38     enum FileType {
39         FileTypeUnknown,
40         FileTypePNG,
41         FileTypeJPEG,
42     };
43 
TextureDescriptor(const std::string & name,const std::string & pathname,FileType filetype)44     TextureDescriptor(const std::string& name, const std::string& pathname,
45                       FileType filetype) :
46         name_(name),
47         pathname_(pathname),
48         filetype_(filetype) {}
~TextureDescriptor()49     ~TextureDescriptor() {}
pathname()50     const std::string& pathname() const { return pathname_; }
filetype()51     FileType filetype() const { return filetype_; }
52 private:
53     std::string name_;
54     std::string pathname_;
55     FileType filetype_;
56     TextureDescriptor();
57 };
58 
59 typedef std::map<std::string, TextureDescriptor*> TextureMap;
60 
61 class Texture
62 {
63 public:
64     /**
65      * Load a texture by name.
66      *
67      * You must initialize the available texture collection using
68      * Texture::find_textures() before using this method.
69      *
70      * @name:        the texture name
71      *
72      * @return:      true if the operation succeeded, false otherwise
73      */
74     static bool load(const std::string &name, GLuint *pTexture, ...);
75     /**
76      * Locate all available textures.
77      *
78      * This method scans the built-in data paths and builds a database of usable
79      * textures available to scenes.  Map is available on a read-only basis to
80      * scenes that might find it useful for listing textures, etc.
81      *
82      * @return:     a map containing information about the located textures
83      */
84     static const TextureMap& find_textures();
85 };
86 
87 #endif
88