[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16865] branches/soc-2008-mxcurioni/source /blender: soc-2008-mxcurioni: refactored Freestyle API to prepare for both rendering modes ( OpenGL and Blender internal), applied a patch to allow CMake to be used for compilation.
Maxime Curioni
maxime.curioni at gmail.com
Wed Oct 1 17:04:04 CEST 2008
Revision: 16865
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16865
Author: mxcurioni
Date: 2008-10-01 17:03:35 +0200 (Wed, 01 Oct 2008)
Log Message:
-----------
soc-2008-mxcurioni: refactored Freestyle API to prepare for both rendering modes (OpenGL and Blender internal), applied a patch to allow CMake to be used for compilation.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/CMakeLists.txt
branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp
branches/soc-2008-mxcurioni/source/blender/python/CMakeLists.txt
branches/soc-2008-mxcurioni/source/blender/render/CMakeLists.txt
branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c
branches/soc-2008-mxcurioni/source/blender/src/CMakeLists.txt
Modified: branches/soc-2008-mxcurioni/source/blender/CMakeLists.txt
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/CMakeLists.txt 2008-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/CMakeLists.txt 2008-10-01 15:03:35 UTC (rev 16865)
@@ -24,7 +24,7 @@
#
# ***** END GPL LICENSE BLOCK *****
-SUBDIRS(avi nodes blenkernel blenlib blenloader blenpluginapi imbuf imbuf/intern/cineon gpu makesdna python radiosity readblenfile render src yafray)
+SUBDIRS(avi nodes blenkernel blenlib blenloader blenpluginapi imbuf imbuf/intern/cineon gpu makesdna python radiosity readblenfile render src yafray freestyle)
IF(WITH_INTERNATIONAL)
SUBDIRS(ftfont)
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h 2008-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h 2008-10-01 15:03:35 UTC (rev 16865)
@@ -9,7 +9,7 @@
void FRS_initialize();
void FRS_prepare(Render* re);
- void FRS_execute(Render* re, int render_in_layer);
+ void FRS_render_GL(Render* re);
#ifdef __cplusplus
}
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-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/api.cpp 2008-10-01 15:03:35 UTC (rev 16865)
@@ -41,12 +41,11 @@
if( controller == NULL )
controller = new Controller;
- if( view == NULL )
+ if( view == NULL ) {
view = new AppGLWidget;
+ controller->setView(view);
+ }
- controller->setView(view);
- controller->Clear();
-
if( strlen(style_module) == 0 ){
string path( pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py" );
strcpy( style_module, path.c_str() );
@@ -82,24 +81,19 @@
view->_camera->setUpVector(camUp);
view->_camera->setViewDirection(camDirection);
}
-
- void FRS_load_mesh( Render *re ){
- controller->LoadMesh(re);
- }
+
void FRS_prepare(Render* re) {
- FRS_initialize();
+ // init
+ FRS_initialize();
FRS_init_view(re);
FRS_init_camera(re);
+ controller->Clear();
- FRS_load_mesh(re);
- }
-
- void FRS_render(Render* re, int render_in_layer) {
+ // load mesh
+ controller->LoadMesh(re);
- view->workingBuffer = GL_BACK;
-
// add style module
cout << "Module: " << style_module << endl;
controller->InsertStyleModule( 0, style_module );
@@ -110,76 +104,23 @@
// build strokes
controller->DrawStrokes();
-
- // render final result
- view->draw();
}
- void FRS_execute(Render* re, int render_in_layer) {
+ void FRS_render_GL(Render* re) {
- if(render_in_layer) {
-
- // GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- // switch(status){
- // case GL_FRAMEBUFFER_COMPLETE_EXT:
- // cout << "CORRECT: GL_FRAMEBUFFER_COMPLETE" << endl;
- // break;
- // case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT" << endl;
- // break;
- // case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT" << endl;
- // break;
- // case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT" << endl;
- // break;
- // case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT" << endl;
- // break;
- // case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" << endl;
- // break;
- // case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" << endl;
- // break;
- // case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
- // cout << "ERROR: GL_FRAMEBUFFER_UNSUPPORTED" << endl;
- // break;
- // }
+ cout << "Rendering Freestyle with OpenGL" << endl;
- RenderLayer *rl;
+ // render strokes
+ view->workingBuffer = GL_BACK;
+ view->draw();
- for(rl = (RenderLayer *)re->result->layers.first; rl; rl= rl->next)
- if(rl->layflag & SCE_LAY_FRS)
- break;
-
- int p;
- for(int j = 0; j < re->winy; j++) {
- for(int i = 0; i < re->winx; i++){
- p = 4*(j*re->winx + i);
- rl->rectf[p] *= 0.6;
- rl->rectf[p + 1] = 0.6 * rl->rectf[p + 1];
- rl->rectf[p + 2] *= 0.6;
- rl->rectf[p + 3] = 1.0;
- }
- }
-
- } else {
- // used to reobtain ogl context after RE_Database_FromScene call
- re->display_clear(re->result);
-
- // render strokes
- FRS_render(re, render_in_layer);
-
- // display result
- RenderResult rres;
- RE_GetResultImage(re, &rres);
- view->readPixels(0, 0, re->winx, re->winy, AppGLWidget::RGBA, rres.rectf );
- re->result->renlay = render_get_active_layer(re, re->result);
- re->display_draw(re->result, NULL);
- }
-
-
+ // display result
+ RenderResult rres;
+ RE_GetResultImage(re, &rres);
+ view->readPixels(0, 0, re->winx, re->winy, AppGLWidget::RGBA, rres.rectf );
+ re->result->renlay = render_get_active_layer(re, re->result);
+ re->display_draw(re->result, NULL);
+
controller->CloseFile();
}
Modified: branches/soc-2008-mxcurioni/source/blender/python/CMakeLists.txt
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/python/CMakeLists.txt 2008-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/python/CMakeLists.txt 2008-10-01 15:03:35 UTC (rev 16865)
@@ -35,6 +35,7 @@
../render/extern/include ../radiosity/extern/include
../makesdna ../../../intern/guardedalloc ../../../intern/bmfont ../imbuf ../include
${PYTHON_INC} ../../../extern/glew/include ../gpu
+ ../freestyle ../freestyle/intern/python
)
IF(WITH_QUICKTIME)
Modified: branches/soc-2008-mxcurioni/source/blender/render/CMakeLists.txt
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/render/CMakeLists.txt 2008-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/render/CMakeLists.txt 2008-10-01 15:03:35 UTC (rev 16865)
@@ -30,6 +30,7 @@
intern/include ../../../intern/guardedalloc ../blenlib ../makesdna
extern/include ../blenkernel ../radiosity/extern/include ../imbuf
../quicktime ../include ../../kernel/gen_messaging ../yafray ../blenloader
+ ../freestyle
)
IF(WITH_OPENEXR)
Modified: branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c 2008-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c 2008-10-01 15:03:35 UTC (rev 16865)
@@ -1630,14 +1630,13 @@
else
RE_Database_FromScene(re, re->scene, 1);
- threaded_tile_processor(re);
-
/* Freestyle */
if( re->r.mode & R_EDGE_FRS ) {
FRS_prepare(re);
- FRS_execute(re,1);
}
+ threaded_tile_processor(re);
+
/* do left-over 3d post effects (flares) */
if(re->flag & R_HALO)
if(!re->test_break())
@@ -2201,8 +2200,6 @@
static void freestyleRender(Render *re)
{
- float mat[4][4];
-
// init render result
RE_FreeRenderResult(re->result);
re->result = new_render_result(re, &re->disprect, 0, RR_USEMEM);
@@ -2215,13 +2212,16 @@
RE_Database_FromScene_Vectors(re, re->scene);
else
RE_Database_FromScene(re, re->scene, 1);
-
+
+ // used to reobtain ogl context after RE_Database_FromScene call
+ re->display_clear(re->result);
+
// Freestyle initialization
FRS_prepare(re);
// run Freestyle
re->i.starttime = PIL_check_seconds_timer();
- FRS_execute(re, 0);
+ FRS_render_GL(re);
re->i.lastframetime = PIL_check_seconds_timer()- re->i.starttime;
re->stats_draw(&re->i);
Modified: branches/soc-2008-mxcurioni/source/blender/src/CMakeLists.txt
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/src/CMakeLists.txt 2008-10-01 08:23:08 UTC (rev 16864)
+++ branches/soc-2008-mxcurioni/source/blender/src/CMakeLists.txt 2008-10-01 15:03:35 UTC (rev 16865)
@@ -35,7 +35,7 @@
../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue
../quicktime ../../../intern/elbeem/extern
../../../intern/ghost ../../../intern/opennl/extern
- ../nodes ../../../extern/glew/include ../gpu
+ ../nodes ../../../extern/glew/include ../gpu ../freestyle
${PYTHON_INC}
${SDL_INC}
)
More information about the Bf-blender-cvs
mailing list