void GBuffer::BindForWriting() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); }
RenderTarget::RenderTarget(const glm::ivec2& size, GLenum format, int flags, GLenum filter) throw() : TextureBase() , id(0) , front(0) , back(0) , max(1) { checkForGLErrors("RenderTarget() pre"); this->size = size; /* init_vbo is a no-op if it already is initialized */ init_vbo(); /* generate projection matrix for this target */ projection = glm::ortho(0.0f, (float)size.x, 0.0f, (float)size.y, -1.0f, 1.0f); projection = glm::scale(projection, glm::vec3(1.0f, -1.0f, 1.0f)); projection = glm::translate(projection, glm::vec3(0.0f, -(float)size.y, 0.0f)); glGenFramebuffers(1, &id); glGenTextures(2, color); glGenTextures(1, &depth); glBindFramebuffer(GL_FRAMEBUFFER, id); Engine::setup_opengl(); /* bind color buffers */ for ( int i = 0; i < 2; i++ ){ glBindTexture(GL_TEXTURE_2D, color[i]); glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, format == GL_RGB8 ? GL_RGB : GL_RGBA, GL_UNSIGNED_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); } glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color[front], 0); checkForGLErrors("glFramebufferTexture2D::color"); /* bind depth buffer */ if ( flags & DEPTH_BUFFER ){ glBindTexture(GL_TEXTURE_2D, depth); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.x, size.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0); checkForGLErrors("glFramebufferTexture2D::depth"); } /* enable doublebuffering */ if ( flags & DOUBLE_BUFFER ){ max = 2; } GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if(status != GL_FRAMEBUFFER_COMPLETE){ switch( status ) { case GL_FRAMEBUFFER_UNSUPPORTED_EXT: fprintf(stderr, "Framebuffer object format is unsupported by the video hardware. (GL_FRAMEBUFFER_UNSUPPORTED_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: fprintf(stderr, "Framebuffer incomplete attachment. (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: fprintf(stderr, "Framebuffer incomplete missing attachment. (GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: fprintf(stderr, "Framebuffer incomplete dimensions. (GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: fprintf(stderr, "Framebuffer incomplete formats. (GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: fprintf(stderr, "Framebuffer incomplete draw buffer. (GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: fprintf(stderr, "Framebuffer incomplete read buffer. (GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT)\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT: fprintf(stderr, "Framebuffer incomplete multisample buffer. (GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT)\n"); break; default: fprintf(stderr, "Framebuffer incomplete: %s\n", gluErrorString(status)); } util_abort(); } glBindFramebuffer(GL_FRAMEBUFFER, 0); checkForGLErrors("RenderTarget() fin"); with([this](){ RenderTarget::clear(Color::black); } ); }
void Display() { static CStopWatch timer; GLfloat yRot = timer.GetElapsedSeconds() * 60.0; M3DVector3f vCameraPosition; M3DVector3f vCameraForward; M3DVector3f vMirrorPosition; M3DVector3f vMirrorForward; void movingCylinder(); cameraFrame.GetOrigin(vCameraPosition); cameraFrame.GetForwardVector(vCameraForward); vMirrorPosition[0] = 0.0f; vMirrorPosition[1] = 0.1f; vMirrorPosition[2] = -20.0f; mirrorFrame.SetOrigin(vMirrorPosition); vMirrorForward[0] = vCameraPosition[0]; vMirrorForward[1] = vCameraPosition[1]; vMirrorForward[2] = (vCameraPosition[2] + 20); m3dNormalizeVector3(vMirrorForward); mirrorFrame.SetForwardVector(vMirrorForward); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindFramebuffer(GL_DRAW_FRAMEBUFFER,fboName); glDrawBuffers(1,fboBuffers); glViewport(0,0,mirrorWidth,mirrorHeight); modelViewMatrix.PushMatrix(); M3DMatrix44f mMirrorView; mirrorFrame.GetCameraMatrix(mMirrorView); modelViewMatrix.MultMatrix(mMirrorView); modelViewMatrix.Scale(-1.0f,1.0f,1.0f); glBindTexture(GL_TEXTURE_2D,textures[0]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vWhite,0); floorBatch.Draw(); drawSun(); drawTorus(yRot); modelViewMatrix.PopMatrix(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0); glDrawBuffers(1,windowBuffer); glViewport(0,0,mirrorWidth,mirrorHeight); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); modelViewMatrix.PushMatrix(); glBindTexture(GL_TEXTURE_2D,mirrorTexture); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeline.GetModelViewProjectionMatrix(),0); mirrorFrontBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); glBindTexture(GL_TEXTURE_2D,textures[0]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vWhite,0); floorBatch.Draw(); drawSun(); drawTorus(yRot); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); //control to moving cylinder movingCylinder(); glutSwapBuffers(); glutPostRedisplay(); }
void PezRender() { #define Instances 7 Matrix4 Model[Instances]; Model[0] = M4MakeRotationY(Globals.Theta); Model[1] = M4Mul(M4Mul( M4MakeTranslation((Vector3){0, 0, 0.6}), M4MakeScale(V3MakeFromScalar(0.25))), M4MakeRotationX(Pi/2) ); Model[2] = Model[3] = Model[4] = Model[1]; Model[1] = M4Mul(M4MakeRotationY(Globals.Theta), Model[1]); Model[2] = M4Mul(M4MakeRotationY(Globals.Theta + Pi/2), Model[2]); Model[3] = M4Mul(M4MakeRotationY(Globals.Theta - Pi/2), Model[3]); Model[4] = M4Mul(M4MakeRotationY(Globals.Theta + Pi), Model[4]); Model[5] = M4Mul(M4Mul( M4MakeScale(V3MakeFromScalar(0.5)), M4MakeTranslation((Vector3){0, 1.25, 0})), M4MakeRotationY(-Globals.Theta) ); Model[6] = M4Mul(M4Mul( M4MakeScale(V3MakeFromScalar(0.5)), M4MakeTranslation((Vector3){0, -1.25, 0})), M4MakeRotationY(-Globals.Theta) ); Vector3 LightPosition = {0.5, 0.25, 1.0}; // world space Vector3 EyePosition = {0, 0, 1}; // world space Matrix4 MVP[Instances]; Vector3 Lhat[Instances]; Vector3 Hhat[Instances]; for (int i = 0; i < Instances; i++) { Matrix4 mv = M4Mul(Globals.View, Model[i]); MVP[i] = M4Mul(Globals.Projection, mv); Matrix3 m = M3Transpose(M4GetUpper3x3(Model[i])); Lhat[i] = M3MulV3(m, V3Normalize(LightPosition)); // object space Vector3 Eye = M3MulV3(m, V3Normalize(EyePosition)); // object space Hhat[i] = V3Normalize(V3Add(Lhat[i], Eye)); } int instanceCount = Instances; MeshPod* mesh = &Globals.Cylinder; glBindFramebuffer(GL_FRAMEBUFFER, Globals.FboHandle); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glUseProgram(Globals.LitProgram); glUniform3f(u("SpecularMaterial"), 0.4, 0.4, 0.4); glUniform4f(u("FrontMaterial"), 0, 0, 1, 1); glUniform4f(u("BackMaterial"), 0.5, 0.5, 0, 1); glUniform3fv(u("Hhat"), Instances, &Hhat[0].x); glUniform3fv(u("Lhat"), Instances, &Lhat[0].x); glUniformMatrix4fv(u("ModelviewProjection"), Instances, 0, (float*) &MVP[0]); glBindVertexArray(mesh->FillVao); glDrawElementsInstanced(GL_TRIANGLES, mesh->FillIndexCount, GL_UNSIGNED_SHORT, 0, instanceCount); glUseProgram(Globals.SimpleProgram); glUniform4f(u("Color"), 0, 0, 0, 1); glUniformMatrix4fv(u("ModelviewProjection"), Instances, 0, (float*) &MVP[0]); glDepthMask(GL_FALSE); glBindVertexArray(mesh->LineVao); glDrawElementsInstanced(GL_LINES, mesh->LineIndexCount, GL_UNSIGNED_SHORT, 0, instanceCount); glDepthMask(GL_TRUE); glDisable(GL_DEPTH_TEST); glBindFramebuffer(GL_FRAMEBUFFER, 0); PezConfig cfg = PezGetConfig(); glViewport(6,6,cfg.Width-12,cfg.Height-12); glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.8, 0.8, 0.9, 1); glUseProgram(Globals.QuadProgram); glUniform1f(u("BarrelPower"), Globals.BarrelPower); glBindTexture(GL_TEXTURE_2D, Globals.FboTexture); glBindVertexArray(Globals.QuadVao); glDisable(GL_BLEND); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, 0); glViewport(0,0,cfg.Width,cfg.Height); }
static bool alloc_fbo(struct agp_rendertarget* dst, bool retry) { glGenFramebuffers(1, &dst->fbo); /* need both stencil and depth buffer, but we don't need the data from them */ glBindFramebuffer(GL_FRAMEBUFFER, dst->fbo); if (dst->mode > RENDERTARGET_DEPTH) { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst->store->vinf.text.glid, 0); /* need a Z buffer in the offscreen rendering but don't want * bo store it, so setup a renderbuffer */ if (dst->mode > RENDERTARGET_COLOR) { glGenRenderbuffers(1, &dst->depth); /* could use GL_DEPTH_COMPONENT only if we'd know that there * wouldn't be any clipping in the active rendertarget */ if (!retry){ glBindRenderbuffer(GL_RENDERBUFFER, dst->depth); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, dst->store->w, dst->store->h); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, dst->depth); } } } else { /* DEPTH buffer only (shadowmapping, ...) convert the storage to * contain a depth texture */ size_t w = dst->store->w; size_t h = dst->store->h; agp_drop_vstore(dst->store); dst->store = arcan_alloc_mem(sizeof(struct storage_info_t), ARCAN_MEM_VSTRUCT, 0, ARCAN_MEMALIGN_NATURAL); struct storage_info_t* store = dst->store; memset(store, '\0', sizeof(struct storage_info_t)); store->txmapped = TXSTATE_DEPTH; store->txu = ARCAN_VTEX_CLAMP; store->txv = ARCAN_VTEX_CLAMP; store->scale = ARCAN_VIMAGE_NOPOW2; store->imageproc = IMAGEPROC_NORMAL; store->filtermode = ARCAN_VFILTER_NONE; store->refcount = 1; store->w = w; store->h = h; /* generate ID etc. special path for TXSTATE_DEPTH */ agp_update_vstore(store, true); glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, store->vinf.text.glid, 0); } /* basic error handling / status checking * may be possible that we should cache this in the * rendertarget and only call when / if something changes as * it's not certain that drivers won't stall the pipeline on this */ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE){ arcan_warning("FBO support broken, couldn't create basic FBO:\n"); switch(status){ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: if (!retry){ arcan_warning("\t Incomplete Attachment, attempting " "simple framebuffer, this will likely break 3D and complex" "clipping operations.\n"); return alloc_fbo(dst, true); } else arcan_warning("\t Simple attachement broke as well " "likely driver issue.\n"); break; #ifdef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: arcan_warning("\t Not all attached buffers have " "the same dimensions.\n"); break; #endif case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: arcan_warning("\t One or several FBO attachment points are missing.\n"); break; case GL_FRAMEBUFFER_UNSUPPORTED: arcan_warning("\t Request formats combination unsupported.\n"); break; } if (dst->fbo != GL_NONE) glDeleteFramebuffers(1,&dst->fbo); if (dst->depth != GL_NONE) glDeleteRenderbuffers(1,&dst->depth); dst->fbo = dst->depth = GL_NONE; return false; } glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
void OffscreenBuffer::Unbind() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); }
GLUSvoid terminateWaterTexture(GLUSvoid) { glBindBuffer(GL_ARRAY_BUFFER, 0); if (g_verticesWaterTextureVBO) { glDeleteBuffers(1, &g_verticesWaterTextureVBO); g_verticesWaterTextureVBO = 0; } if (g_texCoordsWaterTextureVBO) { glDeleteBuffers(1, &g_texCoordsWaterTextureVBO); g_texCoordsWaterTextureVBO = 0; } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); if (g_indicesWaterTextureVBO) { glDeleteBuffers(1, &g_indicesWaterTextureVBO); g_indicesWaterTextureVBO = 0; } glBindVertexArray(0); if (g_vaoWaterTexture) { glDeleteVertexArrays(1, &g_vaoWaterTexture); g_vaoWaterTexture = 0; } glUseProgram(0); glusDestroyProgram(&g_programWaterTexture); // glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); if (g_mirrorTexture) { glDeleteTextures(1, &g_mirrorTexture); g_mirrorTexture = 0; } glBindRenderbuffer(GL_RENDERBUFFER, 0); if (g_depthMirrorTexture) { glDeleteRenderbuffers(1, &g_depthMirrorTexture); g_depthMirrorTexture = 0; } glBindFramebuffer(GL_FRAMEBUFFER, 0); if (g_fboWaterTexture) { glDeleteFramebuffers(1, &g_fboWaterTexture); g_fboWaterTexture = 0; } }
void VROpenVRNode::render(VRDataIndex *renderState, VRRenderHandler *renderHandler) { if(!isInitialized) { isInitialized = true; GLenum nGlewError = glewInit(); if (nGlewError != GLEW_OK) { std::cerr << __FUNCTION__ << " - Error initializing GLEW! \n" << glewGetErrorString( nGlewError ) << std::endl; exit(0); } glGetError(); // to clear the error caused deep in GLEW m_mat4ProjectionLeft = GetHMDMatrixProjectionEye( vr::Eye_Left ); m_mat4ProjectionRight = GetHMDMatrixProjectionEye( vr::Eye_Right ); m_mat4eyePosLeft = GetHMDMatrixPoseEye( vr::Eye_Left ); m_mat4eyePosRight = GetHMDMatrixPoseEye( vr::Eye_Right ); SetupStereoRenderTargets(); } _inputDev->updatePoses(); VRMatrix4 head_pose = _inputDev->getPose(vr::k_unTrackedDeviceIndex_Hmd).inverse(); // Left Eye renderState->pushState(); glEnable( GL_MULTISAMPLE ); glBindFramebuffer( GL_FRAMEBUFFER, leftEyeDesc.m_nRenderFramebufferId ); glViewport(0, 0, m_nRenderWidth, m_nRenderHeight ); glClearColor( 0, 0, 0, 1 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); VRMatrix4 view_left = m_mat4eyePosLeft * head_pose; renderState->addData("ProjectionMatrix", m_mat4ProjectionLeft); renderState->addData("ViewMatrix", view_left); if (_children.size() == 0) { renderHandler->onVRRenderScene(renderState, this); } else { VRDisplayNode::render(renderState, renderHandler); } glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glDisable( GL_MULTISAMPLE ); glBindFramebuffer(GL_READ_FRAMEBUFFER, leftEyeDesc.m_nRenderFramebufferId); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, leftEyeDesc.m_nResolveFramebufferId ); glBlitFramebuffer( 0, 0, m_nRenderWidth, m_nRenderHeight, 0, 0, m_nRenderWidth, m_nRenderHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR ); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 ); renderState->popState(); // Right Eye renderState->pushState(); glEnable( GL_MULTISAMPLE ); glBindFramebuffer( GL_FRAMEBUFFER, rightEyeDesc.m_nRenderFramebufferId ); glViewport(0, 0, m_nRenderWidth, m_nRenderHeight ); glClearColor( 0, 0, 0, 1 ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); VRMatrix4 view_right = m_mat4eyePosRight * head_pose; renderState->addData("ProjectionMatrix",m_mat4ProjectionRight); renderState->addData("ViewMatrix", view_right); if (_children.size() == 0) { renderHandler->onVRRenderScene(renderState, this); } else { VRDisplayNode::render(renderState, renderHandler); } glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glDisable( GL_MULTISAMPLE ); glBindFramebuffer(GL_READ_FRAMEBUFFER, rightEyeDesc.m_nRenderFramebufferId ); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, rightEyeDesc.m_nResolveFramebufferId ); glBlitFramebuffer( 0, 0, m_nRenderWidth, m_nRenderHeight, 0, 0, m_nRenderWidth, m_nRenderHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR ); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 ); renderState->popState(); glFinish(); vr::Texture_t leftEyeTexture = {(void*)leftEyeDesc.m_nResolveTextureId, vr::API_OpenGL, vr::ColorSpace_Gamma }; vr::EVRCompositorError error = vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture ); vr::Texture_t rightEyeTexture = {(void*)rightEyeDesc.m_nResolveTextureId, vr::API_OpenGL, vr::ColorSpace_Gamma }; error = vr::VRCompositor()->Submit(vr::Eye_Right, &rightEyeTexture ); //vr::VRCompositor()->PostPresentHandoff(); }
void VR_Canvas::StartRightPaneRender() { glBindFramebuffer(GL_FRAMEBUFFER, this->RightPane.FBO); }
void GLFrameBuffer::Unbind() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); }
/** **************************************************************************************************** @brief Render scene - camera, lights and objects(run through object list and call render function for every object) @param delete_buffer should we delete color and depth buffer? ***************************************************************************************************/ void TScene::Redraw(bool delete_buffer) { GLenum mrt[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; ///draw all lights unsigned i; for(i=0, m_il = m_lights.begin(); m_il != m_lights.end(), i<m_lights.size(); ++m_il, i++) { ///if light has a shadow, render scene from light view to texture (TScene::RenderShadowMap()) if((*m_il)->IsCastingShadow()) { //render shadow map if((*m_il)->GetType() == OMNI) { RenderShadowMapOmni(*m_il); } else RenderShadowMap(*m_il); } } //HDR/SSAO renderer - render to texture if(m_useHDR || m_useSSAO) { //render target viewport size glViewport(0,0,m_RT_resX,m_RT_resY); //attach framebuffer to render to glBindFramebuffer(GL_FRAMEBUFFER, m_f_buffer); //attach render texture glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex_cache["render_texture"], 0); ///use multisampled FBO if required if(m_msamples > 1) glBindFramebuffer(GL_FRAMEBUFFER, m_f_bufferMSAA); //multiple render targets - only when using SSAO and/or normal buffer if(m_useNormalBuffer) glDrawBuffers(2, mrt); //clear screen (if desired) if(delete_buffer) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } else //else render to default framebuffer, clear it(if desired) { if(delete_buffer) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } if(m_wireframe) glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); glViewport(0,0,m_RT_resX,m_RT_resY); //render all opaque objects DrawScene(DRAW_OPAQUE); //then transparent objects glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); DrawScene(DRAW_TRANSPARENT); glDisable(GL_BLEND); if(m_wireframe) glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //HDR/SSAO renderer if(m_useHDR || m_useSSAO) { //if MSAA enabled, copy from multisampled FBO to normal FBO if(m_msamples > 1) { //blit colors glReadBuffer(GL_COLOR_ATTACHMENT0); glDrawBuffer(GL_COLOR_ATTACHMENT0); glBindFramebuffer(GL_READ_FRAMEBUFFER, m_f_bufferMSAA); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_f_buffer); glBlitFramebuffer(0, 0, m_resx, m_resy, 0, 0, m_resx, m_resy, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT, GL_NEAREST); //blit normals if(m_useNormalBuffer) { glReadBuffer(GL_COLOR_ATTACHMENT1); glDrawBuffer(GL_COLOR_ATTACHMENT1); glBlitFramebuffer(0, 0, m_resx, m_resy, 0, 0, m_resx, m_resy, GL_COLOR_BUFFER_BIT, GL_NEAREST); } } if(m_useNormalBuffer) glDrawBuffer(GL_COLOR_ATTACHMENT0); //attach bloom texture glBindFramebuffer(GL_FRAMEBUFFER, m_f_buffer); glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex_cache["bloom_texture"], 0); //downsample bloom texture by setting new viewport glViewport(0,0,m_RT_resX/2,m_RT_resY/2); //Bloom/SSAO pass RenderPass("mat_bloom_hdr_ssao"); //horizontal blur pass RenderPass("mat_blur_horiz"); //vertical blur pass glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex_cache["blur_texture"], 0); RenderPass("mat_blur_vert"); //go back to regular framebuffer glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //final draw with bloom and tone mapping glViewport(0,0,m_resx,m_resy); //restore original scene viewport RenderPass("mat_tonemap"); } //show shadow maps if(m_draw_shadow_map) { for(int i=0; i<2; i++) { const float q_size = 0.5f; if(m_lights[0]->GetType() == OMNI) { SetUniform("show_depth_omni", "far_plane", SHADOW_FAR); SetUniform("show_depth_omni", "index", float(i)); RenderSmallQuad("show_depth_omni", 0.0f, i*q_size, q_size); } else { SetUniform("show_depth", "far_plane", SHADOW_FAR); RenderSmallQuad("show_depth", 0.0f, 0.0f, q_size); break; } } } //finish drawing, restore buffers glBindVertexArray(0); }
void GLFrameBuffer::Bind() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, id); }
void PostProcessor::_postDraw() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); video().getRender().dropRenderState(); glUseProgram(0); }
//-------------------------------------------------------------- void ofFbo::allocate(Settings _settings) { if(!checkGLSupport()) return; clear(); settings.renderer = _settings.renderer; // check that passed values are correct if(_settings.width <= 0 || _settings.height <= 0){ ofLogError("ofFbo") << "width and height have to be more than 0"; } if(_settings.numSamples > maxSamples() && maxSamples() > -1) { ofLogWarning("ofFbo") << "allocate(): clamping numSamples " << _settings.numSamples << " to maxSamples " << maxSamples() << " for frame buffer object" << fbo; _settings.numSamples = maxSamples(); } if(_settings.depthStencilAsTexture && _settings.numSamples){ ofLogWarning("ofFbo") << "allocate(): multisampling not supported with depthStencilAsTexture, setting 0 samples for frame buffer object " << fbo; _settings.numSamples = 0; } //currently depth only works if stencil is enabled. // http://forum.openframeworks.cc/index.php/topic,6837.0.html #ifdef TARGET_OPENGLES if(_settings.useDepth){ _settings.useStencil = true; } if( _settings.depthStencilAsTexture ){ _settings.depthStencilAsTexture = false; ofLogWarning("ofFbo") << "allocate(): depthStencilAsTexture is not available for iOS"; } #endif GLenum depthAttachment = GL_DEPTH_ATTACHMENT; if( _settings.useDepth && _settings.useStencil ){ _settings.depthStencilInternalFormat = GL_DEPTH_STENCIL; #ifdef TARGET_OPENGLES depthAttachment = GL_DEPTH_ATTACHMENT; #else depthAttachment = GL_DEPTH_STENCIL_ATTACHMENT; #endif }else if(_settings.useDepth){ depthAttachment = GL_DEPTH_ATTACHMENT; }else if(_settings.useStencil){ depthAttachment = GL_STENCIL_ATTACHMENT; _settings.depthStencilInternalFormat = GL_STENCIL_INDEX; } // set needed values for allocation on instance settings // the rest will be set by the corresponding methods during allocation settings.width = _settings.width; settings.height = _settings.height; settings.numSamples = _settings.numSamples; // create main fbo // this is the main one we bind for drawing into // all the renderbuffers are attached to this (whether MSAA is enabled or not) glGenFramebuffers(1, &fbo); retainFB(fbo); GLint previousFboId = 0; // note that we are using a glGetInteger method here, which may stall the pipeline. // in the allocate() method, this is not that tragic since this will not be called // within the draw() loop. Here, we need not optimise for performance, but for // simplicity and readability . glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFboId); glBindFramebuffer(GL_FRAMEBUFFER, fbo); //- USE REGULAR RENDER BUFFER if(!_settings.depthStencilAsTexture){ if(_settings.useDepth && _settings.useStencil){ stencilBuffer = depthBuffer = createAndAttachRenderbuffer(_settings.depthStencilInternalFormat, depthAttachment); retainRB(stencilBuffer); retainRB(depthBuffer); }else if(_settings.useDepth){ depthBuffer = createAndAttachRenderbuffer(_settings.depthStencilInternalFormat, depthAttachment); retainRB(depthBuffer); }else if(_settings.useStencil){ stencilBuffer = createAndAttachRenderbuffer(_settings.depthStencilInternalFormat, depthAttachment); retainRB(stencilBuffer); } //- INSTEAD USE TEXTURE }else{ if(_settings.useDepth || _settings.useStencil){ createAndAttachDepthStencilTexture(_settings.textureTarget,_settings.depthStencilInternalFormat,depthAttachment); #ifdef TARGET_OPENGLES // if there's depth and stencil the texture should be attached as // depth and stencil attachments // http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt if(_settings.useDepth && _settings.useStencil){ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthBufferTex.texData.textureID, 0); } #endif } } settings.useDepth = _settings.useDepth; settings.useStencil = _settings.useStencil; settings.depthStencilInternalFormat = _settings.depthStencilInternalFormat; settings.depthStencilAsTexture = _settings.depthStencilAsTexture; settings.textureTarget = _settings.textureTarget; settings.wrapModeHorizontal = _settings.wrapModeHorizontal; settings.wrapModeVertical = _settings.wrapModeVertical; settings.maxFilter = _settings.maxFilter; settings.minFilter = _settings.minFilter; // if we want MSAA, create a new fbo for textures #ifndef TARGET_OPENGLES if(_settings.numSamples){ glGenFramebuffers(1, &fboTextures); retainFB(fboTextures); }else{ fboTextures = fbo; } #else fboTextures = fbo; if(_settings.numSamples){ ofLogWarning("ofFbo") << "allocate(): multisampling not supported in OpenGL ES"; } #endif // now create all textures and color buffers if(_settings.colorFormats.size() > 0) { for(int i=0; i<(int)_settings.colorFormats.size(); i++) createAndAttachTexture(_settings.colorFormats[i], i); } else if(_settings.numColorbuffers > 0) { for(int i=0; i<_settings.numColorbuffers; i++) createAndAttachTexture(_settings.internalformat, i); _settings.colorFormats = settings.colorFormats; } else { ofLogWarning("ofFbo") << "allocate(): no color buffers specified for frame buffer object " << fbo; } settings.internalformat = _settings.internalformat; dirty.resize(_settings.colorFormats.size(), true); // we start with all color buffers dirty. // if textures are attached to a different fbo (e.g. if using MSAA) check it's status if(fbo != fboTextures) { glBindFramebuffer(GL_FRAMEBUFFER, fboTextures); } // check everything is ok with this fbo bIsAllocated = checkStatus(); // restore previous framebuffer id glBindFramebuffer(GL_FRAMEBUFFER, previousFboId); /* UNCOMMENT OUTSIDE OF DOING RELEASES // this should never happen if(settings != _settings) ofLogWarning("ofFbo") << "allocation not complete, passed settings not equal to created ones, this is an internal OF bug"; */ #ifdef TARGET_ANDROID ofAddListener(ofxAndroidEvents().reloadGL,this,&ofFbo::reloadFbo); #endif }
void GlFrameBufferObject::release() { glBindFramebuffer(GL_FRAMEBUFFER, 0); _bufferBound = false; }
void VR_Canvas::StopRendering() { glBindFramebuffer(GL_FRAMEBUFFER,0); }
void OffscreenBuffer::Bind() const { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID); }
//-------------------------------------------------------------------------------------- // Name: Update() // Desc: Update the scene. //-------------------------------------------------------------------------------------- VOID CSample::Update() { // Process input UINT32 nButtons; UINT32 nPressedButtons; FrmGetInput( &m_Input, &nButtons, &nPressedButtons ); // Toggle user interface if( nPressedButtons & INPUT_KEY_0 ) m_UserInterface.AdvanceState(); if( nPressedButtons & FRM_INPUT::KEY_1 ) { if (!m_is_frozen) { m_bRotationOn = TRUE; m_is_frozen = TRUE; m_freeze_time = m_Timer.GetTime(); } } if( nPressedButtons & FRM_INPUT::KEY_2 ) { m_is_frozen = FALSE; m_bRotationOn = FALSE; } /* Kick off off-screen rendering */ glBindFramebuffer(GL_FRAMEBUFFER, m_fboId); glUseProgram(m_MultiSampleShaderProgram); /* Check if we need to switch to a different texture. This needs to happen either when the * first frame is being rendered, or after a pre-defined number of seconds have passed * since the last time we've made a switch. */ UINT32 frame_time_seconds = 0; static UINT32 last_frame_time_seconds = 0; const UINT32 switch_delta_s = 5; frame_time_seconds = (UINT32) m_Timer.GetTime(); if (last_frame_time_seconds == 0 || (frame_time_seconds - last_frame_time_seconds >= switch_delta_s)) { m_currentTextureIndex = (frame_time_seconds / switch_delta_s) % NO_MULTIMPLE_TEXTURES; //TODO need to show sample no on to the screen once app starts working. //LOG_INFO("Using texture with [%d] samples", _textures[n_texture_to_use].n_samples); InitOffScreenFramebuffer(m_currentTextureIndex); last_frame_time_seconds = frame_time_seconds; } /* Set up MVP matrix */ static FLOAT32 angle = 0.0f; UINT32 frame_time_msec = 0; FRMVECTOR3 rotation_xyz = FRMVECTOR3( 1.0f, 0.0f, 0.0f); FRMVECTOR3 translation_xyz = FRMVECTOR3(0.0f, 0.0f, -3.0f); if (m_is_frozen) { frame_time_msec = (UINT32) (m_freeze_time * 1000); } else { frame_time_msec = (UINT32) (m_Timer.GetTime() * 1000); } angle = float(frame_time_msec % FULL_ROTATION_TIME_MSEC) / float(FULL_ROTATION_TIME_MSEC) * 2 * 3.14152965f; { FRMMATRIX4X4 model; FRMMATRIX4X4 rotation_matrix; FRMMATRIX4X4 translation_matrix; translation_matrix = FrmMatrixTranslate(translation_xyz); rotation_matrix = FrmMatrixRotate (angle,rotation_xyz); model = FrmMatrixMultiply(rotation_matrix, translation_matrix); m_mvp = FrmMatrixMultiply(model, m_matProj); glProgramUniformMatrix4fv(m_MultiSampleShaderProgram, m_mvpLocation, 1, /* count */ GL_FALSE, /* transpose */ (FLOAT32*) &m_mvp); } }
/** * Function to render and display content. */ GLUSboolean renderWaterTexture(GLUSfloat passedTime) { static WaveParameters waveParameters[NUMBERWAVES]; static WaveDirections waveDirections[NUMBERWAVES]; static GLfloat overallSteepness = 0.2f; // Waves memset(waveParameters, 0, sizeof(waveParameters)); memset(waveDirections, 0, sizeof(waveDirections)); // Wave One waveParameters[0].speed = 0.05f; waveParameters[0].amplitude = 0.02f; waveParameters[0].wavelength = 0.3f; waveParameters[0].steepness = overallSteepness / (waveParameters[0].wavelength * waveParameters[0].amplitude * (GLfloat) NUMBERWAVES); waveDirections[0].x = +1.0f; waveDirections[0].z = +1.5f; // Wave Two waveParameters[1].speed = 0.1f; waveParameters[1].amplitude = 0.01f; waveParameters[1].wavelength = 0.4f; waveParameters[1].steepness = overallSteepness / (waveParameters[1].wavelength * waveParameters[1].amplitude * (GLfloat) NUMBERWAVES); waveDirections[1].x = +0.8f; waveDirections[1].z = +0.2f; // Wave Thre waveParameters[2].speed = 0.04f; waveParameters[2].amplitude = 0.035f; waveParameters[2].wavelength = 0.1f; waveParameters[2].steepness = overallSteepness / (waveParameters[1].wavelength * waveParameters[1].amplitude * (GLfloat) NUMBERWAVES); waveDirections[2].x = -0.2f; waveDirections[2].z = -0.1f; // Wave Four waveParameters[3].speed = 0.05f; waveParameters[3].amplitude = 0.007f; waveParameters[3].wavelength = 0.2f; waveParameters[3].steepness = overallSteepness / (waveParameters[1].wavelength * waveParameters[1].amplitude * (GLfloat) NUMBERWAVES); waveDirections[3].x = -0.4f; waveDirections[3].z = -0.3f; glViewport(0, 0, TEXTURE_SIZE, TEXTURE_SIZE); glBindFramebuffer(GL_FRAMEBUFFER, g_fboWaterTexture); // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(g_programWaterTexture.program); glUniform1f(g_passedTimeWaterTextureLocation, passedTime); glUniform4fv(g_waveParametersWaterTextureLocation, 4 * NUMBERWAVES, (GLfloat*) waveParameters); glUniform2fv(g_waveDirectionsWaterTextureLocation, 2 * NUMBERWAVES, (GLfloat*) waveDirections); glFrontFace(GL_CCW); glBindVertexArray(g_vaoWaterTexture); glDrawElements(GL_TRIANGLES, g_numberIndicesWaterTexture, GL_UNSIGNED_INT, 0); // glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, g_parentWidth, g_parentHeight); return GLUS_TRUE; }
static struct ctx* create_context(void) { const char *vert_shader = "#version 100\n" "precision mediump float;\n" "uniform vec2 resolution;\n" "attribute vec4 pos;\n" "attribute vec2 uv;\n" "varying vec2 v_uv;\n" "void main() {\n" " mat4 ortho = mat4(" " 2.0/resolution.x, 0, 0, 0," " 0, -2.0/resolution.y, 0, 0," " 0, 0, -1, 0," " -1, 1, 0, 1" " );\n" " gl_Position = ortho * pos;\n" " v_uv = uv;\n" "}\n"; const char *frag_shader_dummy = "#version 100\n" "precision mediump float;\n" "void main() {\n" " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" "}\n"; const char *frag_shader_cursor = "#version 100\n" "precision highp float;\n" "uniform sampler2D texture0;\n" "varying vec2 v_uv;\n" "void main() {\n" " vec4 palette[3];\n" " palette[0] = vec4(0.0, 0.0, 0.0, 1.0);\n" " palette[1] = vec4(1.0, 1.0, 1.0, 1.0);\n" " palette[2] = vec4(0.0, 0.0, 0.0, 0.0);\n" " gl_FragColor = palette[int(texture2D(texture0, v_uv).r * 256.0)];\n" "}\n"; const char *frag_shader_rgb = "#version 100\n" "precision mediump float;\n" "uniform sampler2D texture0;\n" "uniform float dim;\n" "varying vec2 v_uv;\n" "void main() {\n" " gl_FragColor = vec4(texture2D(texture0, v_uv).rgb * dim, 1.0);\n" "}\n"; const char *frag_shader_rgba = "#version 100\n" "precision mediump float;\n" "uniform sampler2D texture0;\n" "uniform float dim;\n" "varying vec2 v_uv;\n" "void main() {\n" " vec4 col = texture2D(texture0, v_uv);\n" " gl_FragColor = vec4(col.rgb * dim, col.a);\n" "}\n"; const char *frag_shader_egl = "#version 100\n" "#extension GL_OES_EGL_image_external : require\n" "precision mediump float;\n" "uniform samplerExternalOES texture0;\n" "uniform float dim;\n" "varying vec2 v_uv;\n" "void main()\n" "{\n" " vec4 col = texture2D(texture0, v_uv);\n" " gl_FragColor = vec4(col.rgb * dim, col.a)\n;" "}\n"; #define FRAGMENT_CONVERT_YUV \ " y *= dim;\n" \ " u *= dim;\n" \ " v *= dim;\n" \ " gl_FragColor.r = y + 1.59602678 * v;\n" \ " gl_FragColor.g = y - 0.39176229 * u - 0.81296764 * v;\n" \ " gl_FragColor.b = y + 2.01723214 * u;\n" \ " gl_FragColor.a = 1.0;\n" const char *frag_shader_y_uv = "#version 100\n" "precision mediump float;\n" "uniform sampler2D texture0;\n" "uniform sampler2D texture1;\n" "uniform float dim;\n" "varying vec2 v_uv;\n" "void main() {\n" " float y = 1.16438356 * (texture2D(texture0, v_uv).x - 0.0625);\n" " float u = texture2D(texture1, v_uv).r - 0.5;\n" " float v = texture2D(texture1, v_uv).g - 0.5;\n" FRAGMENT_CONVERT_YUV "}\n"; const char *frag_shader_y_u_v = "#version 100\n" "precision mediump float;\n" "uniform sampler2D texture0;\n" "uniform sampler2D texture1;\n" "uniform sampler2D texture2;\n" "uniform float dim;\n" "varying vec2 v_uv;\n" "void main() {\n" " float y = 1.16438356 * (texture2D(texture0, v_uv).x - 0.0625);\n" " float u = texture2D(texture1, v_uv).x - 0.5;\n" " float v = texture2D(texture2, v_uv).x - 0.5;\n" FRAGMENT_CONVERT_YUV "}\n"; const char *frag_shader_y_xuxv = "#version 100\n" "precision mediump float;\n" "uniform sampler2D texture0;\n" "uniform sampler2D texture1;\n" "uniform float dim;\n" "varying vec2 v_uv;\n" "void main() {\n" " float y = 1.16438356 * (texture2D(texture0, v_uv).x - 0.0625);\n" " float u = texture2D(texture1, v_uv).g - 0.5;\n" " float v = texture2D(texture1, v_uv).a - 0.5;\n" FRAGMENT_CONVERT_YUV "}\n"; struct ctx *context; if (!(context = calloc(1, sizeof(struct ctx)))) return NULL; const char *str; str = (const char*)GL_CALL(glGetString(GL_VERSION)); wlc_log(WLC_LOG_INFO, "GL version: %s", str ? str : "(null)"); str = (const char*)GL_CALL(glGetString(GL_VENDOR)); wlc_log(WLC_LOG_INFO, "GL vendor: %s", str ? str : "(null)"); /** TODO: Should be available in GLES3 */ #if 0 GL_CALL(glGetInternalFormativ(GL_TEXTURE_2D, GL_RGBA, GL_TEXTURE_IMAGE_FORMAT, 1, &context->preferred_format)); GL_CALL(glGetInternalFormativ(GL_TEXTURE_2D, GL_RGBA, GL_TEXTURE_IMAGE_TYPE, 1, &context->preferred_type)); wlc_log(WLC_LOG_INFO, "Preferred texture format: %d", context->preferred_format); wlc_log(WLC_LOG_INFO, "Preferred texture type: %d", context->preferred_type); #endif context->extensions = (const char*)GL_CALL(glGetString(GL_EXTENSIONS)); if (!has_extension(context, "GL_OES_EGL_image_external")) { wlc_log(WLC_LOG_WARN, "gles2: GL_OES_EGL_image_external not available"); frag_shader_egl = frag_shader_dummy; } const struct { const char *vert; const char *frag; } map[PROGRAM_LAST] = { { vert_shader, frag_shader_rgb }, // PROGRAM_RGB { vert_shader, frag_shader_rgba }, // PROGRAM_RGBA { vert_shader, frag_shader_egl }, // PROGRAM_EGL { vert_shader, frag_shader_y_uv }, // PROGRAM_Y_UV { vert_shader, frag_shader_y_u_v }, // PROGRAM_Y_U_V { vert_shader, frag_shader_y_xuxv }, // PROGRAM_Y_XUXV { vert_shader, frag_shader_cursor }, // PROGRAM_CURSOR }; for (GLuint i = 0; i < PROGRAM_LAST; ++i) { GLuint vert = create_shader(map[i].vert, GL_VERTEX_SHADER); GLuint frag = create_shader(map[i].frag, GL_FRAGMENT_SHADER); context->programs[i].obj = glCreateProgram(); GL_CALL(glAttachShader(context->programs[i].obj, vert)); GL_CALL(glAttachShader(context->programs[i].obj, frag)); GL_CALL(glLinkProgram(context->programs[i].obj)); GL_CALL(glDeleteShader(vert)); GL_CALL(glDeleteShader(frag)); GLint status; GL_CALL(glGetProgramiv(context->programs[i].obj, GL_LINK_STATUS, &status)); if (!status) { GLsizei len; char log[1024]; GL_CALL(glGetProgramInfoLog(context->programs[i].obj, sizeof(log), &len, log)); wlc_log(WLC_LOG_ERROR, "Linking:\n%*s\n", len, log); abort(); } set_program(context, i); GL_CALL(glBindAttribLocation(context->programs[i].obj, 0, "pos")); GL_CALL(glBindAttribLocation(context->programs[i].obj, 1, "uv")); for (int u = 0; u < UNIFORM_LAST; ++u) { context->programs[i].uniforms[u] = GL_CALL(glGetUniformLocation(context->programs[i].obj, uniform_names[u])); } GL_CALL(glUniform1i(context->programs[i].uniforms[UNIFORM_TEXTURE0], 0)); GL_CALL(glUniform1i(context->programs[i].uniforms[UNIFORM_TEXTURE1], 1)); GL_CALL(glUniform1i(context->programs[i].uniforms[UNIFORM_TEXTURE2], 2)); } struct { GLenum format; GLuint w, h; GLenum type; const void *data; } images[TEXTURE_LAST] = { { GL_LUMINANCE, 1, 1, GL_UNSIGNED_BYTE, NULL }, // TEXTURE_BLACK { GL_LUMINANCE, 14, 14, GL_UNSIGNED_BYTE, cursor_palette }, // TEXTURE_CURSOR { GL_RGBA, 0, 0, GL_UNSIGNED_BYTE, NULL }, // TEXTURE_FAKEFB }; GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1)); GL_CALL(glGenTextures(TEXTURE_LAST, context->textures)); for (GLuint i = 0; i < TEXTURE_LAST; ++i) { GL_CALL(glBindTexture(GL_TEXTURE_2D, context->textures[i])); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, images[i].format, images[i].w, images[i].h, 0, images[i].format, images[i].type, images[i].data)); } GL_CALL(glEnableVertexAttribArray(0)); GL_CALL(glEnableVertexAttribArray(1)); GL_CALL(glGenFramebuffers(1, &context->clear_fbo)); GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, context->clear_fbo)); GL_CALL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, context->textures[TEXTURE_FAKEFB], 0)); GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, 0)); GL_CALL(glEnable(GL_BLEND)); GL_CALL(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); GL_CALL(glClearColor(0.0, 0.0, 0.0, 0.0)); return context; }
GLUSuint initWaterTexture(GLUSfloat waterPlaneLength) { GLfloat projectionMatrixWaterTexture[16]; GLfloat modelViewMatrixWaterTexture[16]; GLUSshape plane; GLUStextfile vertexSource; GLUStextfile fragmentSource; glusLoadTextFile("../Example15/shader/WaterTexture.vert.glsl", &vertexSource); glusLoadTextFile("../Example15/shader/WaterTexture.frag.glsl", &fragmentSource); glusBuildProgramFromSource(&g_programWaterTexture, (const GLUSchar**) &vertexSource.text, 0, 0, 0, (const GLUSchar**) &fragmentSource.text); glusDestroyTextFile(&vertexSource); glusDestroyTextFile(&fragmentSource); // g_projectionMatrixWaterTextureLocation = glGetUniformLocation(g_programWaterTexture.program, "u_projectionMatrix"); g_modelViewMatrixWaterTextureLocation = glGetUniformLocation(g_programWaterTexture.program, "u_modelViewMatrix"); g_waterPlaneLengthWaterTextureLocation = glGetUniformLocation(g_programWaterTexture.program, "u_waterPlaneLength"); g_passedTimeWaterTextureLocation = glGetUniformLocation(g_programWaterTexture.program, "u_passedTime"); g_waveParametersWaterTextureLocation = glGetUniformLocation(g_programWaterTexture.program, "u_waveParameters"); g_waveDirectionsWaterTextureLocation = glGetUniformLocation(g_programWaterTexture.program, "u_waveDirections"); g_vertexWaterTextureLocation = glGetAttribLocation(g_programWaterTexture.program, "a_vertex"); g_texCoordWaterTextureLocation = glGetAttribLocation(g_programWaterTexture.program, "a_texCoord"); // glGenTextures(1, &g_mirrorTexture); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, g_mirrorTexture); glTexImage2D(GL_TEXTURE_2D, 0, GLUS_RGB, TEXTURE_SIZE, TEXTURE_SIZE, 0, GLUS_RGB, GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(GL_TEXTURE_2D, 0); // glGenRenderbuffers(1, &g_depthMirrorTexture); glBindRenderbuffer(GL_RENDERBUFFER, g_depthMirrorTexture); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, TEXTURE_SIZE, TEXTURE_SIZE); glBindRenderbuffer(GL_RENDERBUFFER, 0); // glGenFramebuffers(1, &g_fboWaterTexture); glBindFramebuffer(GL_FRAMEBUFFER, g_fboWaterTexture); // Attach the color buffer ... glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, g_mirrorTexture, 0); // ... and the depth buffer, glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, g_depthMirrorTexture); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { printf("GL_FRAMEBUFFER_COMPLETE error 0x%x", glCheckFramebufferStatus(GL_FRAMEBUFFER)); return GLUS_FALSE; } glBindFramebuffer(GL_FRAMEBUFFER, 0); // glBindVertexArray(0); // glusCreatePlanef(&plane, TEXTURE_SIZE / 2.0f); g_numberIndicesWaterTexture = plane.numberIndices; glGenBuffers(1, &g_verticesWaterTextureVBO); glBindBuffer(GL_ARRAY_BUFFER, g_verticesWaterTextureVBO); glBufferData(GL_ARRAY_BUFFER, plane.numberVertices * 4 * sizeof(GLfloat), (GLfloat*) plane.vertices, GL_STATIC_DRAW); glGenBuffers(1, &g_texCoordsWaterTextureVBO); glBindBuffer(GL_ARRAY_BUFFER, g_texCoordsWaterTextureVBO); glBufferData(GL_ARRAY_BUFFER, plane.numberVertices * 2 * sizeof(GLfloat), (GLfloat*) plane.texCoords, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glGenBuffers(1, &g_indicesWaterTextureVBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_indicesWaterTextureVBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, plane.numberIndices * sizeof(GLuint), (GLuint*) plane.indices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glusDestroyShapef(&plane); // glUseProgram(g_programWaterTexture.program); glusLookAtf(modelViewMatrixWaterTexture, 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); glUniformMatrix4fv(g_modelViewMatrixWaterTextureLocation, 1, GL_FALSE, modelViewMatrixWaterTexture); glusOrthof(projectionMatrixWaterTexture, -(GLfloat) TEXTURE_SIZE / 2, (GLfloat) TEXTURE_SIZE / 2, -(GLfloat) TEXTURE_SIZE / 2, (GLfloat) TEXTURE_SIZE / 2, 1.0f, 100.0f); glUniformMatrix4fv(g_projectionMatrixWaterTextureLocation, 1, GL_FALSE, projectionMatrixWaterTexture); glUniform1f(g_waterPlaneLengthWaterTextureLocation, waterPlaneLength); // glGenVertexArrays(1, &g_vaoWaterTexture); glBindVertexArray(g_vaoWaterTexture); glBindBuffer(GL_ARRAY_BUFFER, g_verticesWaterTextureVBO); glVertexAttribPointer(g_vertexWaterTextureLocation, 4, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(g_vertexWaterTextureLocation); glBindBuffer(GL_ARRAY_BUFFER, g_texCoordsWaterTextureVBO); glVertexAttribPointer(g_texCoordWaterTextureLocation, 2, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(g_texCoordWaterTextureLocation); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_indicesWaterTextureVBO); // glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); return g_mirrorTexture; }
void gl4DrawStrips(GLuint output_fbo) { checkOverflowAndReset(); if (geom_fbo == 0) { glGenFramebuffers(1, &geom_fbo); glBindFramebuffer(GL_FRAMEBUFFER, geom_fbo); CreateTextures(); GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); verify(uStatus == GL_FRAMEBUFFER_COMPLETE); } else { glBindFramebuffer(GL_FRAMEBUFFER, geom_fbo); if (stencilTexId == 0) CreateTextures(); } if (texSamplers[0] == 0) glGenSamplers(2, texSamplers); glcache.DepthMask(GL_TRUE); glStencilMask(0xFF); glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glCheck(); SetupMainVBO(); //Draw the strips ! //We use sampler 0 glActiveTexture(GL_TEXTURE0); glcache.Disable(GL_BLEND); glProvokingVertex(GL_LAST_VERTEX_CONVENTION); RenderPass previous_pass = {0}; int render_pass_count = pvrrc.render_passes.used(); for (int render_pass = 0; render_pass < render_pass_count; render_pass++) { const RenderPass& current_pass = pvrrc.render_passes.head()[render_pass]; // Check if we can skip this pass, in part or completely, in case nothing is drawn (Cosmic Smash) bool skip_op_pt = true; bool skip_tr = true; for (int j = previous_pass.op_count; skip_op_pt && j < current_pass.op_count; j++) { if (pvrrc.global_param_op.head()[j].count > 2) skip_op_pt = false; } for (int j = previous_pass.pt_count; skip_op_pt && j < current_pass.pt_count; j++) { if (pvrrc.global_param_pt.head()[j].count > 2) skip_op_pt = false; } for (int j = previous_pass.tr_count; skip_tr && j < current_pass.tr_count; j++) { if (pvrrc.global_param_tr.head()[j].count > 2) skip_tr = false; } if (skip_op_pt && skip_tr) { previous_pass = current_pass; continue; } if (!skip_op_pt) { // // PASS 1: Geometry pass to update depth and stencil // if (render_pass > 0) { // Make a copy of the depth buffer that will be reused in pass 2 if (depth_fbo == 0) glGenFramebuffers(1, &depth_fbo); glBindFramebuffer(GL_FRAMEBUFFER, depth_fbo); if (depthSaveTexId == 0) { depthSaveTexId = glcache.GenTexture(); glcache.BindTexture(GL_TEXTURE_2D, depthSaveTexId); glcache.TexParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT); glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glcache.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH32F_STENCIL8, screen_width, screen_height, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); glCheck(); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthSaveTexId, 0); glCheck(); } GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); verify(uStatus == GL_FRAMEBUFFER_COMPLETE); glBindFramebuffer(GL_READ_FRAMEBUFFER, geom_fbo); glBlitFramebuffer(0, 0, screen_width, screen_height, 0, 0, screen_width, screen_height, GL_DEPTH_BUFFER_BIT, GL_NEAREST); glCheck(); glBindFramebuffer(GL_FRAMEBUFFER, geom_fbo); } glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glcache.Enable(GL_DEPTH_TEST); glcache.DepthMask(GL_TRUE); glcache.Enable(GL_STENCIL_TEST); glcache.StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); DrawList<ListType_Opaque, false>(pvrrc.global_param_op, previous_pass.op_count, current_pass.op_count - previous_pass.op_count, 0); DrawList<ListType_Punch_Through, false>(pvrrc.global_param_pt, previous_pass.pt_count, current_pass.pt_count - previous_pass.pt_count, 0); // Modifier volumes if (settings.rend.ModifierVolumes) DrawModVols(previous_pass.mvo_count, current_pass.mvo_count - previous_pass.mvo_count); // // PASS 2: Render OP and PT to fbo // if (render_pass == 0) { glcache.DepthMask(GL_TRUE); glClear(GL_DEPTH_BUFFER_BIT); } else { // Restore the depth buffer from the last render pass // FIXME This is pretty slow apparently (CS) glBindFramebuffer(GL_DRAW_FRAMEBUFFER, geom_fbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, depth_fbo); glBlitFramebuffer(0, 0, screen_width, screen_height, 0, 0, screen_width, screen_height, GL_DEPTH_BUFFER_BIT, GL_NEAREST); glCheck(); glBindFramebuffer(GL_FRAMEBUFFER, geom_fbo); } glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glcache.Disable(GL_STENCIL_TEST); // Bind stencil buffer for the fragment shader (shadowing) glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, stencilTexId); glActiveTexture(GL_TEXTURE0); glCheck(); //Opaque DrawList<ListType_Opaque, false>(pvrrc.global_param_op, previous_pass.op_count, current_pass.op_count - previous_pass.op_count, 1); //Alpha tested DrawList<ListType_Punch_Through, false>(pvrrc.global_param_pt, previous_pass.pt_count, current_pass.pt_count - previous_pass.pt_count, 1); // Unbind stencil glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); } if (!skip_tr) { // // PASS 3: Render TR to a-buffers // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glcache.Disable(GL_DEPTH_TEST); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, depthTexId); glActiveTexture(GL_TEXTURE0); //Alpha blended if (current_pass.autosort) DrawList<ListType_Translucent, true>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count, 3); // 3 because pass 2 is no more else DrawList<ListType_Translucent, false>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count, 3); // 3 because pass 2 is no more glCheck(); // Translucent modifier volumes if (settings.rend.ModifierVolumes) DrawTranslucentModVols(previous_pass.mvo_tr_count, current_pass.mvo_tr_count - previous_pass.mvo_tr_count); if (render_pass < render_pass_count - 1) { // // PASS 3b: Geometry pass with TR to update the depth for the next TA render pass // // Unbind depth texture glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); glcache.Enable(GL_DEPTH_TEST); if (current_pass.autosort) DrawList<ListType_Translucent, true>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count, 0); else DrawList<ListType_Translucent, false>(pvrrc.global_param_tr, previous_pass.tr_count, current_pass.tr_count - previous_pass.tr_count, 0); // // PASS 3c: Render a-buffer to temporary texture // GLuint texId = CreateColorFBOTexture(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glActiveTexture(GL_TEXTURE0); glBindSampler(0, 0); glBindTexture(GL_TEXTURE_2D, opaqueTexId); renderABuffer(current_pass.autosort); SetupMainVBO(); glcache.DeleteTextures(1, &opaqueTexId); opaqueTexId = texId; glCheck(); } } if (!skip_op_pt && render_pass < render_pass_count - 1) { // Clear the stencil from this pass glStencilMask(0xFF); glClear(GL_STENCIL_BUFFER_BIT); } previous_pass = current_pass; } // // PASS 4: Render a-buffers to screen // glBindFramebuffer(GL_FRAMEBUFFER, output_fbo); glCheck(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glActiveTexture(GL_TEXTURE0); glBindSampler(0, 0); glBindTexture(GL_TEXTURE_2D, opaqueTexId); renderABuffer(previous_pass.autosort); SetupMainVBO(); vertex_buffer_unmap(); }
// The MAIN function, from here we start our application and run our Game loop int main() { // Init GLFW glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); GLFWwindow* window = glfwCreateWindow(SCR_WIDTH/2, SCR_HEIGHT/2, "LearnOpenGL", nullptr, nullptr); // Windowed glfwMakeContextCurrent(window); // Set the required callback functions glfwSetKeyCallback(window, key_callback); glfwSetCursorPosCallback(window, mouse_callback); glfwSetScrollCallback(window, scroll_callback); // Options glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); // Initialize GLEW to setup the OpenGL Function pointers glewExperimental = GL_TRUE; glewInit(); // Define the viewport dimensions glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT); // Setup some OpenGL options glEnable(GL_DEPTH_TEST); // Setup and compile our shaders Shader shaderBloom("shaders/bloom.vs", "shaders/bloom.frag"); Shader shaderLight("shaders/bloom.vs", "shaders/light_box.frag"); Shader shaderBlur("shaders/blur.vs", "shaders/blur.frag"); Shader shaderBloomFinal("shaders/bloom_final.vs", "shaders/bloom_final.frag"); // Set samplers shaderBloomFinal.Use(); glUniform1i(glGetUniformLocation(shaderBloomFinal.Program, "scene"), 0); glUniform1i(glGetUniformLocation(shaderBloomFinal.Program, "bloomBlur"), 1); // Light sources // - Positions std::vector<glm::vec3> lightPositions; lightPositions.push_back(glm::vec3(0.0f, 0.5f, 1.5f)); // back light lightPositions.push_back(glm::vec3(-4.0f, 0.5f, -3.0f)); lightPositions.push_back(glm::vec3(3.0f, 0.5f, 1.0f)); lightPositions.push_back(glm::vec3(-.8f, 2.4f, -1.0f)); // - Colors std::vector<glm::vec3> lightColors; lightColors.push_back(glm::vec3(2.0f, 2.0f, 2.0f)); lightColors.push_back(glm::vec3(1.5f, 0.0f, 0.0f)); lightColors.push_back(glm::vec3(0.0f, 0.0f, 1.5f)); lightColors.push_back(glm::vec3(0.0f, 1.5f, 0.0f)); // Load textures GLuint woodTexture = loadTexture("resources/textures/wood.png"); GLuint containerTexture = loadTexture("resources/textures/container2.png"); // Set up floating point framebuffer to render scene to GLuint hdrFBO; glGenFramebuffers(1, &hdrFBO); glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO); // - Create 2 floating point color buffers (1 for normal rendering, other for brightness treshold values) GLuint colorBuffers[2]; glGenTextures(2, colorBuffers); for (GLuint i = 0; i < 2; i++) { glBindTexture(GL_TEXTURE_2D, colorBuffers[i]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGB, GL_FLOAT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // We clamp to the edge as the blur filter would otherwise sample repeated texture values! glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // attach texture to framebuffer glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, colorBuffers[i], 0); } // - Create and attach depth buffer (renderbuffer) GLuint rboDepth; glGenRenderbuffers(1, &rboDepth); glBindRenderbuffer(GL_RENDERBUFFER, rboDepth); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, SCR_WIDTH, SCR_HEIGHT); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth); // - Tell OpenGL which color attachments we'll use (of this framebuffer) for rendering GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; glDrawBuffers(2, attachments); // - Finally check if framebuffer is complete if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer not complete!" << std::endl; glBindFramebuffer(GL_FRAMEBUFFER, 0); // Ping pong framebuffer for blurring GLuint pingpongFBO[2]; GLuint pingpongColorbuffers[2]; glGenFramebuffers(2, pingpongFBO); glGenTextures(2, pingpongColorbuffers); for (GLuint i = 0; i < 2; i++) { glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]); glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGB, GL_FLOAT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // We clamp to the edge as the blur filter would otherwise sample repeated texture values! glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0); // Also check if framebuffers are complete (no need for depth buffer) if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer not complete!" << std::endl; } glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Game loop while (!glfwWindowShouldClose(window)) { // Set frame time GLfloat currentFrame = glfwGetTime(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; // Check and call events glfwPollEvents(); Do_Movement(); // 1. Render scene into floating point framebuffer glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glm::mat4 projection = glm::perspective(camera.Zoom, (GLfloat)SCR_WIDTH / (GLfloat)SCR_HEIGHT, 0.1f, 100.0f); glm::mat4 view = camera.GetViewMatrix(); glm::mat4 model; shaderBloom.Use(); glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection)); glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "view"), 1, GL_FALSE, glm::value_ptr(view)); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, woodTexture); // - set lighting uniforms for (GLuint i = 0; i < lightPositions.size(); i++) { glUniform3fv(glGetUniformLocation(shaderBloom.Program, ("lights[" + std::to_string(i) + "].Position").c_str()), 1, &lightPositions[i][0]); glUniform3fv(glGetUniformLocation(shaderBloom.Program, ("lights[" + std::to_string(i) + "].Color").c_str()), 1, &lightColors[i][0]); } glUniform3fv(glGetUniformLocation(shaderBloom.Program, "viewPos"), 1, &camera.Position[0]); // - create one large cube that acts as the floor // model = glm::mat4(); // model = glm::translate(model, glm::vec3(0.0f, -1.0f, 0.0)); // model = glm::scale(model, glm::vec3(25.0f, 1.0f, 25.0f)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // - then create multiple cubes as the scenery // glBindTexture(GL_TEXTURE_2D, containerTexture); // model = glm::mat4(); // model = glm::translate(model, glm::vec3(0.0f, 1.5f, 0.0)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // model = glm::mat4(); // model = glm::translate(model, glm::vec3(2.0f, 0.0f, 1.0)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // model = glm::mat4(); // model = glm::translate(model, glm::vec3(-1.0f, -1.0f, 2.0)); // model = glm::rotate(model, 60.0f, glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // model = glm::scale(model, glm::vec3(2.0)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // model = glm::mat4(); // model = glm::translate(model, glm::vec3(0.0f, 2.7f, 4.0)); // model = glm::rotate(model, 23.0f, glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // model = glm::scale(model, glm::vec3(2.5)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // model = glm::mat4(); // model = glm::translate(model, glm::vec3(-2.0f, 1.0f, -3.0)); // model = glm::rotate(model, 124.0f, glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // model = glm::scale(model, glm::vec3(2.0)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // RenderCube(); // model = glm::mat4(); // model = glm::translate(model, glm::vec3(-3.0f, 0.0f, 0.0)); // glUniformMatrix4fv(glGetUniformLocation(shaderBloom.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); // RenderCube(); // - finally show all the light sources as bright cubes shaderLight.Use(); glUniformMatrix4fv(glGetUniformLocation(shaderLight.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection)); glUniformMatrix4fv(glGetUniformLocation(shaderLight.Program, "view"), 1, GL_FALSE, glm::value_ptr(view)); for (GLuint i = 0; i < lightPositions.size(); i++) { model = glm::mat4(); model = glm::translate(model, glm::vec3(lightPositions[i])); model = glm::scale(model, glm::vec3(0.5f)); glUniformMatrix4fv(glGetUniformLocation(shaderLight.Program, "model"), 1, GL_FALSE, glm::value_ptr(model)); glUniform3fv(glGetUniformLocation(shaderLight.Program, "lightColor"), 1, &lightColors[i][0]); RenderCube(); } glBindFramebuffer(GL_FRAMEBUFFER, 0); // 2. Blur bright fragments w/ two-pass Gaussian Blur GLboolean horizontal = true, first_iteration = true; GLuint amount = 10; shaderBlur.Use(); for (GLuint i = 0; i < amount; i++) { glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]); glUniform1i(glGetUniformLocation(shaderBlur.Program, "horizontal"), horizontal); glBindTexture(GL_TEXTURE_2D, first_iteration ? colorBuffers[1] : pingpongColorbuffers[!horizontal]); // bind texture of other framebuffer (or scene if first iteration) RenderQuad(); horizontal = !horizontal; if (first_iteration) first_iteration = false; } glBindFramebuffer(GL_FRAMEBUFFER, 0); // 2. Now render floating point color buffer to 2D quad and tonemap HDR colors to default framebuffer's (clamped) color range glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shaderBloomFinal.Use(); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, colorBuffers[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[!horizontal]); glUniform1i(glGetUniformLocation(shaderBloomFinal.Program, "bloom"), bloom); glUniform1f(glGetUniformLocation(shaderBloomFinal.Program, "exposure"), exposure); RenderQuad(); // Swap the buffers glfwSwapBuffers(window); } glfwTerminate(); return 0; }
void ofFbo::unbind() { if(isBound) { glBindFramebuffer(GL_FRAMEBUFFER, savedFramebuffer); isBound = 0; } }
//------------------------------------------------------------------------------ void IGUIRender_opengl_es2::BindFramebuffer( uint32 framebuffer ) { glBindFramebuffer( GL_FRAMEBUFFER, framebuffer ); }
/** * @name tealeaf_canvas_bind_render_buffer * @brief bind's the render buffer and set's it's height / width to the given context's props * @param ctx - (context_2d *) pointer to the context to use the width / height from * @retval NONE */ void tealeaf_canvas_bind_render_buffer(context_2d *ctx) { GLTRACE(glBindFramebuffer(GL_FRAMEBUFFER, canvas.view_framebuffer)); canvas.framebuffer_width = ctx->width; canvas.framebuffer_height = ctx->height; canvas.framebuffer_offset_bottom = 0; }
void DefRenderer::Init() { nullProg = new ShaderProgram(SHADER_PATH + "nullVS.glsl", SHADER_PATH + "nullFS.glsl"); nullProg->BindAttribLoc(0, "Position"); nullProg->Link(); ivec2 screen = Graphics::GetViewport(); glGenFramebuffers(1, &fbo); GLuint FBOtexture[TEXTURES]; //color, normal glGenTextures(TEXTURES, FBOtexture); glGenRenderbuffers(1, &rbo); //depth & stencil CHECK_GL_ERROR(); glBindFramebuffer(GL_FRAMEBUFFER, fbo); //initialization of the textures and buffers for (int i = 0; i < TEXTURES; i++) { glBindTexture(GL_TEXTURE_2D, FBOtexture[i]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, screen.x, screen.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); textures[i] = new Texture(FBOtexture[i]); } glBindRenderbuffer(GL_RENDERBUFFER, rbo); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, screen.x, screen.y); CHECK_GL_ERROR(); //configuring frame buffer //setting texture attachments glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, FBOtexture[0], 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, FBOtexture[1], 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); CHECK_GL_ERROR(); //marking that frag shader will render to the 2 bound textures //depth is handled in a different pipeline stage - no need to bother about it GLenum bufferToDraw[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; glDrawBuffers(TEXTURES, bufferToDraw); CHECK_GL_ERROR(); //check if we succeeded if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) printf("Error - Framebuffer incomplete!\n"); //now create all the required resources for rendering the screen quad vector<Vertex> *verts = new vector<Vertex>(); verts->push_back(Vertex(vec3(-1.f, -1.f, 0))); verts->push_back(Vertex(vec3(1.f, -1.f, 0))); verts->push_back(Vertex(vec3(-1.f, 1.f, 0))); verts->push_back(Vertex(vec3(1.f, 1.f, 0))); model = new Model(); model->SetVertices(verts, GL_STATIC_DRAW, true); model->FlushBuffers(); model->SetUpAttrib(0, 2, GL_FLOAT, 0); //vec2 position program = new ShaderProgram(SHADER_PATH + "postProcVS.glsl", SHADER_PATH + "defRendFS.glsl"); program->BindAttribLoc(0, "vertexPosition"); program->Link(); renderer = new Renderer(); for (int i = 0; i < TEXTURES; i++) renderer->AddTexture(textures[i]); renderer->SetModel(model, GL_TRIANGLE_FAN); renderer->SetShaderProgram(program); }
void GlFrameBufferObject::bind() { glBindFramebuffer(GL_FRAMEBUFFER, _fboHandle); _bufferBound = true; }
void AppCore::mainLoop(void* context, const GLuint* const frameBuffer, const GLuint* const colorBuffer, const GLuint screenWidth, const GLuint screenHeight) { _context = context; // Start in interactive mode to restore a few nodes and show something on startup _isInteractiveMode = true; _lastCameraParameterChangeTimestamp = APIFactory::GetInstance().getTimeInMS(); // Init camera parameter ((MiniGL::SimpleCamera*)_camera)->setFrustum(screenWidth, screenHeight, CAMERA_FIELD_OF_VIEW_IN_DEGREE, CAMERA_NEAR_PLANE, CAMERA_FAR_PLANE); updateScreenSizeRelatedConstants(); if (frameBuffer && colorBuffer) { #if POST_PROCESSING // Create the color textures int fullTextureSize = 512; glGenTextures(2, _fbTexture); glBindTexture(GL_TEXTURE_2D, _fbTexture[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fullTextureSize, fullTextureSize, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_2D, _fbTexture[1]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fullTextureSize, fullTextureSize, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Generate depth buffer glGenRenderbuffers(1, &_depthBuffer); // Generate frame buffers glGenFramebuffers(2, _framebuffer); // Setup first framebuffer (with depth buffer) glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer[0]); glBindRenderbuffer(GL_RENDERBUFFER, _depthBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, fullTextureSize, fullTextureSize); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthBuffer); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _fbTexture[0], 0); // Setup second framebuffer (without depth buffer) glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer[1]); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _fbTexture[1], 0); #else glGenRenderbuffers(1, &_depthBuffer); glBindFramebuffer(GL_FRAMEBUFFER, *frameBuffer); glBindRenderbuffer(GL_RENDERBUFFER, _depthBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, screenWidth, screenHeight); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthBuffer); glViewport(0, 0, screenWidth, screenHeight); #endif glBindRenderbuffer(GL_RENDERBUFFER, *colorBuffer); } initOpenGL(); while(true) { #if POST_PROCESSING // Render scene to _fbTexture[0] (with depth buffer) glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer[0]); glViewport(0, 0, fullTextureSize, fullTextureSize); float m_fTexelOffset = 1.0f / (float)fullTextureSize; // Altered weights for the faster filter kernel float w1 = 0.0555555f; float w2 = 0.2777777f; float intraTexelOffset = (w2 / (w1 + w2)) * m_fTexelOffset; m_fTexelOffset += intraTexelOffset; if (render()) { // Render _fbTexture[0] to _fbTexture[1] // Apply horizontal * POSSIBILITY OF SUCH DAMAGE. glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer[1]); glViewport(0, 0, fullTextureSize, fullTextureSize); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, _fbTexture[0]); glUseProgram(_blurShaderProgram.handle); glUniform1f( * POSSIBILITY OF SUCH DAMAGE._SHADER_UNIFORM_TEXEL_OFFSET_X, m_fTexelOffset); glUniform1f( * POSSIBILITY OF SUCH DAMAGE._SHADER_UNIFORM_TEXEL_OFFSET_Y, 0.0f); renderFullscreenTexture(); // Render _fbTexture[1] to color buffer // Apply vertical * POSSIBILITY OF SUCH DAMAGE. glBindFramebuffer(GL_FRAMEBUFFER, *frameBuffer); glViewport(0, 0, screenWidth, screenHeight); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, _fbTexture[1]); glUseProgram(_blurShaderProgram.handle); glUniform1f(_blurShaderProgram.uniforms[ * POSSIBILITY OF SUCH DAMAGE._SHADER_UNIFORM_TEXEL_OFFSET_X], 0.0f); glUniform1f(_blurShaderProgram.uniforms[ * POSSIBILITY OF SUCH DAMAGE._SHADER_UNIFORM_TEXEL_OFFSET_Y], m_fTexelOffset); renderFullscreenTexture(); APIFactory::GetInstance().presentRenderBuffer(_context); } #else if (render()) APIFactory::GetInstance().presentRenderBuffer(_context); #endif // Restore nodes from backing store if in interactive mode if (_isInteractiveMode) _octree->restoreNodes(_nodeRestoreQuota); } }
void RenderGL(void) { #ifdef __APPLE__ if(directionSoundTravels > 0.0) { // audioRotation[3] += (GLfloat)(frequency_fMod_iOS[60]*200.0); } if(directionSoundTravels < 0.0) { // audioRotation[3] -= (GLfloat)(frequency_fMod_iOS[60]*200.0); } #endif #ifdef WIN32 if(directionSoundTravels > 0.0) { // audioRotation[3] += frequency[selectFrequency]*.1; } if(directionSoundTravels < 0.0) { // audioRotation[3] -= frequency[selectFrequency]*.1; } #endif //#################################################################################################### #ifdef __APPLE__ if(sound_API_selector == 0) { // #include "AUDIO/openAL_iOS/openAL_iOS_Render.cpp" } if(sound_API_selector == 1) { // #include "AUDIO/fMod_iOS/fMod_iOS_Render.cpp" } #endif //========================================================= #ifdef WIN32 if(sound_API_selector == 0) { // #include "AUDIO/openAL_WIN/openAL_WIN_Render.cpp" } if(sound_API_selector == 1) { // #include "AUDIO/fMod_WIN/fMod_WIN_Render.cpp" } #endif //################################################################# #ifdef __APPLE__ //*************************************************************** //eyeposition[0] -= PassTouchMovement[0]; //eyeposition[1] -= PassTouchMovement[1]; //eyeposition[2] -= PassTouchMovement[2]; //PassTouchMovement[0] = 0.0; //PassTouchMovement[1] = 0.0; //PassTouchMovement[2] = 0.0; //*************************************************************** #endif #ifdef WIN32 //*************************************************************** rotateModelWithLeftMouse[0] = PassMouseMovement[0]; rotateModelWithLeftMouse[1] = PassMouseMovement[1]; //*************************************************************** #endif //turnTable += 0.1; //==================================================================================================================================== ///////////////________FRAMEBUFFER_SHADOWS_BEGINS_HERE______________FRAMEBUFFER_SHADOWS_BEGINS_HERE___________________________________ ///////////////________FRAMEBUFFER_SHADOWS_BEGINS_HERE______________FRAMEBUFFER_SHADOWS_BEGINS_HERE___________________________________ //==================================================================================================================================== #include "runDepth_FBO.cpp" //==================================================================================================================================== ///////////////________FRAMEBUFFER_SHADOWS_BEGINS_HERE______________FRAMEBUFFER_SHADOWS_BEGINS_HERE___________________________________ ///////////////________FRAMEBUFFER_SHADOWS_BEGINS_HERE______________FRAMEBUFFER_SHADOWS_BEGINS_HERE___________________________________ //==================================================================================================================================== //============= //==================================================================================================================================== //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //==================================================================================================================================== //glActiveTexture (GL_TEXTURE0); //glBindTexture(GL_TEXTURE_2D, shadowMap_TEXTURE); //#include "flatten_3D_RENDER.cpp" //==================================================================================================================================== //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //==================================================================================================================================== //============= //==================================================================================================================================== //************************************************************************************************************************************ //************************************************************************************************************************************ //==================================================================================================================================== //#include "_MODEL_FOLDERS_/lightSpheres/lightSpheres_Render.cpp" //***************************************************************** //#include "_MODEL_FOLDERS_/lightSpheres/blurLightSpheres_Render.cpp" //==================================================================================================================================== //************************************************************************************************************************************ //************************************************************************************************************************************ //==================================================================================================================================== //============= //==================================================================================================================================== //#################################################################################################################################### //#################################################################################################################################### //==================================================================================================================================== #ifdef __APPLE__ glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebuffer); #endif //===================================================================== #include "drawMainColor_FBO.cpp" //------------------------------------------ //glBindFramebuffer(GL_FRAMEBUFFER, 0); //------------------------------------------ //==================================================================================================================================== //#################################################################################################################################### //#################################################################################################################################### //==================================================================================================================================== //============= //==================================================================================================================================== //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //==================================================================================================================================== /* glActiveTexture (GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, m_uiShadowMapTexture); glActiveTexture (GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_uiShadowMapTexture);//facing_UP_TEXTUREMAP #include "_MODEL_FOLDERS_/frameBufferPlane/frameBufferPlane_Render.cpp" */ //==================================================================================================================================== //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //==================================================================================================================================== }//_END_RenderGL()