Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
RoboGuide
scigl_render
Commits
ff49f339
Commit
ff49f339
authored
Mar 04, 2019
by
Tim Übelhör
Browse files
using texture as framebuffer attachment so sampling in shaders is possible
parent
32be141c
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/scigl_render/buffer/frame_buffer.hpp
View file @
ff49f339
...
...
@@ -41,6 +41,9 @@ public:
*/
void
clear
(
float
color
=
0
,
float
depth
=
1
,
int
stencil
=
0
)
const
;
/** returns the texture used for rendering */
GLuint
get_texture
()
const
;
/** gets the maximum rbo size */
static
int
get_max_size
();
...
...
@@ -49,9 +52,9 @@ private:
int
width
,
height
;
// framebuffer object to render the texture into
GLuint
fbo
;
//
renderbuffer
for renderng colors
GLuint
color_
rbo
;
// renderbuffer object for the depth testing
//
texture
for renderng colors
, can be sampled from
GLuint
color_
tex
;
// renderbuffer object for the depth testing
, does not allow sampling
GLuint
depth_stencil_rbo
;
};
}
// namespace scigl_render
\ No newline at end of file
src/buffer/frame_buffer.cpp
View file @
ff49f339
...
...
@@ -10,11 +10,11 @@ FrameBuffer::FrameBuffer(int width, int height, GLenum internal_format)
// Create framebuffer with renderbuffer attachements
glGenFramebuffers
(
1
,
&
fbo
);
activate
();
glGen
Renderbuffer
s
(
1
,
&
color_
rbo
);
glBind
Renderbuffer
(
GL_RENDERBUFFER
,
color_
rbo
);
gl
Renderbuffer
Storage
(
GL_
RENDERBUFFER
,
internal_format
,
width
,
height
);
glFramebuffer
Renderbuffer
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_RENDERBUFFER
,
color_
rbo
);
glGen
Texture
s
(
1
,
&
color_
tex
);
glBind
Texture
(
GL_TEXTURE_2D
,
color_
tex
);
gl
Tex
Storage
2D
(
GL_
TEXTURE_2D
,
1
,
internal_format
,
width
,
height
);
glFramebuffer
Texture2D
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
GL_TEXTURE_2D
,
color_
tex
,
0
);
glGenRenderbuffers
(
1
,
&
depth_stencil_rbo
);
glBindRenderbuffer
(
GL_RENDERBUFFER
,
depth_stencil_rbo
);
glRenderbufferStorage
(
GL_RENDERBUFFER
,
GL_DEPTH24_STENCIL8
,
width
,
height
);
...
...
@@ -33,7 +33,7 @@ FrameBuffer::~FrameBuffer()
{
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
glDeleteRenderbuffers
(
1
,
&
depth_stencil_rbo
);
glDelete
Renderbuffer
s
(
1
,
&
color_
rbo
);
glDelete
Texture
s
(
1
,
&
color_
tex
);
}
void
FrameBuffer
::
activate
()
const
...
...
@@ -56,6 +56,11 @@ void FrameBuffer::clear(float color, float depth, int stencil) const
deactivate
();
}
GLuint
FrameBuffer
::
get_texture
()
const
{
return
color_tex
;
}
int
FrameBuffer
::
get_max_size
()
{
int
max_rbo_size
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment