Doxygen Samurai Engine 0.0.1
Doxygen Samurai Engine Documentation
Loading...
Searching...
No Matches
frameBuffer.cpp
Go to the documentation of this file.
1#include "frameBuffer.h"
2
3namespace samurai
4{
5 namespace GL
6 {
7
8 void PikaFramebuffer::createFramebuffer(unsigned int w, unsigned int h)
9 {
10 glGenFramebuffers(1, &fbo);
11 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
12
13 glGenTextures(1, &texture);
14 glBindTexture(GL_TEXTURE_2D, texture);
15
16 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
17
18 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
19 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
20 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
21
22 //glDrawBuffer(GL_COLOR_ATTACHMENT0); //todo look into this function
23
24 //glGenTextures(1, &depthtTexture); //todo add depth stuff
25 //glBindTexture(GL_TEXTURE_2D, depthtTexture);
26
27 //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, w, h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
28
29 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
30 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
31
32 //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthtTexture, 0);
33
34 glBindTexture(GL_TEXTURE_2D, 0);
35 glBindFramebuffer(GL_FRAMEBUFFER, 0);
36
37 }
38
40 {
41 if (fbo)
42 {
43 glDeleteFramebuffers(1, &fbo);
44 fbo = 0;
45 }
46
47 if (texture)
48 {
49 glDeleteTextures(1, &texture);
50 texture = 0;
51 }
52 }
53
54 void PikaFramebuffer::resizeFramebuffer(unsigned int w, unsigned int h)
55 {
56 glBindTexture(GL_TEXTURE_2D, texture);
57 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
58
59 //glBindTexture(GL_TEXTURE_2D, depthtTexture);
60 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
61
62 glBindTexture(GL_TEXTURE_2D, 0);
63 }
64
65 }
66
67
68}
69
70
void createFramebuffer(unsigned int w, unsigned int h)
void resizeFramebuffer(unsigned int w, unsigned int h)