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 default: 00091 return GL_DYNAMIC_DRAW_ARB; 00092 }; 00093 } 00094 //--------------------------------------------------------------------- 00095 GLenum GLHardwareBufferManager::getGLType(unsigned int type) 00096 { 00097 switch(type) 00098 { 00099 case VET_FLOAT1: 00100 case VET_FLOAT2: 00101 case VET_FLOAT3: 00102 case VET_FLOAT4: 00103 return GL_FLOAT; 00104 case VET_SHORT1: 00105 case VET_SHORT2: 00106 case VET_SHORT3: 00107 case VET_SHORT4: 00108 return GL_SHORT; 00109 case VET_COLOUR: 00110 case VET_UBYTE4: 00111 return GL_UNSIGNED_BYTE; 00112 default: 00113 return 0; 00114 }; 00115 } 00116 }
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:11 2004