openscenegraph
BindImageTexture
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
14
15#ifndef _GLImageUnitBinding_H
16#define _GLImageUnitBinding_H
17
18#include <osg/Export>
19#include <osg/Texture>
20
21namespace osg
22{
30 public:
32 enum Access
33 {
34 NOT_USED = 0,
35 READ_ONLY = GL_READ_ONLY_ARB,
36 WRITE_ONLY = GL_WRITE_ONLY_ARB,
37 READ_WRITE = GL_READ_WRITE_ARB
38 };
39
41 GLuint imageunit = 0,
42 osg::Texture* target = 0,
43 Access access = READ_ONLY,
44 GLenum format = GL_RGBA8,
45 int level = 0,
46 bool layered = GL_FALSE,
47 int layer = 0) : osg::StateAttribute(),
48 _target(target),
49 _imageunit(imageunit),
50 _level(level),
51 _layered(layered),
52 _layer(layer),
53 _access(access),
54 _format(format) {}
55
57 osg::StateAttribute(o,op),
58 _target(o._target),
59 _imageunit(o._imageunit),
60 _level(o._level),
61 _layered(o._layered),
62 _layer(o._layer),
63 _access(o._access),
64 _format(o._format) {}
65
66 virtual ~BindImageTexture() {}
67
69
70 inline void setImageUnit(GLuint i) { _imageunit=i; }
71 inline GLuint getImageUnit() const { return _imageunit; }
72
73 inline void setLevel(GLint i) { _level=i; }
74 inline GLint getLevel() const { return _level; }
75
76 inline void setIsLayered(GLboolean i) { _layered=i; }
77 inline GLboolean getIsLayered() const { return _layered; }
78
79 inline void setLayer(GLint i) { _layer=i; }
80 inline GLint getLayer() const { return _layer; }
81
82 inline void setAccess(Access i) { _access=i; }
83 inline Access getAccess() const { return _access; }
84
85 inline void setFormat(GLenum i) { _format=i; }
86 inline GLenum getFormat() const { return _format; }
87
88 inline void setTexture(osg::Texture* target) { _target=target; }
89 inline osg::Texture* getTexture() { return _target.get();}
90 inline const osg::Texture* getTexture() const { return _target.get();}
91
92 virtual void apply(osg::State&state) const;
93
94 virtual int compare(const osg::StateAttribute &sa) const;
95
96 virtual unsigned getMember() const { return static_cast<unsigned int>(_imageunit); }
97
98 protected:
99
102 GLint _level;
103 GLboolean _layered;
104 GLint _layer;
106 GLenum _format;
107
108};
109
110}
111#endif
#define GL_WRITE_ONLY_ARB
Definition BufferObject:54
#define GL_READ_WRITE_ARB
Definition BufferObject:55
#define GL_READ_ONLY_ARB
Definition BufferObject:53
#define GL_RGBA8
Definition Texture:308
Definition BindImageTexture:29
GLboolean _layered
Definition BindImageTexture:103
void setAccess(Access i)
Definition BindImageTexture:82
virtual void apply(osg::State &state) const
GLint _layer
Definition BindImageTexture:104
GLuint _imageunit
Definition BindImageTexture:101
GLint getLayer() const
Definition BindImageTexture:80
virtual unsigned getMember() const
Definition BindImageTexture:96
void setLayer(GLint i)
Definition BindImageTexture:79
GLenum _format
Definition BindImageTexture:106
osg::Texture * getTexture()
Definition BindImageTexture:89
Access _access
Definition BindImageTexture:105
GLboolean getIsLayered() const
Definition BindImageTexture:77
virtual int compare(const osg::StateAttribute &sa) const
META_StateAttribute(osg, BindImageTexture, BINDIMAGETEXTURE) inline void setImageUnit(GLuint i)
Definition BindImageTexture:68
GLuint getImageUnit() const
Definition BindImageTexture:71
Access getAccess() const
Definition BindImageTexture:83
GLint _level
Definition BindImageTexture:102
osg::ref_ptr< osg::Texture > _target
Definition BindImageTexture:100
virtual ~BindImageTexture()
Definition BindImageTexture:66
BindImageTexture(GLuint imageunit=0, osg::Texture *target=0, Access access=READ_ONLY, GLenum format=GL_RGBA8, int level=0, bool layered=GL_FALSE, int layer=0)
Definition BindImageTexture:40
GLenum getFormat() const
Definition BindImageTexture:86
void setTexture(osg::Texture *target)
Definition BindImageTexture:88
const osg::Texture * getTexture() const
Definition BindImageTexture:90
GLint getLevel() const
Definition BindImageTexture:74
BindImageTexture(const BindImageTexture &o, osg::CopyOp op=osg::CopyOp::SHALLOW_COPY)
Definition BindImageTexture:56
Access
Definition BindImageTexture:33
void setFormat(GLenum i)
Definition BindImageTexture:85
void setLevel(GLint i)
Definition BindImageTexture:73
void setIsLayered(GLboolean i)
Definition BindImageTexture:76
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition StateAttribute:77
Definition State:80
Definition Texture:422
Definition ref_ptr:32
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSG_EXPORT
Definition osg/Export:39