Solution

Files changed (1) hide show
  1. lab5-rendertotexture/lab5_main.cpp +12 -0
lab5-rendertotexture/lab5_main.cpp CHANGED
@@ -140,6 +140,15 @@ struct FboInfo
140
140
  ///////////////////////////////////////////////////////////////////////
141
141
  // Task 1
142
142
  //...
143
+ glGenFramebuffers(1, &framebufferId);
144
+ glBindFramebuffer(GL_FRAMEBUFFER, framebufferId);
145
+
146
+ // bind the texture as color attachment 0 (to the currently bound framebuffer)
147
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTextureTarget, 0);
148
+ glDrawBuffer(GL_COLOR_ATTACHMENT0);
149
+
150
+ // bind the texture as depth attachment (to the currently bound framebuffer)
151
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthBuffer, 0);
143
152
 
144
153
  // check if framebuffer is complete
145
154
  isComplete = checkFramebufferComplete();
@@ -239,6 +248,9 @@ void initialize()
239
248
  ///////////////////////////////////////////////////////////////////////////
240
249
  int w, h;
241
250
  SDL_GetWindowSize(g_window, &w, &h);
251
+ const int numFbos = 5;
252
+ for(int i = 0; i < numFbos; i++)
253
+ fboList.push_back(FboInfo(w, h));
242
254
  }
243
255
 
244
256