source: OGRE/trunk/ogrenew/RenderSystems/GL/src/OgreGLRenderTexture.cpp @ 692

Revision 692, 4.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://ogre.sourceforge.net/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#include "OgreGLRenderTexture.h"
26#include "OgreGLPixelFormat.h"
27#include "OgreLogManager.h"
28#include "OgreStringConverter.h"
29#include "OgreRoot.h"
30#include "OgreGLHardwarePixelBuffer.h"
31
32namespace Ogre {
33
34
35//-----------------------------------------------------------------------------
36
37template<> GLRTTManager* Singleton<GLRTTManager>::ms_Singleton = 0;
38    GLRTTManager::~GLRTTManager()
39    {
40    }
41    MultiRenderTarget* GLRTTManager::createMultiRenderTarget(const String & name)
42    {
43        OGRE_EXCEPT(Exception::UNIMPLEMENTED_FEATURE, "MultiRenderTarget can only be used with GL_EXT_framebuffer_object extension", "GLRTTManager::createMultiRenderTarget");
44    }
45    PixelFormat GLRTTManager::getSupportedAlternative(PixelFormat format)
46    {
47        if(checkFormat(format))
48            return format;
49        /// Find first alternative
50        PixelComponentType pct = PixelUtil::getComponentType(format);
51        switch(pct)
52        {
53        case PCT_BYTE: format = PF_A8R8G8B8; break;
54        case PCT_SHORT: format = PF_SHORT_RGBA; break;
55        case PCT_FLOAT16: format = PF_FLOAT16_RGBA; break;
56        case PCT_FLOAT32: format = PF_FLOAT32_RGBA; break;
57        }
58        if(checkFormat(format))
59            return format;
60        /// If none at all, return to default
61        return PF_A8R8G8B8;
62    }
63//----------------------------------------------------------------------------- 
64    GLRenderTexture::GLRenderTexture(const String &name, const GLSurfaceDesc &target):
65        RenderTexture(target.buffer, target.zoffset)
66    {
67        mName = name;
68    }
69    GLRenderTexture::~GLRenderTexture()
70    {
71    }
72//----------------------------------------------------------------------------- 
73    GLCopyingRenderTexture::GLCopyingRenderTexture(GLCopyingRTTManager *manager, const String &name, const GLSurfaceDesc &target):
74        GLRenderTexture(name, target)
75    {
76    }
77    void GLCopyingRenderTexture::getCustomAttribute(const String& name, void* pData)
78    {
79        if(name=="TARGET")
80        {
81                        GLSurfaceDesc &target = *static_cast<GLSurfaceDesc*>(pData);
82                        target.buffer = static_cast<GLHardwarePixelBuffer*>(mBuffer);
83                        target.zoffset = mZOffset;
84        }
85    }
86//----------------------------------------------------------------------------- 
87    GLCopyingRTTManager::GLCopyingRTTManager()
88    {
89    } 
90    GLCopyingRTTManager::~GLCopyingRTTManager()
91    {
92    }
93
94    RenderTexture *GLCopyingRTTManager::createRenderTexture(const String &name, const GLSurfaceDesc &target)
95    {
96        return new GLCopyingRenderTexture(this, name, target);
97    }
98   
99    bool GLCopyingRTTManager::checkFormat(PixelFormat format)
100    {
101        return true;
102    }
103
104    void GLCopyingRTTManager::bind(RenderTarget *target)
105    {
106        // Nothing to do here
107    }
108
109    void GLCopyingRTTManager::unbind(RenderTarget *target)
110    {
111        // Copy on unbind
112        GLSurfaceDesc surface;
113                surface.buffer = 0;
114        target->getCustomAttribute("TARGET", &surface);
115        if(surface.buffer)
116            static_cast<GLTextureBuffer*>(surface.buffer)->copyFromFramebuffer(surface.zoffset);
117    }
118        //---------------------------------------------------------------------------------------------
119
120}
121
Note: See TracBrowser for help on using the repository browser.