-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frame buffer creation, shader refractor
the frame buffer creation is in progresse, but we still need to think a proper way to draw the scene into the frame buffer. #8 also, the main shader as be cleaned a bit, now every object are independent, no more gobal setting.
- Loading branch information
Showing
7 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ int main() | |
|
||
|
||
cam->sendInfo(); | ||
|
||
obj.show(); | ||
|
||
nerv::window::get().update(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "framebuffer.h" | ||
|
||
|
||
nerv::framebuffer::framebuffer() | ||
{ | ||
logger.warning("FRAMEBUFFER", "Creating frame buffer"); | ||
|
||
glGenBuffers(1, &(this->id)); | ||
glBindFramebuffer(GL_FRAMEBUFFER, this->id); //this make a offscreen render of the buffer set to 0 for onscreen rendering | ||
this->frameTexture = new nerv::texture(nerv::window::get().width, nerv::window::get().height); | ||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->frameTexture->getId(), 0); | ||
logger.info("FRAMEBUFFER", "Created texture for framebuffer"); | ||
|
||
glGenRenderbuffers(1, &(this->rbo)); | ||
glBindRenderbuffer(GL_RENDERBUFFER, this->rbo); | ||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, this->frameTexture->getWidth(), this->frameTexture->getHeight()); | ||
glBindRenderbuffer(GL_RENDERBUFFER, 0); | ||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, this->rbo); | ||
logger.info("FRAMEBUFFER", "alloced space for framebuffer"); | ||
|
||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | ||
logger.error("FRAMEBUFFER", "Framebuffer creation did not succed"); | ||
|
||
glBindFramebuffer(GL_FRAMEBUFFER, 0); | ||
} | ||
|
||
nerv::framebuffer::~framebuffer() | ||
{ | ||
glDeleteBuffers(1, &(this->id)); | ||
delete(this->frameTexture); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include "../../../dependencies.h" | ||
#include "texture.h" | ||
#include "../../in_out/windows/windows.h" | ||
|
||
namespace nerv | ||
{ | ||
class framebuffer | ||
{ | ||
public: | ||
size_t id; | ||
|
||
//renderbuffer objet id | ||
size_t rbo; | ||
|
||
//texture where the frame buffer is drawn | ||
nerv::texture * frameTexture; | ||
|
||
framebuffer(); | ||
~framebuffer(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters