/* ======================================================================================================================================================== */ void GBuffer::initialize(pxInt width, pxInt height, GLenum textureType) { STACK_TRACE; /* Texture */ glActiveTexture(GL_TEXTURE0); createTexture(colorTexture, textureType, GL_RGBA32F, GL_RGBA, width, height); glActiveTexture(GL_TEXTURE1); createTexture(normalTexture, textureType, GL_RGBA32F, GL_RGBA, width, height); glActiveTexture(GL_TEXTURE2); createTexture(typeTexture, textureType, GL_RGBA32F, GL_RGBA, width, height); glActiveTexture(GL_TEXTURE3); createTexture(depthTexture, textureType, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, width, height); /* Framebuffer to link everything together */ glGenFramebuffers(1, &id); glBindFramebuffer(GL_FRAMEBUFFER, id); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureType, colorTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, textureType, normalTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, textureType, typeTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureType, depthTexture, 0); STACK_MESSAGE("Checking Framebuffer errors"); checkFrameBuffer(); glBindFramebuffer(GL_FRAMEBUFFER, 0); createQuad(VAO_id, VBO_Quad); UNSTACK_TRACE; }
/* ======================================================================================================================================================== */ void ImageBuffer::initialize(pxInt width, pxInt height) { STACK_TRACE; /* Texture */ glActiveTexture(GL_TEXTURE0); createTexture(texture, GL_TEXTURE_2D, GL_RGBA32F, GL_RGBA, width, height); /* Framebuffer to link everything together */ glGenFramebuffers(1, &id); glBindFramebuffer(GL_FRAMEBUFFER, id); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); STACK_MESSAGE("Checking Framebuffer errors"); checkFrameBuffer(); glBindFramebuffer(GL_FRAMEBUFFER, 0); createQuad(VAO_id, VBO_Quad); UNSTACK_TRACE; }
void GRendering::writeToFBO(void) { // Binde Framebuffer glBindFramebuffer(GL_FRAMEBUFFER, glui_FBO); glViewport(0, 0, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE); checkFrameBuffer(); // Lösche den Inhalt des FBOs glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_DEPTH_BUFFER_BIT); // Binde die Textur glBindTexture(GL_TEXTURE_2D, glui_depthTexture); // Schalte FBO Shader glUseProgram(glui_shadowMapShaderProgram); // Zeichne die Szene in die Textur sm_sceneMgr->drawShadow(glui_shadowMapShaderProgram); // Stoppe das Rendern in das FBO glBindFramebuffer(GL_FRAMEBUFFER, 0); glUseProgram(0); }