PCG-FPS  v2 m0.22.4
Simple First Person Shooter with Procedurally Generated Level
Texture.h
Go to the documentation of this file.
1 #ifndef SKR_FPS2_RENDERER_OPENGL_TEXTURE_H
2 #define SKR_FPS2_RENDERER_OPENGL_TEXTURE_H
3 
4 #include "..\..\pch.h"
5 
6 #include <iostream>
7 #include <string>
8 #include <unordered_map>
9 
10 #include "stb_image.h"
11 
12 namespace skr
13 {
14 namespace fps2
15 {
16 namespace Renderer
17 {
18 namespace OpenGL
19 {
21  enum struct TextureType
22  {
23  EMPTY,
24  DIFFUSE,
25  NORMAL,
26  SPECULAR,
27  HEIGHT
28  };
29 
31  typedef std::unordered_map<TextureType, std::string> TextureTypToStringMap;
32 
34  typedef std::unordered_map<std::string, TextureType> StringToTextureTypeMap;
35 
38  class Texture
39  {
40  public:
41  uint32_t _id;
43  std::string _path;
44 
45  //TODO i would like to keep the maps instead of single strings, because it would make them easier to organize. However, I need to access them without making a deep copy at every draw call, which tanks the framerate
46  //static const std::unordered_map<TextureType, std::string> MapTextureTypToString;
47  //static const std::unordered_map<std::string, TextureType> MapStringToTextureType;
48 
49  static const std::string TextureTypeDiffuse;
50  static const std::string TextureTypeNormal;
51  static const std::string TextureTypeSpecular;
52  static const std::string TextureTypeHeight;
53 
54  public:
58  : _id(0), _type(TextureType::EMPTY), _path("")
59  {};
60 
64  Texture(TextureType type, std::string path);
65 
74  static std::vector<Texture> LoadMaterialTextures(std::vector<Texture>& loadedTexture, std::string dir, aiMaterial* aiMat, aiTextureType aiType, TextureType ttype);
75 
76  private:
81  bool LoadTexture(std::string path);
82  };
83 }
84 }
85 }
86 }
87 
88 #endif
skr::fps2::Renderer::OpenGL::Texture::_type
TextureType _type
TextureType.
Definition: Texture.h:42
skr::fps2::Renderer::OpenGL::TextureTypToStringMap
std::unordered_map< TextureType, std::string > TextureTypToStringMap
mapping table from a texture type to string
Definition: Texture.h:31
skr::fps2::Renderer::OpenGL::Texture
holds all informations for a texture
Definition: Texture.h:39
skr::fps2::Renderer::OpenGL::TextureType::NORMAL
@ NORMAL
normal map
skr::fps2::Renderer::OpenGL::TextureType::HEIGHT
@ HEIGHT
height map. Not used here, but assimp requires it
skr::fps2::Renderer::OpenGL::Texture::_path
std::string _path
path where texture is loaded from
Definition: Texture.h:43
skr::fps2::Renderer::OpenGL::TextureType::DIFFUSE
@ DIFFUSE
diffuse texture
skr::fps2::Renderer::OpenGL::Texture::LoadTexture
bool LoadTexture(std::string path)
load texture from given path texture is bound to _id
Definition: Texture.cpp:77
skr::fps2::Renderer::OpenGL::TextureType::EMPTY
@ EMPTY
no texture
skr::fps2::Renderer::OpenGL::TextureType::SPECULAR
@ SPECULAR
specular map
skr::fps2::Renderer::OpenGL::Texture::TextureTypeHeight
static const std::string TextureTypeHeight
string with name of height map used in shader
Definition: Texture.h:52
skr::fps2::Renderer::OpenGL::StringToTextureTypeMap
std::unordered_map< std::string, TextureType > StringToTextureTypeMap
mapping table from a string to a texture type
Definition: Texture.h:34
skr::fps2::Renderer::OpenGL::Texture::TextureTypeSpecular
static const std::string TextureTypeSpecular
string with name of specular map used in shader
Definition: Texture.h:51
skr
Definition: AssetPath.h:10
skr::fps2::Renderer::OpenGL::Texture::_id
uint32_t _id
id of texture
Definition: Texture.h:41
skr::fps2::Renderer::OpenGL::Texture::Texture
Texture()
default constructor default constructor is needed since OpenGL Renderer Object is a global object,...
Definition: Texture.h:57
skr::fps2::Renderer::OpenGL::Texture::LoadMaterialTextures
static std::vector< Texture > LoadMaterialTextures(std::vector< Texture > &loadedTexture, std::string dir, aiMaterial *aiMat, aiTextureType aiType, TextureType ttype)
loads textures from a model uses loadedTexture-parameter to skip already loaded textures
Definition: Texture.cpp:43
skr::fps2::Renderer::OpenGL::Texture::TextureTypeNormal
static const std::string TextureTypeNormal
string with name of normal map used in shader
Definition: Texture.h:50
skr::fps2::Renderer::OpenGL::Texture::TextureTypeDiffuse
static const std::string TextureTypeDiffuse
string with name of diffuse texture used in shader
Definition: Texture.h:49
skr::fps2::Renderer::OpenGL::TextureType
TextureType
enum types of texture
Definition: Texture.h:22