OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreGLESTexture.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
8 Copyright (c) 2000-2011 Torus Knot Software Ltd
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 
30 #ifndef __GLESTexture_H__
31 #define __GLESTexture_H__
32 
33 #include "OgreGLESPrerequisites.h"
34 #include "OgreGLESSupport.h"
35 #include "OgrePlatform.h"
36 #include "OgreRenderTexture.h"
37 #include "OgreTexture.h"
39 
40 namespace Ogre {
42  {
43  public:
44  // Constructor
45  GLESTexture(ResourceManager* creator, const String& name, ResourceHandle handle,
46  const String& group, bool isManual, ManualResourceLoader* loader,
47  GLESSupport& support);
48 
49  virtual ~GLESTexture();
50 
51  void createRenderTexture();
53  HardwarePixelBufferSharedPtr getBuffer(size_t face, size_t mipmap);
54 
55  // Takes the OGRE texture type (1d/2d/3d/cube) and returns the appropriate GL one
56  GLenum getGLESTextureTarget(void) const;
57 
58  GLuint getGLID() const
59  {
60  return mTextureID;
61  }
62 
63  protected:
65  void createInternalResourcesImpl(void);
67  void prepareImpl(void);
69  void unprepareImpl(void);
71  void loadImpl(void);
73  void freeInternalResourcesImpl(void);
74 
80  void _createSurfaceList();
81 
84 
90 
91  private:
92  GLuint mTextureID;
94 
96  typedef std::vector<HardwarePixelBufferSharedPtr> SurfaceList;
98 
99  };
100 
107  class _OgreGLESExport GLESTexturePtr : public SharedPtr<GLESTexture>
108  {
109  public:
113 
115  {
116  // lock & copy other mutex pointer
117  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
118  {
119  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
120  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
121  pRep = static_cast<GLESTexture*>(r.getPointer());
122  pUseCount = r.useCountPointer();
123  if (pUseCount)
124  {
125  ++(*pUseCount);
126  }
127  }
128  }
129 
131  {
132  *this = r;
133  }
134 
137  {
138  if (pRep == static_cast<GLESTexture*>(r.getPointer()))
139  {
140  return *this;
141  }
142  release();
143  // lock & copy other mutex pointer
144  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
145  {
146  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
147  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
148  pRep = static_cast<GLESTexture*>(r.getPointer());
149  pUseCount = r.useCountPointer();
150  if (pUseCount)
151  {
152  ++(*pUseCount);
153  }
154  }
155  else
156  {
157  // RHS must be a null pointer
158  assert(r.isNull() && "RHS must be null if it has no mutex!");
159  setNull();
160  }
161  return *this;
162  }
163 
166  {
167  if (pRep == static_cast<GLESTexture*>(r.getPointer()))
168  return *this;
169  release();
170  // lock & copy other mutex pointer
171  OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
172  {
173  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
174  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
175  pRep = static_cast<GLESTexture*>(r.getPointer());
176  pUseCount = r.useCountPointer();
177  if (pUseCount)
178  {
179  ++(*pUseCount);
180  }
181  }
182  else
183  {
184  // RHS must be a null pointer
185  assert(r.isNull() && "RHS must be null if it has no mutex!");
186  setNull();
187  }
188  return *this;
189  }
190  };
191 }
192 
193 #endif
LoadedImages mLoadedImages
Vector of images that were pulled from disk by prepareLoad but have yet to be pushed into texture mem...
GLESTexturePtr & operator=(const TexturePtr &r)
Operator used to convert a TexturePtr to a GLESTexturePtr.
T * getPointer() const
SurfaceList mSurfaceList
#define OGRE_MUTEX_CONDITIONAL(name)
SharedPtr< std::vector< Image > > LoadedImages
Used to hold images between calls to prepare and load.
Interface describing a manual resource loader.
Definition: OgreResource.h:512
#define _OgreGLESExport
GLESTexturePtr & operator=(const ResourcePtr &r)
Operator used to convert a ResourcePtr to a GLESTexturePtr.
Specialisation of SharedPtr to allow SharedPtr to be assigned to TexturePtr.
Definition: OgreTexture.h:440
GLuint getGLID() const
Shared pointer implementation used to share pixel buffers.
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
#define OGRE_LOCK_MUTEX(name)
GLESTexturePtr(GLESTexture *rep)
Specialisation of SharedPtr to allow SharedPtr to be assigned to GLESTexturePtr.
Defines a generic resource handler.
unsigned int * useCountPointer() const
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:60
std::vector< HardwarePixelBufferSharedPtr > SurfaceList
Vector of pointers to subsurfaces.
_StringBase String
Abstract class representing a Texture resource.
Definition: OgreTexture.h:101
GLESSupport & mGLSupport
#define OGRE_COPY_AUTO_SHARED_MUTEX(from)
GLESTexturePtr(const ResourcePtr &r)
GLESTexturePtr(const TexturePtr &r)
bool isNull(void) const
GLESTexturePtr(const GLESTexturePtr &r)