daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // ResourceManager.h : Defines the ResourceManager class, which tracks objects |
| 8 | // shared by multiple GL contexts. |
| 9 | |
| 10 | #ifndef LIBGLESV2_RESOURCEMANAGER_H_ |
| 11 | #define LIBGLESV2_RESOURCEMANAGER_H_ |
| 12 | |
| 13 | #define GL_APICALL |
| 14 | #include <GLES2/gl2.h> |
| 15 | |
| 16 | #include <map> |
| 17 | |
| 18 | #include "common/angleutils.h" |
| 19 | |
| 20 | namespace gl |
| 21 | { |
| 22 | class Buffer; |
| 23 | class Shader; |
| 24 | class Program; |
| 25 | class Texture; |
| 26 | class Renderbuffer; |
| 27 | |
| 28 | enum SamplerType |
| 29 | { |
| 30 | SAMPLER_2D, |
| 31 | SAMPLER_CUBE, |
| 32 | |
| 33 | SAMPLER_TYPE_COUNT |
| 34 | }; |
| 35 | |
| 36 | class ResourceManager |
| 37 | { |
| 38 | public: |
| 39 | ResourceManager(); |
| 40 | ~ResourceManager(); |
| 41 | |
| 42 | GLuint createBuffer(); |
| 43 | GLuint createShader(GLenum type); |
| 44 | GLuint createProgram(); |
| 45 | GLuint createTexture(); |
| 46 | GLuint createRenderbuffer(); |
| 47 | |
| 48 | void deleteBuffer(GLuint buffer); |
| 49 | void deleteShader(GLuint shader); |
| 50 | void deleteProgram(GLuint program); |
| 51 | void deleteTexture(GLuint texture); |
| 52 | void deleteRenderbuffer(GLuint renderbuffer); |
| 53 | |
| 54 | Buffer *getBuffer(GLuint handle); |
| 55 | Shader *getShader(GLuint handle); |
| 56 | Program *getProgram(GLuint handle); |
| 57 | Texture *getTexture(GLuint handle); |
| 58 | Renderbuffer *getRenderbuffer(GLuint handle); |
| 59 | |
| 60 | void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer); |
| 61 | |
| 62 | void checkBufferAllocation(unsigned int buffer); |
| 63 | void checkTextureAllocation(GLuint texture, SamplerType type); |
| 64 | void checkRenderbufferAllocation(GLuint renderbuffer); |
| 65 | |
| 66 | private: |
| 67 | DISALLOW_COPY_AND_ASSIGN(ResourceManager); |
| 68 | |
| 69 | typedef std::map<GLuint, Buffer*> BufferMap; |
| 70 | BufferMap mBufferMap; |
| 71 | |
| 72 | typedef std::map<GLuint, Shader*> ShaderMap; |
| 73 | ShaderMap mShaderMap; |
| 74 | |
| 75 | typedef std::map<GLuint, Program*> ProgramMap; |
| 76 | ProgramMap mProgramMap; |
| 77 | |
| 78 | typedef std::map<GLuint, Texture*> TextureMap; |
| 79 | TextureMap mTextureMap; |
| 80 | |
| 81 | typedef std::map<GLuint, Renderbuffer*> RenderbufferMap; |
| 82 | RenderbufferMap mRenderbufferMap; |
| 83 | }; |
| 84 | |
| 85 | } |
| 86 | |
| 87 | #endif // LIBGLESV2_RESOURCEMANAGER_H_ |