aboutsummaryrefslogtreecommitdiff
path: root/glox/glox/GloxTextureFactory.hpp
blob: cf8a9191de299d2f37495b612f950a5e93b63003 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef GLOXTEXTUREFACTORY_HPP_
#define GLOXTEXTUREFACTORY_HPP_

/*
 * Author: jrahm
 * created: 2013/10/22
 * GloxTextureFactory.hpp: <description>
 */

#include "glox/GloxTexture.hpp"

#include <fstream>
#include <iostream>
#include <string>

namespace glox {

/* This is a static class that builds
 * texture objects. The textures can then
 * be pinned onto objects */
class GloxTextureFactory {
 public:
  /* Creates a new texture from a bitmap
     * image. If there is an error, NULL is
     * returned */
  static GloxTexture* textureFromBitmap(std::istream& stream);
  static inline GloxTexture* textureFromBitmapFile(const char* filename) {
    std::ifstream ifs;
    ifs.open(filename, std::ifstream::binary);

    if (!ifs.is_open()) {
      return NULL;
    }
    return textureFromBitmap(ifs);
  }

#ifndef NO_JPG_SUPPORT
  static GloxTexture* buildTextureFromJpg(std::istream& stream);
#endif

#ifndef NO_PNG_SUPPORT
  static GloxTexture* buildTextureFromPng(std::istream& stream);
#endif

  static const std::string& getErrorMessage();
};

}  // namespace glox

#endif /* GLOXTEXTUREFACTORY_HPP_ */