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) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include "OgreGLTextureManager.h"
|
---|
27 |
|
---|
28 | namespace Ogre {
|
---|
29 | //-----------------------------------------------------------------------------
|
---|
30 | GLTextureManager::GLTextureManager(GLSupport& support)
|
---|
31 | : TextureManager(), mGLSupport(support), mWarningTextureID(0)
|
---|
32 | {
|
---|
33 | // register with group manager
|
---|
34 | ResourceGroupManager::getSingleton()._registerResourceManager(mResourceType, this);
|
---|
35 |
|
---|
36 | createWarningTexture();
|
---|
37 | }
|
---|
38 | //-----------------------------------------------------------------------------
|
---|
39 | GLTextureManager::~GLTextureManager()
|
---|
40 | {
|
---|
41 | // unregister with group manager
|
---|
42 | ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType);
|
---|
43 | // Delete warning texture
|
---|
44 | glDeleteTextures(1, &mWarningTextureID);
|
---|
45 | }
|
---|
46 | //-----------------------------------------------------------------------------
|
---|
47 | Resource* GLTextureManager::createImpl(const String& name, ResourceHandle handle,
|
---|
48 | const String& group, bool isManual, ManualResourceLoader* loader,
|
---|
49 | const NameValuePairList* createParams)
|
---|
50 | {
|
---|
51 | return new GLTexture(this, name, handle, group, isManual, loader, mGLSupport);
|
---|
52 | }
|
---|
53 |
|
---|
54 | //-----------------------------------------------------------------------------
|
---|
55 | void GLTextureManager::createWarningTexture()
|
---|
56 | {
|
---|
57 | // Generate warning texture
|
---|
58 | size_t width = 8;
|
---|
59 | size_t height = 8;
|
---|
60 | uint32 *data = new uint32[width*height]; // 0xXXRRGGBB
|
---|
61 | // Yellow/black stripes
|
---|
62 | for(size_t y=0; y<height; ++y)
|
---|
63 | {
|
---|
64 | for(size_t x=0; x<width; ++x)
|
---|
65 | {
|
---|
66 | data[y*width+x] = (((x+y)%8)<4)?0x000000:0xFFFF00;
|
---|
67 | }
|
---|
68 | }
|
---|
69 | // Create GL resource
|
---|
70 | glGenTextures(1, &mWarningTextureID);
|
---|
71 | glBindTexture(GL_TEXTURE_2D, mWarningTextureID);
|
---|
72 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
---|
73 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (void*)data);
|
---|
74 | // Free memory
|
---|
75 | delete [] data;
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 | }
|
---|