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

Revision 692, 3.8 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://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    GLenum GLHardwareBufferManager::getGLUsage(unsigned int usage)
59    {
60        switch(usage)
61        {
62        case HardwareBuffer::HBU_STATIC:
63        case HardwareBuffer::HBU_STATIC_WRITE_ONLY:
64            return GL_STATIC_DRAW_ARB;
65        case HardwareBuffer::HBU_DYNAMIC:
66        case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY:
67            return GL_DYNAMIC_DRAW_ARB;
68        case HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE:
69            return GL_STREAM_DRAW_ARB;
70        default:
71            return GL_DYNAMIC_DRAW_ARB;
72        };
73    }
74    //---------------------------------------------------------------------
75    GLenum GLHardwareBufferManager::getGLType(unsigned int type)
76    {
77        switch(type)
78        {
79            case VET_FLOAT1:
80            case VET_FLOAT2:
81            case VET_FLOAT3:
82            case VET_FLOAT4:
83                return GL_FLOAT;
84            case VET_SHORT1:
85            case VET_SHORT2:
86            case VET_SHORT3:
87            case VET_SHORT4:
88                return GL_SHORT;
89            case VET_COLOUR:
90                        case VET_COLOUR_ABGR:
91                        case VET_COLOUR_ARGB:
92            case VET_UBYTE4:
93                return GL_UNSIGNED_BYTE;
94            default:
95                return 0;
96        };
97    }
98}
Note: See TracBrowser for help on using the repository browser.