Przeglądaj źródła

simplified rendering code

naelstrof 7 lat temu
rodzic
commit
ec39dfc079
1 zmienionych plików z 29 dodań i 36 usunięć
  1. 29
    36
      src/slop.cpp

+ 29
- 36
src/slop.cpp Wyświetl plik

@@ -186,10 +186,7 @@ slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, bool* cancel
186 186
     // Init our little state machine, memory is a tad of a misnomer
187 187
     slop::SlopMemory memory( options, new GLRectangle(glm::vec2(0,0), glm::vec2(0,0), options->borderSize, options->padding, glm::vec4( options->r, options->g, options->b, options->a ), options->highlight) );
188 188
 
189
-    slop::Framebuffer* pingpong;
190
-    if ( shaders.size() > 1 ) {
191
-        pingpong = new slop::Framebuffer(WidthOfScreen(x11->screen), HeightOfScreen(x11->screen));
192
-    }
189
+    slop::Framebuffer* pingpong = new slop::Framebuffer(WidthOfScreen(x11->screen), HeightOfScreen(x11->screen));
193 190
 
194 191
     // This is where we'll run through all of our stuffs
195 192
     auto start = std::chrono::high_resolution_clock::now();
@@ -214,40 +211,36 @@ slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, bool* cancel
214 211
         window->framebuffer->unbind();
215 212
 
216 213
         std::chrono::duration<double, std::milli> elapsed = current-start;
217
-        if ( shaders.size() > 1 ) {
218
-            int i;
219
-            // We have our clean buffer, now to slather it with some juicy shader chains.
220
-            for (i=0;i<=(int)shaders.size()-2;i+=2) {
221
-                pingpong->bind();
222
-                glClearColor (0.0, 0.0, 0.0, 0.0);
223
-                glClear (GL_COLOR_BUFFER_BIT);
224
-                window->framebuffer->setShader( shaders[i] );
225
-                window->framebuffer->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
226
-                pingpong->unbind();
214
+        
215
+        int i;
216
+        // We have our clean buffer, now to slather it with some juicy shader chains.
217
+        for (i=0;i<=(int)shaders.size()-2;i+=2) {
218
+            pingpong->bind();
219
+            glClearColor (0.0, 0.0, 0.0, 0.0);
220
+            glClear (GL_COLOR_BUFFER_BIT);
221
+            window->framebuffer->setShader( shaders[i] );
222
+            window->framebuffer->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
223
+            pingpong->unbind();
227 224
 
228
-                window->framebuffer->bind();
229
-                glClearColor (0.0, 0.0, 0.0, 0.0);
230
-                glClear (GL_COLOR_BUFFER_BIT);
231
-                pingpong->setShader( shaders[i+1] );
232
-                pingpong->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
233
-                window->framebuffer->unbind();
234
-            }
235
-            for (;i<shaders.size();i++) {
236
-                pingpong->bind();
237
-                glClearColor (0.0, 0.0, 0.0, 0.0);
238
-                glClear (GL_COLOR_BUFFER_BIT);
239
-                window->framebuffer->setShader( shaders[i] );
240
-                window->framebuffer->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
241
-                pingpong->unbind();
242
-            }
243
-            if ( i%2 != 0 ) {
244
-                window->framebuffer->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
245
-            } else {
246
-                pingpong->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
247
-            }
248
-        } else {
249
-            window->framebuffer->setShader( shaders[0] );
225
+            window->framebuffer->bind();
226
+            glClearColor (0.0, 0.0, 0.0, 0.0);
227
+            glClear (GL_COLOR_BUFFER_BIT);
228
+            pingpong->setShader( shaders[i+1] );
229
+            pingpong->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
230
+            window->framebuffer->unbind();
231
+        }
232
+        for (;i<shaders.size();i++) {
233
+            pingpong->bind();
234
+            glClearColor (0.0, 0.0, 0.0, 0.0);
235
+            glClear (GL_COLOR_BUFFER_BIT);
236
+            window->framebuffer->setShader( shaders[i] );
250 237
             window->framebuffer->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
238
+            pingpong->unbind();
239
+        }
240
+        if ( i%2 != 0 ) {
241
+            window->framebuffer->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
242
+        } else {
243
+            pingpong->draw(slop::mouse->getMousePos(), elapsed.count()/1000.f, glm::vec4( options->r, options->g, options->b, options->a ) );
251 244
         }
252 245
 
253 246
         window->display();