| 
					
				 | 
			
			
				@@ -22,7 +22,7 @@ GLuint Engine::postProgram = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 GLuint Engine::frameBuffer = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 GLuint Engine::frameTexture = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-GLuint Engine::renderBuffer = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+GLuint Engine::depthTexture = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int Engine::scale = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int Engine::width = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 int Engine::height = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -152,6 +152,7 @@ void Engine::start(IClient* client) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // draw scene in framebuffer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        glActiveTexture(GL_TEXTURE0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glUseProgram(program); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -159,14 +160,20 @@ void Engine::start(IClient* client) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Engine::client->renderTick((float) lag / NANOS_PER_TICK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // draw textured framebuffer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        glActiveTexture(GL_TEXTURE1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        glBindTexture(GL_TEXTURE_2D, frameTexture); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        glActiveTexture(GL_TEXTURE2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        glBindTexture(GL_TEXTURE_2D, depthTexture); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glUseProgram(postProgram); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glBindFramebuffer(GL_FRAMEBUFFER, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        glClear(GL_COLOR_BUFFER_BIT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glDisable(GL_DEPTH_TEST); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        glBindTexture(GL_TEXTURE_2D, frameTexture); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glBindVertexArray(postVba); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glBindBuffer(GL_ARRAY_BUFFER, postVbo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glDrawArrays(GL_TRIANGLES, 0, 6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glfwSwapBuffers(window); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         glfwPollEvents(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -361,6 +368,15 @@ void Engine::onWindowResize(GLFWwindow* w, int width, int height) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Engine::width = width; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Engine::height = height; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     updateScale(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindTexture(GL_TEXTURE_2D, frameTexture); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindTexture(GL_TEXTURE_2D, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindRenderbuffer(GL_RENDERBUFFER, depthTexture);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindRenderbuffer(GL_RENDERBUFFER, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindFramebuffer(GL_FRAMEBUFFER, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void Engine::updateScale() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -413,7 +429,7 @@ void Engine::printError() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     switch(error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         case GL_NO_ERROR:  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //cout << "> No error has been recorded." << endl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            cout << "> No error has been recorded." << endl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         case GL_INVALID_ENUM:  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cout << "> An unacceptable value is specified for an enumerated argument." << endl; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -454,23 +470,22 @@ void Engine::generateFramebuffer() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     glBindTexture(GL_TEXTURE_2D, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, frameTexture, 0);   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, frameTexture, 0);    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    glGenRenderbuffers(1, &renderBuffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    glBindRenderbuffer(GL_RENDERBUFFER, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glGenTextures(1, &depthTexture); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindTexture(GL_TEXTURE_2D, depthTexture); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBuffer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glBindTexture(GL_TEXTURE_2D, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cout << "ERROR::FRAMEBUFFER:: Framebuffer is not complete!" << endl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        cout << "WORKS" << endl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     glBindFramebuffer(GL_FRAMEBUFFER, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |