root/OpenSceneGraph/trunk/src/osg/BufferIndexBinding.cpp @ 13041

Revision 13041, 3.1 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 * Copyright (C) 2010 Tim Moore
3 *
4 * This library is open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version.  The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * OpenSceneGraph Public License for more details.
13*/
14
15#include <osg/BufferIndexBinding>
16#include <osg/State>
17
18namespace osg {
19
20BufferIndexBinding::BufferIndexBinding(GLenum target, GLuint index)
21    : _target(target), _index(index), _offset(0), _size(0)
22{
23}
24
25BufferIndexBinding::BufferIndexBinding(GLenum target, GLuint index, BufferObject* bo,
26                                       GLintptr offset, GLsizeiptr size)
27    : _target(target), _index(index), _bufferObject(bo), _offset(offset), _size(size)
28{
29}
30
31BufferIndexBinding::BufferIndexBinding(const BufferIndexBinding& rhs, const CopyOp& copyop)
32    : StateAttribute(rhs, copyop),
33      _target(rhs._target), _index(rhs._index),
34      _bufferObject(static_cast<BufferObject*>(copyop(rhs._bufferObject.get()))),
35      _offset(rhs._offset),
36      _size(rhs._size)
37{
38}
39
40BufferIndexBinding::~BufferIndexBinding()
41{
42}
43
44void BufferIndexBinding::apply(State& state) const
45{
46    if (_bufferObject.valid())
47    {
48        GLBufferObject* glObject
49            = _bufferObject->getOrCreateGLBufferObject(state.getContextID());
50        if (!glObject->_extensions->isUniformBufferObjectSupported())
51            return;
52        if (glObject->isDirty()) glObject->compileBuffer();
53        glObject->_extensions->glBindBufferRange(_target, _index,
54                                                 glObject->getGLObjectID(), _offset, _size);
55    }
56}
57
58UniformBufferBinding::UniformBufferBinding()
59    : BufferIndexBinding(GL_UNIFORM_BUFFER, 0)
60{
61}
62
63UniformBufferBinding::UniformBufferBinding(GLuint index)
64  : BufferIndexBinding(GL_UNIFORM_BUFFER, index)
65{
66}
67
68UniformBufferBinding::UniformBufferBinding(GLuint index, BufferObject* bo, GLintptr offset,
69                                           GLsizeiptr size)
70    : BufferIndexBinding(GL_UNIFORM_BUFFER, index, bo, offset, size)
71{
72
73}
74
75UniformBufferBinding::UniformBufferBinding(const UniformBufferBinding& rhs,
76                                           const CopyOp& copyop)
77    : BufferIndexBinding(rhs, copyop)
78{
79}
80
81
82TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(GLuint index)
83  : BufferIndexBinding(GL_TRANSFORM_FEEDBACK_BUFFER, index)
84{
85}
86
87TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size)
88    : BufferIndexBinding(GL_TRANSFORM_FEEDBACK_BUFFER, index, bo, offset, size)
89{
90
91}
92
93TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(const TransformFeedbackBufferBinding& rhs, const CopyOp& copyop)
94    : BufferIndexBinding(rhs, copyop)
95{
96}
97
98}
Note: See TracBrowser for help on using the browser.