Symphony Of Empires
framebuffer.cpp
Go to the documentation of this file.
1 // Eng3D - General purpouse game engine
2 // Copyright (C) 2021, Eng3D contributors
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (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, see <https://www.gnu.org/licenses/>.
16 //
17 // ----------------------------------------------------------------------------
18 // Name:
19 // framebuffer.cpp
20 //
21 // Abstract:
22 // Does some important stuff.
23 // ----------------------------------------------------------------------------
24 
25 
26 #ifdef E3D_BACKEND_OPENGL
27 # include <GL/glew.h>
28 # include <GL/gl.h>
29 #elif defined E3D_BACKEND_GLES
30 # include <GLES3/gl3.h>
31 # include <GLES3/gl31.h>
32 #endif
33 
34 #include "eng3d/framebuffer.hpp"
35 #include "eng3d/log.hpp"
36 
38  glGenFramebuffers(1, &id);
39  glBindFramebuffer(GL_FRAMEBUFFER, id);
40 }
41 
43  if(id)
44  glDeleteFramebuffers(1, &id);
45 }
46 
48  glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, GL_TEXTURE_2D, texture.id, 0);
49  if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
50  Eng3D::Log::error("opengl", translate("Frame buffer error"));
51 }
52 
54  glBindFramebuffer(GL_FRAMEBUFFER, id);
55 }
void set_texture(int index, const Eng3D::Texture &texture)
Definition: framebuffer.cpp:47
unsigned int id
Definition: texture.hpp:146
std::string translate(const std::string_view str)
Definition: string.cpp:76
void error(const std::string_view category, const std::string_view msg)
Definition: log.cpp:68