Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/RenderSystems/GL/src/OgreGLRenderTexture.cpp @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

  • Property svn:executable set to *
File size: 4.4 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#include "OgreGLRenderTexture.h"
30#include "OgreGLPixelFormat.h"
31#include "OgreLogManager.h"
32#include "OgreStringConverter.h"
33#include "OgreRoot.h"
34#include "OgreGLHardwarePixelBuffer.h"
35
36namespace Ogre {
37
38
39//-----------------------------------------------------------------------------
40
41template<> GLRTTManager* Singleton<GLRTTManager>::ms_Singleton = 0;
42    GLRTTManager::~GLRTTManager()
43    {
44    }
45    MultiRenderTarget* GLRTTManager::createMultiRenderTarget(const String & name)
46    {
47        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "MultiRenderTarget can only be used with GL_EXT_framebuffer_object extension", "GLRTTManager::createMultiRenderTarget");
48    }
49    PixelFormat GLRTTManager::getSupportedAlternative(PixelFormat format)
50    {
51        if(checkFormat(format))
52            return format;
53        /// Find first alternative
54        PixelComponentType pct = PixelUtil::getComponentType(format);
55        switch(pct)
56        {
57        case PCT_BYTE: format = PF_A8R8G8B8; break;
58        case PCT_SHORT: format = PF_SHORT_RGBA; break;
59        case PCT_FLOAT16: format = PF_FLOAT16_RGBA; break;
60        case PCT_FLOAT32: format = PF_FLOAT32_RGBA; break;
61        }
62        if(checkFormat(format))
63            return format;
64        /// If none at all, return to default
65        return PF_A8R8G8B8;
66    }
67//----------------------------------------------------------------------------- 
68    GLRenderTexture::GLRenderTexture(const String &name, const GLSurfaceDesc &target):
69        RenderTexture(target.buffer, target.zoffset)
70    {
71        mName = name;
72    }
73    GLRenderTexture::~GLRenderTexture()
74    {
75    }
76//----------------------------------------------------------------------------- 
77    GLCopyingRenderTexture::GLCopyingRenderTexture(GLCopyingRTTManager *manager, const String &name, const GLSurfaceDesc &target):
78        GLRenderTexture(name, target)
79    {
80    }
81    void GLCopyingRenderTexture::getCustomAttribute(const String& name, void* pData)
82    {
83        if(name=="TARGET")
84        {
85                        GLSurfaceDesc &target = *static_cast<GLSurfaceDesc*>(pData);
86                        target.buffer = static_cast<GLHardwarePixelBuffer*>(mBuffer);
87                        target.zoffset = mZOffset;
88        }
89    }
90//----------------------------------------------------------------------------- 
91    GLCopyingRTTManager::GLCopyingRTTManager()
92    {
93    } 
94    GLCopyingRTTManager::~GLCopyingRTTManager()
95    {
96    }
97
98    RenderTexture *GLCopyingRTTManager::createRenderTexture(const String &name, const GLSurfaceDesc &target)
99    {
100        return new GLCopyingRenderTexture(this, name, target);
101    }
102   
103    bool GLCopyingRTTManager::checkFormat(PixelFormat format) 
104    { 
105        return true; 
106    }
107
108    void GLCopyingRTTManager::bind(RenderTarget *target)
109    {
110        // Nothing to do here
111    }
112
113    void GLCopyingRTTManager::unbind(RenderTarget *target)
114    {
115        // Copy on unbind
116        GLSurfaceDesc surface;
117                surface.buffer = 0;
118        target->getCustomAttribute("TARGET", &surface);
119        if(surface.buffer)
120            static_cast<GLTextureBuffer*>(surface.buffer)->copyFromFramebuffer(surface.zoffset);
121    }
122        //---------------------------------------------------------------------------------------------
123
124}
125
Note: See TracBrowser for help on using the repository browser.