SuperTuxKart
Loading...
Searching...
No Matches
frame_buffer_layer.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2018 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program 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// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef SERVER_ONLY
19
20#ifndef HEADER_FRAME_BUFFER_LAYER_HPP
21#define HEADER_FRAME_BUFFER_LAYER_HPP
22
23#include "graphics/frame_buffer.hpp"
24
26{
27private:
28 std::vector<GLuint> m_fbo_layer;
29
30public:
31 LEAK_CHECK()
32 // ------------------------------------------------------------------------
33 FrameBufferLayer(const std::vector<GLuint> &rtts, unsigned w, unsigned h,
34 unsigned layer_count);
35 // ------------------------------------------------------------------------
36 FrameBufferLayer(const std::vector<GLuint> &rtts, GLuint depth_stencil,
37 unsigned w, unsigned h, unsigned layer_count);
38 // ------------------------------------------------------------------------
40 {
41 if (!m_fbo_layer.empty())
42 {
43 glDeleteFramebuffers((int)m_fbo_layer.size(), m_fbo_layer.data());
44 }
45 }
46 // ------------------------------------------------------------------------
47 void bindLayer(unsigned i) const
48 {
49 assert(i < m_fbo_layer.size());
50 glBindFramebuffer(GL_FRAMEBUFFER, m_fbo_layer[i]);
51 glViewport(0, 0, (int)m_width, (int)m_height);
52 GLenum bufs[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1,
53 GL_COLOR_ATTACHMENT2 };
54 glDrawBuffers((int)m_render_targets.size(), bufs);
55 }
56 // ------------------------------------------------------------------------
57 void bindLayerDepthOnly(unsigned i) const
58 {
59 assert(i < m_fbo_layer.size());
60 glBindFramebuffer(GL_FRAMEBUFFER, m_fbo_layer[i]);
61 glViewport(0, 0, (int)m_width, (int)m_height);
62 GLenum bufs[] = { GL_NONE, GL_NONE, GL_NONE };
63 glDrawBuffers((int)m_render_targets.size(), bufs);
64 }
65 // ------------------------------------------------------------------------
66 unsigned getLayerCount() const { return (unsigned)m_fbo_layer.size(); }
67
68};
69
70#endif
71
72#endif
Definition: frame_buffer_layer.hpp:26
Definition: frame_buffer.hpp:33