diff options
author | Paul Lemire <paul.lemire.ecortex@kdab.com> | 2014-11-20 14:14:19 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2014-12-12 14:17:02 +0100 |
commit | 9dd1b0c993873772e2719844be71f86bc0c92a02 (patch) | |
tree | 33ff71e3805d46c048844d44b9807d834b02eccc /src/render/io/uniformbuffer_p.h | |
parent | d2d8a59d1ae87ae356974be8e5515c2307c71132 (diff) |
UniformBuffer: wraps around the GL calls needed to have a UBO
Will be used by the RenderShaderData internally to map the CPU side buffer to
the GPU side Uniform Buffer Object.
Change-Id: I6b8ffdbff49d806bb8668df81ec59872feafe611
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/io/uniformbuffer_p.h')
-rw-r--r-- | src/render/io/uniformbuffer_p.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/render/io/uniformbuffer_p.h b/src/render/io/uniformbuffer_p.h new file mode 100644 index 000000000..2cc2f0a64 --- /dev/null +++ b/src/render/io/uniformbuffer_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3D_RENDER_UNIFORMBUFFER_P_H +#define QT3D_RENDER_UNIFORMBUFFER_P_H + +#include <QOpenGLContext> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +namespace Render { + +class QGraphicsContext; + +class UniformBuffer +{ +public: + UniformBuffer(); + + void bind(QGraphicsContext *ctx); + void create(QGraphicsContext *ctx); + void destroy(QGraphicsContext *ctx); + void allocate(QGraphicsContext *ctx, uint size, bool dynamic = true); + void update(QGraphicsContext *ctx, const void *data, uint size); + void bindToUniformBlock(QGraphicsContext *ctx, int bindingPoint); + + inline GLuint bufferId() const { return m_bufferId; } + inline bool isCreated() const { return m_isCreated; } + +private: + GLuint m_bufferId; + bool m_isCreated; +}; + +} // Render + +} // Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_RENDER_UNIFORMBUFFER_P_H |