mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 08:30:04 +00:00 
			
		
		
		
	Manage texture atlas in GL context
This commit is contained in:
		
							parent
							
								
									e4629eb9ef
								
							
						
					
					
						commit
						fb37139073
					
				
					 2 changed files with 16 additions and 0 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| #include <scwx/qt/gl/gl_context.hpp> | ||||
| #include <scwx/qt/util/streams.hpp> | ||||
| #include <scwx/qt/util/texture_atlas.hpp> | ||||
| #include <scwx/util/hash.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
|  | @ -29,6 +30,7 @@ public: | |||
|        shaderProgramMap_ {}, | ||||
|        shaderProgramMutex_ {}, | ||||
|        textureMap_ {}, | ||||
|        textureAtlas_ {GL_INVALID_INDEX}, | ||||
|        textureMutex_ {} | ||||
|    { | ||||
|    } | ||||
|  | @ -45,6 +47,7 @@ public: | |||
|    std::mutex shaderProgramMutex_; | ||||
| 
 | ||||
|    std::unordered_map<std::string, GLuint> textureMap_; | ||||
|    GLuint                                  textureAtlas_; | ||||
|    std::mutex                              textureMutex_; | ||||
| }; | ||||
| 
 | ||||
|  | @ -84,6 +87,18 @@ GlContext::GetShaderProgram(const std::string& vertexPath, | |||
|    return shaderProgram; | ||||
| } | ||||
| 
 | ||||
| GLuint GlContext::GetTextureAtlas() | ||||
| { | ||||
|    std::unique_lock lock(p->textureMutex_); | ||||
| 
 | ||||
|    if (p->textureAtlas_ == GL_INVALID_INDEX) | ||||
|    { | ||||
|       p->textureAtlas_ = util::TextureAtlas::Instance().BufferAtlas(p->gl_); | ||||
|    } | ||||
| 
 | ||||
|    return p->textureAtlas_; | ||||
| } | ||||
| 
 | ||||
| GLuint GlContext::GetTexture(const std::string& texturePath) | ||||
| { | ||||
|    GLuint texture = GL_INVALID_INDEX; | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ public: | |||
|    GetShaderProgram(const std::string& vertexPath, | ||||
|                     const std::string& fragmentPath); | ||||
| 
 | ||||
|    GLuint GetTextureAtlas(); | ||||
|    GLuint GetTexture(const std::string& texturePath); | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat