Solution

Files changed (1) hide show
  1. lab5-rendertotexture/lab5_main.cpp +18 -3
lab5-rendertotexture/lab5_main.cpp CHANGED
@@ -124,8 +124,8 @@ struct FboInfo
124
124
  glBindTexture(GL_TEXTURE_2D, colorTextureTarget);
125
125
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
126
126
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
127
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
128
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
127
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
128
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
129
129
 
130
130
  glGenTextures(1, &depthBuffer);
131
131
  glBindTexture(GL_TEXTURE_2D, depthBuffer);
@@ -371,7 +371,8 @@ void display()
371
371
  ///////////////////////////////////////////////////////////////////////////
372
372
  // draw scene from camera
373
373
  ///////////////////////////////////////////////////////////////////////////
374
- glBindFramebuffer(GL_FRAMEBUFFER, 0); // to be replaced with another framebuffer when doing post processing
374
+ FboInfo& cameraFB = fboList[1];
375
+ glBindFramebuffer(GL_FRAMEBUFFER, cameraFB.framebufferId);
375
376
  glViewport(0, 0, w, h);
376
377
  glClearColor(0.2f, 0.2f, 0.8f, 1.0f);
377
378
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -391,6 +392,20 @@ void display()
391
392
  // 4. Draw a quad over the entire viewport
392
393
 
393
394
  // Task 4: Set the required uniforms
395
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
396
+ glViewport(0, 0, w, h);
397
+ glClearColor(0.2f, 0.2f, 0.8f, 1.0f);
398
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
399
+
400
+ glUseProgram(postFxShader);
401
+
402
+
403
+
404
+ glActiveTexture(GL_TEXTURE0);
405
+ glBindTexture(GL_TEXTURE_2D, cameraFB.colorTextureTarget);
406
+
407
+
408
+ labhelper::drawFullScreenQuad();
394
409
 
395
410
  glUseProgram(0);
396
411