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.
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** 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)
|
IF(WITH_INTERNATIONAL)
|
||||||
SUBDIRS(ftfont)
|
SUBDIRS(ftfont)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ extern "C" {
|
|||||||
|
|
||||||
void FRS_initialize();
|
void FRS_initialize();
|
||||||
void FRS_prepare(Render* re);
|
void FRS_prepare(Render* re);
|
||||||
void FRS_execute(Render* re, int render_in_layer);
|
void FRS_render_GL(Render* re);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,10 @@ extern "C" {
|
|||||||
if( controller == NULL )
|
if( controller == NULL )
|
||||||
controller = new Controller;
|
controller = new Controller;
|
||||||
|
|
||||||
if( view == NULL )
|
if( view == NULL ) {
|
||||||
view = new AppGLWidget;
|
view = new AppGLWidget;
|
||||||
|
controller->setView(view);
|
||||||
controller->setView(view);
|
}
|
||||||
controller->Clear();
|
|
||||||
|
|
||||||
if( strlen(style_module) == 0 ){
|
if( strlen(style_module) == 0 ){
|
||||||
string path( pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py" );
|
string path( pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py" );
|
||||||
@@ -82,23 +81,18 @@ extern "C" {
|
|||||||
view->_camera->setUpVector(camUp);
|
view->_camera->setUpVector(camUp);
|
||||||
view->_camera->setViewDirection(camDirection);
|
view->_camera->setViewDirection(camDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FRS_load_mesh( Render *re ){
|
|
||||||
controller->LoadMesh(re);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FRS_prepare(Render* re) {
|
void FRS_prepare(Render* re) {
|
||||||
FRS_initialize();
|
|
||||||
|
|
||||||
|
// init
|
||||||
|
FRS_initialize();
|
||||||
FRS_init_view(re);
|
FRS_init_view(re);
|
||||||
FRS_init_camera(re);
|
FRS_init_camera(re);
|
||||||
|
controller->Clear();
|
||||||
|
|
||||||
FRS_load_mesh(re);
|
// load mesh
|
||||||
}
|
controller->LoadMesh(re);
|
||||||
|
|
||||||
void FRS_render(Render* re, int render_in_layer) {
|
|
||||||
|
|
||||||
view->workingBuffer = GL_BACK;
|
|
||||||
|
|
||||||
// add style module
|
// add style module
|
||||||
cout << "Module: " << style_module << endl;
|
cout << "Module: " << style_module << endl;
|
||||||
@@ -110,76 +104,23 @@ extern "C" {
|
|||||||
|
|
||||||
// build strokes
|
// build strokes
|
||||||
controller->DrawStrokes();
|
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) {
|
cout << "Rendering Freestyle with OpenGL" << endl;
|
||||||
|
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
RenderLayer *rl;
|
// render strokes
|
||||||
|
view->workingBuffer = GL_BACK;
|
||||||
for(rl = (RenderLayer *)re->result->layers.first; rl; rl= rl->next)
|
view->draw();
|
||||||
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();
|
controller->CloseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ SET(INC
|
|||||||
../render/extern/include ../radiosity/extern/include
|
../render/extern/include ../radiosity/extern/include
|
||||||
../makesdna ../../../intern/guardedalloc ../../../intern/bmfont ../imbuf ../include
|
../makesdna ../../../intern/guardedalloc ../../../intern/bmfont ../imbuf ../include
|
||||||
${PYTHON_INC} ../../../extern/glew/include ../gpu
|
${PYTHON_INC} ../../../extern/glew/include ../gpu
|
||||||
|
../freestyle ../freestyle/intern/python
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(WITH_QUICKTIME)
|
IF(WITH_QUICKTIME)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ SET(INC
|
|||||||
intern/include ../../../intern/guardedalloc ../blenlib ../makesdna
|
intern/include ../../../intern/guardedalloc ../blenlib ../makesdna
|
||||||
extern/include ../blenkernel ../radiosity/extern/include ../imbuf
|
extern/include ../blenkernel ../radiosity/extern/include ../imbuf
|
||||||
../quicktime ../include ../../kernel/gen_messaging ../yafray ../blenloader
|
../quicktime ../include ../../kernel/gen_messaging ../yafray ../blenloader
|
||||||
|
../freestyle
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(WITH_OPENEXR)
|
IF(WITH_OPENEXR)
|
||||||
|
|||||||
@@ -1630,14 +1630,13 @@ static void do_render_3d(Render *re)
|
|||||||
else
|
else
|
||||||
RE_Database_FromScene(re, re->scene, 1);
|
RE_Database_FromScene(re, re->scene, 1);
|
||||||
|
|
||||||
threaded_tile_processor(re);
|
|
||||||
|
|
||||||
/* Freestyle */
|
/* Freestyle */
|
||||||
if( re->r.mode & R_EDGE_FRS ) {
|
if( re->r.mode & R_EDGE_FRS ) {
|
||||||
FRS_prepare(re);
|
FRS_prepare(re);
|
||||||
FRS_execute(re,1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
threaded_tile_processor(re);
|
||||||
|
|
||||||
/* do left-over 3d post effects (flares) */
|
/* do left-over 3d post effects (flares) */
|
||||||
if(re->flag & R_HALO)
|
if(re->flag & R_HALO)
|
||||||
if(!re->test_break())
|
if(!re->test_break())
|
||||||
@@ -2201,8 +2200,6 @@ static void do_render_composite_fields_blur_3d(Render *re)
|
|||||||
|
|
||||||
static void freestyleRender(Render *re)
|
static void freestyleRender(Render *re)
|
||||||
{
|
{
|
||||||
float mat[4][4];
|
|
||||||
|
|
||||||
// init render result
|
// init render result
|
||||||
RE_FreeRenderResult(re->result);
|
RE_FreeRenderResult(re->result);
|
||||||
re->result = new_render_result(re, &re->disprect, 0, RR_USEMEM);
|
re->result = new_render_result(re, &re->disprect, 0, RR_USEMEM);
|
||||||
@@ -2215,13 +2212,16 @@ static void freestyleRender(Render *re)
|
|||||||
RE_Database_FromScene_Vectors(re, re->scene);
|
RE_Database_FromScene_Vectors(re, re->scene);
|
||||||
else
|
else
|
||||||
RE_Database_FromScene(re, re->scene, 1);
|
RE_Database_FromScene(re, re->scene, 1);
|
||||||
|
|
||||||
|
// used to reobtain ogl context after RE_Database_FromScene call
|
||||||
|
re->display_clear(re->result);
|
||||||
|
|
||||||
// Freestyle initialization
|
// Freestyle initialization
|
||||||
FRS_prepare(re);
|
FRS_prepare(re);
|
||||||
|
|
||||||
// run Freestyle
|
// run Freestyle
|
||||||
re->i.starttime = PIL_check_seconds_timer();
|
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->i.lastframetime = PIL_check_seconds_timer()- re->i.starttime;
|
||||||
re->stats_draw(&re->i);
|
re->stats_draw(&re->i);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ SET(INC
|
|||||||
../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue
|
../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue
|
||||||
../quicktime ../../../intern/elbeem/extern
|
../quicktime ../../../intern/elbeem/extern
|
||||||
../../../intern/ghost ../../../intern/opennl/extern
|
../../../intern/ghost ../../../intern/opennl/extern
|
||||||
../nodes ../../../extern/glew/include ../gpu
|
../nodes ../../../extern/glew/include ../gpu ../freestyle
|
||||||
${PYTHON_INC}
|
${PYTHON_INC}
|
||||||
${SDL_INC}
|
${SDL_INC}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user