source: OGRE/trunk/ogrenew/RenderSystems/GL/src/OgreGLHardwareBufferManager.cpp @ 657

Revision 657, 4.2 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

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-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 "OgreGLHardwareBufferManager.h"
26#include "OgreGLHardwareVertexBuffer.h"
27#include "OgreGLHardwareIndexBuffer.h"
28#include "OgreHardwareBuffer.h"
29
30namespace Ogre {
31    //-----------------------------------------------------------------------
32    GLHardwareBufferManager::GLHardwareBufferManager()
33    {
34    }
35    //-----------------------------------------------------------------------
36    GLHardwareBufferManager::~GLHardwareBufferManager()
37    {
38        destroyAllDeclarations();
39        destroyAllBindings();
40    }
41    //-----------------------------------------------------------------------
42    HardwareVertexBufferSharedPtr GLHardwareBufferManager::createVertexBuffer(
43        size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
44    {
45                return HardwareVertexBufferSharedPtr(
46                        new GLHardwareVertexBuffer(vertexSize, numVerts, usage, useShadowBuffer) );
47    }
48    //-----------------------------------------------------------------------
49    HardwareIndexBufferSharedPtr
50    GLHardwareBufferManager:: createIndexBuffer(
51        HardwareIndexBuffer::IndexType itype, size_t numIndexes,
52        HardwareBuffer::Usage usage, bool useShadowBuffer)
53    {
54                return HardwareIndexBufferSharedPtr(
55                        new GLHardwareIndexBuffer(itype, numIndexes, usage, useShadowBuffer) );
56    }
57    //-----------------------------------------------------------------------
58    VertexDeclaration* GLHardwareBufferManager::createVertexDeclaration(void)
59    {
60        VertexDeclaration* decl = new VertexDeclaration();
61        mVertexDeclarations.push_back(decl);
62        return decl;
63    }
64    //-----------------------------------------------------------------------
65    void GLHardwareBufferManager::destroyVertexDeclaration(VertexDeclaration* decl)
66    {
67        mVertexDeclarations.remove(decl);
68        delete decl;
69    }
70    //---------------------------------------------------------------------
71    GLenum GLHardwareBufferManager::getGLUsage(unsigned int usage)
72    {
73        switch(usage)
74        {
75        case HardwareBuffer::HBU_STATIC:
76        case HardwareBuffer::HBU_STATIC_WRITE_ONLY:
77            return GL_STATIC_DRAW_ARB;
78        case HardwareBuffer::HBU_DYNAMIC:
79        case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY:
80            return GL_DYNAMIC_DRAW_ARB;
81        case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE:
82            return GL_STREAM_DRAW_ARB;
83        default:
84            return GL_DYNAMIC_DRAW_ARB;
85        };
86    }
87    //---------------------------------------------------------------------
88    GLenum GLHardwareBufferManager::getGLType(unsigned int type)
89    {
90        switch(type)
91        {
92            case VET_FLOAT1:
93            case VET_FLOAT2:
94            case VET_FLOAT3:
95            case VET_FLOAT4:
96                return GL_FLOAT;
97            case VET_SHORT1:
98            case VET_SHORT2:
99            case VET_SHORT3:
100            case VET_SHORT4:
101                return GL_SHORT;
102            case VET_COLOUR:
103            case VET_UBYTE4:
104                return GL_UNSIGNED_BYTE;
105            default:
106                return 0;
107        };
108    }
109}
Note: See TracBrowser for help on using the repository browser.