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 *****
|
||||
|
||||
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)
|
||||
|
||||
@@ -9,7 +9,7 @@ extern "C" {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -41,11 +41,10 @@ extern "C" {
|
||||
if( controller == NULL )
|
||||
controller = new Controller;
|
||||
|
||||
if( view == NULL )
|
||||
if( view == NULL ) {
|
||||
view = new AppGLWidget;
|
||||
|
||||
controller->setView(view);
|
||||
controller->Clear();
|
||||
}
|
||||
|
||||
if( strlen(style_module) == 0 ){
|
||||
string path( pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py" );
|
||||
@@ -83,22 +82,17 @@ extern "C" {
|
||||
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) {
|
||||
|
||||
view->workingBuffer = GL_BACK;
|
||||
// load mesh
|
||||
controller->LoadMesh(re);
|
||||
|
||||
// add style module
|
||||
cout << "Module: " << style_module << endl;
|
||||
@@ -110,66 +104,15 @@ extern "C" {
|
||||
|
||||
// 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;
|
||||
// }
|
||||
|
||||
RenderLayer *rl;
|
||||
|
||||
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);
|
||||
cout << "Rendering Freestyle with OpenGL" << endl;
|
||||
|
||||
// render strokes
|
||||
FRS_render(re, render_in_layer);
|
||||
view->workingBuffer = GL_BACK;
|
||||
view->draw();
|
||||
|
||||
// display result
|
||||
RenderResult rres;
|
||||
@@ -177,8 +120,6 @@ extern "C" {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ SET(INC
|
||||
../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)
|
||||
|
||||
@@ -30,6 +30,7 @@ SET(INC
|
||||
intern/include ../../../intern/guardedalloc ../blenlib ../makesdna
|
||||
extern/include ../blenkernel ../radiosity/extern/include ../imbuf
|
||||
../quicktime ../include ../../kernel/gen_messaging ../yafray ../blenloader
|
||||
../freestyle
|
||||
)
|
||||
|
||||
IF(WITH_OPENEXR)
|
||||
|
||||
@@ -1630,14 +1630,13 @@ static void do_render_3d(Render *re)
|
||||
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 do_render_composite_fields_blur_3d(Render *re)
|
||||
|
||||
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);
|
||||
@@ -2216,12 +2213,15 @@ static void freestyleRender(Render *re)
|
||||
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);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ SET(INC
|
||||
../../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}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user