00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00015 #include "nvsgcommon.h"
00016
00017 #include <set>
00018 #include "nvgl/nvgl.h"
00019 #include "nvutil/RCObject.h"
00020
00021 namespace nvsg
00022 {
00023 class Texture;
00024 }
00025
00026 namespace nvgl
00027 {
00029 class GLObjects
00030 {
00031 friend class GLContext;
00032
00033 public:
00034
00035 GLObjects();
00036 ~GLObjects();
00037
00038 public:
00040 void addBuffers(GLsizei n, const GLuint * names);
00041
00043 void removeBuffers(GLsizei n, const GLuint * names);
00044
00046 void addLists(GLsizei n, GLuint first);
00047
00049 void removeLists(GLsizei n, GLuint first);
00050
00052 void addPrograms(GLsizei n, const GLuint * names);
00053
00055 void removePrograms(GLsizei n, const GLuint * names);
00056
00058 void addTextures(GLsizei n, const GLuint * names);
00059
00061 void removeTextures(GLsizei n, const GLuint * names);
00062
00064 void addOcclusionQueries(GLsizei n, const GLuint * names);
00065
00067 void removeOcclusionQueries(GLsizei n, const GLuint * names);
00068
00070 void addQueries(GLsizei n, const GLuint * names);
00071
00073 void removeQueries(GLsizei n, const GLuint * names);
00074
00075 private:
00076
00077 struct GLShareables : public nvutil::RCObject
00078 {
00079 ~GLShareables();
00080
00081 std::set<GLuint> m_vboNames;
00082 std::set<GLuint> m_dlistNames;
00083 std::set<GLuint> m_programNames;
00084 std::set<GLuint> m_textureNames;
00085 std::map<std::string, const nvsg::Texture*> m_texLUT;
00086 };
00087
00088
00089 GLShareables * m_shareables;
00090
00091 std::set<GLuint> m_occlusionQueryNames;
00092 std::set<GLuint> m_queryNames;
00093 };
00094
00095 inline void GLObjects::addBuffers(GLsizei n, const GLuint * names)
00096 {
00097 __ASSERT(n>0 && names);
00098 m_shareables->m_vboNames.insert(&names[0], &names[n]);
00099 }
00100
00101 inline void GLObjects::removeBuffers(GLsizei n, const GLuint * names)
00102 {
00103 __ASSERT(n>0 && names);
00104 for( GLsizei i=0; i<n; ++i )
00105 {
00106 m_shareables->m_vboNames.erase(names[i]);
00107 }
00108 }
00109
00110 inline void GLObjects::addLists(GLsizei n, GLuint first)
00111 {
00112 __ASSERT(n>0 && first>0);
00113 for( GLuint i=first; i<first+n; ++i )
00114 {
00115 m_shareables->m_dlistNames.insert(i);
00116 }
00117 }
00118
00119 inline void GLObjects::removeLists(GLsizei n, GLuint first)
00120 {
00121 __ASSERT(n>0 && first>0);
00122 for( GLuint i=first; i<first+n; ++i )
00123 {
00124 m_shareables->m_dlistNames.erase(i);
00125 }
00126 }
00127
00128 inline void GLObjects::addPrograms(GLsizei n, const GLuint * names)
00129 {
00130 __ASSERT(n>0 && names);
00131 m_shareables->m_programNames.insert(&names[0], &names[n]);
00132 }
00133
00134 inline void GLObjects::removePrograms(GLsizei n, const GLuint * names)
00135 {
00136 __ASSERT(n>0 && names);
00137 for( GLsizei i=0; i<n; ++i )
00138 {
00139 m_shareables->m_programNames.erase(names[i]);
00140 }
00141 }
00142
00143 inline void GLObjects::addTextures(GLsizei n, const GLuint * names)
00144 {
00145 __ASSERT(n>0 && names);
00146 m_shareables->m_textureNames.insert(&names[0], &names[n]);
00147 }
00148
00149 inline void GLObjects::removeTextures(GLsizei n, const GLuint * names)
00150 {
00151 __ASSERT(n>0 && names);
00152 for( GLsizei i=0; i<n; ++i )
00153 {
00154 m_shareables->m_textureNames.erase(names[i]);
00155 }
00156 }
00157
00158 inline void GLObjects::addOcclusionQueries(GLsizei n, const GLuint * names)
00159 {
00160 __ASSERT(n>0 && names);
00161 m_occlusionQueryNames.insert(&names[0], &names[n]);
00162 }
00163
00164 inline void GLObjects::removeOcclusionQueries(GLsizei n, const GLuint * names)
00165
00166 {
00167 __ASSERT(n>0 && names);
00168 for( GLsizei i=0; i<n; ++i )
00169 {
00170 m_occlusionQueryNames.erase(names[i]);
00171 }
00172 }
00173
00174 inline void GLObjects::addQueries(GLsizei n, const GLuint * names)
00175 {
00176 __ASSERT(n>0 && names);
00177 m_queryNames.insert(&names[0], &names[n]);
00178 }
00179
00180 inline void GLObjects::removeQueries(GLsizei n, const GLuint * names)
00181
00182 {
00183 __ASSERT(n>0 && names);
00184 for( GLsizei i=0; i<n; ++i )
00185 {
00186 m_queryNames.erase(names[i]);
00187 }
00188 }
00189
00190 }