Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreGLHardwareBufferManager.cpp

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright © 2000-2003 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025 #include "OgreGLHardwareBufferManager.h"
    00026 #include "OgreGLHardwareVertexBuffer.h"
    00027 #include "OgreGLHardwareIndexBuffer.h"
    00028 #include "OgreHardwareBuffer.h"
    00029
    00030 namespace Ogre {
    00031     //-----------------------------------------------------------------------
    00032     GLHardwareBufferManager::GLHardwareBufferManager()
    00033     {
    00034     }
    00035     //-----------------------------------------------------------------------
    00036     GLHardwareBufferManager::~GLHardwareBufferManager()
    00037     {
    00038         destroyAllDeclarations();
    00039         destroyAllBindings();
    00040     }
    00041     //-----------------------------------------------------------------------
    00042     HardwareVertexBufferSharedPtr GLHardwareBufferManager::createVertexBuffer(
    00043         size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
    00044     {
    00045         return HardwareVertexBufferSharedPtr(
    00046             new GLHardwareVertexBuffer(vertexSize, numVerts, usage, useShadowBuffer) );
    00047     }
    00048     //-----------------------------------------------------------------------
    00049     void GLHardwareBufferManager::destroyVertexBuffer(HardwareVertexBuffer* buf)
    00050     {
    00051         delete buf;
    00052     }
    00053     //-----------------------------------------------------------------------
    00054     HardwareIndexBufferSharedPtr
    00055     GLHardwareBufferManager:: createIndexBuffer(
    00056         HardwareIndexBuffer::IndexType itype, size_t numIndexes,
    00057         HardwareBuffer::Usage usage, bool useShadowBuffer)
    00058     {
    00059         return HardwareIndexBufferSharedPtr(
    00060             new GLHardwareIndexBuffer(itype, numIndexes, usage, useShadowBuffer) );
    00061     }
    00062     //-----------------------------------------------------------------------
    00063     void GLHardwareBufferManager::destroyIndexBuffer(HardwareIndexBuffer* buf)
    00064     {
    00065         delete buf;
    00066     }
    00067     //-----------------------------------------------------------------------
    00068     VertexDeclaration* GLHardwareBufferManager::createVertexDeclaration(void)
    00069     {
    00070         VertexDeclaration* decl = new VertexDeclaration();
    00071         mVertexDeclarations.push_back(decl);
    00072         return decl;
    00073     }
    00074     //-----------------------------------------------------------------------
    00075     void GLHardwareBufferManager::destroyVertexDeclaration(VertexDeclaration* decl)
    00076     {
    00077         mVertexDeclarations.remove(decl);
    00078         delete decl;
    00079     }
    00080     //---------------------------------------------------------------------
    00081     GLenum GLHardwareBufferManager::getGLUsage(unsigned int usage)
    00082     {
    00083         switch(usage)
    00084         {
    00085         case HardwareBuffer::HBU_STATIC:
    00086         case HardwareBuffer::HBU_STATIC_WRITE_ONLY:
    00087             return GL_STATIC_DRAW_ARB;
    00088         case HardwareBuffer::HBU_DYNAMIC:
    00089         case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY:
    00090             return GL_DYNAMIC_DRAW_ARB;
    00091         case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE:
    00092             return GL_STREAM_DRAW_ARB;
    00093         default:
    00094             return GL_DYNAMIC_DRAW_ARB;
    00095         };
    00096     }
    00097     //---------------------------------------------------------------------
    00098     GLenum GLHardwareBufferManager::getGLType(unsigned int type)
    00099     {
    00100         switch(type)
    00101         {
    00102             case VET_FLOAT1:
    00103             case VET_FLOAT2:
    00104             case VET_FLOAT3:
    00105             case VET_FLOAT4:
    00106                 return GL_FLOAT;
    00107             case VET_SHORT1:
    00108             case VET_SHORT2:
    00109             case VET_SHORT3:
    00110             case VET_SHORT4:
    00111                 return GL_SHORT;
    00112             case VET_COLOUR:
    00113             case VET_UBYTE4:
    00114                 return GL_UNSIGNED_BYTE;
    00115             default:
    00116                 return 0;
    00117         };
    00118     }
    00119 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:25 2004