Otclient  14/8/2020
shadermanager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef SHADERMANAGER_H
24 #define SHADERMANAGER_H
25 
26 #include "declarations.h"
28 
29 //@bindsingleton g_shaders
31 {
32 public:
33  enum {
37  MAP_ZOOM = 12
38  };
39 
40  void init();
41  void terminate();
42 
43  PainterShaderProgramPtr createShader(const std::string& name);
44  PainterShaderProgramPtr createFragmentShader(const std::string& name, std::string file);
45  PainterShaderProgramPtr createFragmentShaderFromCode(const std::string& name, const std::string& code);
46 
47  PainterShaderProgramPtr createItemShader(const std::string& name, const std::string& file);
48  PainterShaderProgramPtr createMapShader(const std::string& name, const std::string& file);
49 
50  const PainterShaderProgramPtr& getDefaultItemShader() { return m_defaultItemShader; }
51  const PainterShaderProgramPtr& getDefaultMapShader() { return m_defaultMapShader; }
52 
53  PainterShaderProgramPtr getShader(const std::string& name);
54 
55 private:
56  void setupItemShader(const PainterShaderProgramPtr& shader);
57  void setupMapShader(const PainterShaderProgramPtr& shader);
58 
59  PainterShaderProgramPtr m_defaultItemShader;
60  PainterShaderProgramPtr m_defaultMapShader;
61  std::unordered_map<std::string, PainterShaderProgramPtr> m_shaders;
62 };
63 
64 
66 
67 #endif
68 
ShaderManager::createItemShader
PainterShaderProgramPtr createItemShader(const std::string &name, const std::string &file)
Definition: shadermanager.cpp:107
paintershaderprogram.h
ShaderManager::terminate
void terminate()
Definition: shadermanager.cpp:44
ShaderManager::createMapShader
PainterShaderProgramPtr createMapShader(const std::string &name, const std::string &file)
Definition: shadermanager.cpp:115
ShaderManager::createFragmentShaderFromCode
PainterShaderProgramPtr createFragmentShaderFromCode(const std::string &name, const std::string &code)
Definition: shadermanager.cpp:86
ShaderManager::getDefaultMapShader
const PainterShaderProgramPtr & getDefaultMapShader()
Definition: shadermanager.h:51
ShaderManager::MAP_ZOOM
@ MAP_ZOOM
Definition: shadermanager.h:37
ShaderManager::MAP_GLOBAL_COORD
@ MAP_GLOBAL_COORD
Definition: shadermanager.h:36
declarations.h
ShaderManager::getDefaultItemShader
const PainterShaderProgramPtr & getDefaultItemShader()
Definition: shadermanager.h:50
ShaderManager::getShader
PainterShaderProgramPtr getShader(const std::string &name)
Definition: shadermanager.cpp:139
ShaderManager::createFragmentShader
PainterShaderProgramPtr createFragmentShader(const std::string &name, std::string file)
Definition: shadermanager.cpp:63
ShaderManager
Definition: shadermanager.h:30
ShaderManager::MAP_CENTER_COORD
@ MAP_CENTER_COORD
Definition: shadermanager.h:35
ShaderManager::ITEM_ID_UNIFORM
@ ITEM_ID_UNIFORM
Definition: shadermanager.h:34
g_shaders
ShaderManager g_shaders
Definition: shadermanager.cpp:29
stdext::shared_object_ptr< PainterShaderProgram >
ShaderManager::createShader
PainterShaderProgramPtr createShader(const std::string &name)
Definition: shadermanager.cpp:51
ShaderManager::init
void init()
Definition: shadermanager.cpp:31