[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15037] branches/soc-2008-mxcurioni/source /blender: soc-2008-mxcurioni: First render ! It should render the teapot upside down on a black background .

Maxime Curioni maxime.curioni at gmail.com
Thu May 29 02:27:09 CEST 2008


Revision: 15037
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15037
Author:   mxcurioni
Date:     2008-05-29 02:27:09 +0200 (Thu, 29 May 2008)

Log Message:
-----------
soc-2008-mxcurioni: First render ! It should render the teapot upside down on a black background. The correction was made by following Yafray's rendering and display implementation, which is very clear.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/FST_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp
    branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FST_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FST_freestyle.h	2008-05-29 00:15:17 UTC (rev 15036)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FST_freestyle.h	2008-05-29 00:27:09 UTC (rev 15037)
@@ -5,7 +5,7 @@
 extern "C" {
 #endif	
 	
-	void FRS_execute();
+	void FRS_execute(Render* re);
 
 #ifdef __cplusplus
 }

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-05-29 00:15:17 UTC (rev 15036)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-05-29 00:27:09 UTC (rev 15037)
@@ -6,7 +6,8 @@
 defs = []
 incs = ''
 
-incs += '../blenkernel ../blenlib ../imbuf ../makesdna ../python'
+incs += '../blenkernel ../blenlib ../imbuf ../makesdna ../python '
+incs += '../render/extern/include ../render/intern/include'
 incs += ' #/extern/freestyle/lib3ds' 
 incs += ' ' + env['BF_PYTHON_INC']
 incs += ' ' + env['BF_LIB3DS_INC']

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp	2008-05-29 00:15:17 UTC (rev 15036)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp	2008-05-29 00:27:09 UTC (rev 15037)
@@ -6,13 +6,26 @@
 
 #include <iostream>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "render_types.h"
+//#include "renderdatabase.h"
+/* display_draw() needs render layer info */
+#include "renderpipeline.h"
+
+#ifdef __cplusplus
+}
+#endif
+
 using namespace std;
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-	void FRS_execute() {
+	void FRS_execute(Render* re) {
 		cout << "Freestyle start" << endl;
 	
 		Config::Path pathconfig;
@@ -20,17 +33,40 @@
 		AppGLWidget *view = new AppGLWidget;
 		
 		c->SetView(view);
-		view->setWidth(640);
-		view->setHeight(640);
+		unsigned int width = re->winx;
+		unsigned int height = re->winy;
+		view->setWidth(width);
+		view->setHeight(height);
 		
 		c->Load3DSFile( TEST_3DS_FILE );
 		
 		c->InsertStyleModule( 0, TEST_STYLE_MODULE_FILE );
 		c->toggleLayer(0, true);
 		c->ComputeViewMap();
-		 
+		
 		c->DrawStrokes();
+
+		RenderResult rres;
+		RE_GetResultImage(re, &rres);
+		float *rgb = new float[3*width*height];
+		view->readPixels(0,0,width,height,AppGLWidget::RGB, rgb);
 		
+		for (unsigned short y=0; y<height; y++) {
+			float* bpt = (float*)rres.rectf + ((y*width) << 2);			
+			for (unsigned short x=0; x<width; x++) {
+				float *pos = rgb + 3 * ( y*width + x );
+				
+				bpt[0] = pos[0]; // r
+				bpt[1] = pos[1]; // g
+				bpt[2] = pos[2]; // b
+				bpt[3] = 1.0; // a
+				bpt += 4;
+			}
+		}
+		
+		re->result->renlay = render_get_active_layer(re, re->result);
+		re->display_draw(re->result, NULL);
+		
 		cout << "Freestyle end" << endl;
 
 	}

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp	2008-05-29 00:15:17 UTC (rev 15036)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp	2008-05-29 00:27:09 UTC (rev 15037)
@@ -513,7 +513,6 @@
 	ImBuf *qim = IMB_loadiffname(name, 0);
 	char filename[FILE_MAXFILE];
 	BLI_splitdirstring((char *)name, filename);
-	qim->depth = 32;
 
   if (!qim) //soc 
     {

Modified: branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c	2008-05-29 00:15:17 UTC (rev 15036)
+++ branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c	2008-05-29 00:27:09 UTC (rev 15037)
@@ -2193,7 +2193,15 @@
 
 static void freestyleRender(Render *re)
 {
-	FRS_execute();
+	RE_FreeRenderResult(re->result);
+	re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM);
+	
+	RE_SetCamera(re, re->scene->camera);
+	
+	FRS_execute(re);
+	
+	re->stats_draw(&re->i);
+	RE_Database_Free(re);
 }
 
 #ifndef DISABLE_YAFRAY





More information about the Bf-blender-cvs mailing list