Files

57 lines
1.2 KiB
C++
Raw Permalink Normal View History

#include "Scene.h"
extern "C" {
#include "../GLES_3_1_compatibility.h"
}
/* REPLACED
#include <GL/freeglut.h>
*/
#include <glut.h>
#include <glm/gtc/matrix_transform.hpp>
#include <string>
#include <iostream>
using namespace glm;
Scene::Scene(int left, int top, int width, int height)
: PseudoContext { left, top, width, height }
{
glGenFramebuffers(1, &FBO);
glGenRenderbuffers(1, &depthRBO);
glBindRenderbuffer(GL_RENDERBUFFER, depthRBO);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
void Scene::draw() {
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRBO);
GLenum DrawBuffers[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT };
glDrawBuffers(2, DrawBuffers);
}
void Scene::setOutTexture(GLuint outTexture) {
outputTexture = outTexture;
}
void Scene::keyPress(unsigned char key, int x, int y) {
switch (key)
{
case 27:
exit(0);
break;
default:
break;
}
}
GLuint Scene::getFrameBuffer() {
return this->FBO;
}