Revision: 17519
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17519
Author:   kjym3
Date:     2008-11-20 21:42:38 +0100 (Thu, 20 Nov 2008)

Log Message:
-----------
Added changes for implementing antialiasing.  The OSA settings for the internal
renderer are respected by the Freestyle renderer as well.

Modified Paths:
--------------
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp
    
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp
     2008-11-20 20:41:53 UTC (rev 17518)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp
     2008-11-20 20:42:38 UTC (rev 17519)
@@ -39,8 +39,13 @@
 
 extern "C" {
 #include "BLI_blenlib.h"
+#include "BLI_jitter.h"
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
+#if 1 // FRS_antialiasing
+#include "BKE_global.h"
+#include "DNA_scene_types.h"
+#endif
 }
 
 // glut.h must be included last to avoid a conflict with stdlib.h on vc .net 
2003 and 2005
@@ -439,6 +444,23 @@
   glPopAttrib();
 }
 
+#if 1 // FRS_antialiasing
+
+void AppGLWidget::init_jit(int osa)
+{
+  static float cache[32][2]; /* simple caching */
+  static int lastjit= 0;
+       
+  if(lastjit != osa) {
+       memset(cache, 0, sizeof(cache));
+       BLI_initjit(cache[0], osa);
+  }
+  lastjit= osa;
+  memcpy(jit, cache, sizeof(jit));
+}
+
+#endif
+
 void AppGLWidget::Draw2DScene(SceneVisitor *iRenderer)
 {
   static bool first = 1;
@@ -473,7 +495,29 @@
       canvas->init();
       first = false;
     }
-    canvas->Render(canvas->renderer());
+#if 1 // FRS_antialiasing
+       if (!(G.scene->r.mode & R_OSA)) {
+#endif
+         canvas->Render(canvas->renderer());
+#if 1 // FRS_antialiasing
+       } else {
+         init_jit(G.scene->r.osa);
+         GLint viewport[4];
+         glGetIntegerv(GL_VIEWPORT, viewport);
+         glClear(GL_ACCUM_BUFFER_BIT);
+         for (int jitter = 0; jitter < G.scene->r.osa; jitter++) {
+               cout << "Antialiasing " << jitter+1 << "/" << G.scene->r.osa << 
endl;
+               glClear(GL_COLOR_BUFFER_BIT);
+               glPushMatrix();
+               
glTranslatef(jit[jitter][0]*(viewport[2]+viewport[3])/viewport[2],
+                            
jit[jitter][1]*(viewport[2]+viewport[3])/viewport[3], 0.0);
+               canvas->Render(canvas->renderer());
+               glPopMatrix();
+               glAccum(GL_ACCUM, 1.0/G.scene->r.osa);
+         }
+         glAccum(GL_RETURN, 1.0);
+       }
+#endif
   }
   
   glLoadIdentity();

Modified: 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
===================================================================
--- 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
       2008-11-20 20:41:53 UTC (rev 17518)
+++ 
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/AppGLWidget.h
       2008-11-20 20:42:38 UTC (rev 17519)
@@ -542,7 +542,11 @@
 
   bool _record;
 
+#if 1 // FRS_antialiasing
+  float jit[32][2];
 
+  void init_jit(int osa);
+#endif
 
 };
 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to