diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-29 01:19:56 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-29 01:19:56 +0400 |
commit | 9986b5cd736a493026c9580a49bbf030cd1fa4be (patch) | |
tree | 6e6e3d36059cd890805fce1f7afbb743f3dfc5e0 /source/blender | |
parent | 58066fd0af30388a6bf29fa897fb0300b37c5c7b (diff) |
soc-2008-mxcurioni: corrected GLStrokeRender::preparePaper function for paper texture loading. The canvas view now has its frame properly initialized to fixed dimensions. When the Freestyle render is executed, the render is displayed for a fraction of a second and is then erased by a standard gray background. I have to analyze what command I need to call to keep the result on display.
Diffstat (limited to 'source/blender')
6 files changed, 37 insertions, 36 deletions
diff --git a/source/blender/freestyle/SConscript b/source/blender/freestyle/SConscript index 198eb2ed422..58d4e980e8b 100644 --- a/source/blender/freestyle/SConscript +++ b/source/blender/freestyle/SConscript @@ -55,14 +55,10 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw'): prefix = 'intern/app_blender' app_sources = env.Glob(prefix + '/*.cpp') -# swig wrapper -#prefix = 'intern/swig' -#swig_sources = env.Glob(prefix + '/*.cpp') -swig_sources = [] sources = system_sources + image_sources + geometry_sources + scene_graph_sources \ + winged_edge_sources + view_map_sources + stroke_sources + rendering_sources \ - + app_sources + swig_sources + + app_sources env.BlenderLib (libname="bf_freestyle", sources=sources, diff --git a/source/blender/freestyle/intern/app_blender/AppCanvas.cpp b/source/blender/freestyle/intern/app_blender/AppCanvas.cpp index 5125bf5f70b..98013cf18d4 100755 --- a/source/blender/freestyle/intern/app_blender/AppCanvas.cpp +++ b/source/blender/freestyle/intern/app_blender/AppCanvas.cpp @@ -214,7 +214,7 @@ void AppCanvas::update() // char number[10]; // _pViewer->updateGL(); - _pViewer->swapBuffers(); + //_pViewer->swapBuffers(); //QImage fb = _pViewer->grabFrameBuffer(); // sprintf(number, "%3d", counter); // strcat(fileName, number); diff --git a/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp b/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp index 18e9639342d..a06e25d72be 100755 --- a/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp +++ b/source/blender/freestyle/intern/app_blender/AppGLWidget.cpp @@ -618,22 +618,13 @@ bool AppGLWidget::getBackBufferFlag() { // COPIED FROM LIBQGLVIEWER //******************************* - // inherited - void AppGLWidget::swapBuffers() {} - + // inherited //Updates the display. Do not call draw() directly, use this method instead. void AppGLWidget::updateGL() {} //Makes this widget's rendering context the current OpenGL rendering context. Useful with several viewers - void AppGLWidget::makeCurrent() {} - + void AppGLWidget::makeCurrent() { } // not-inherited - - // Convenient way to call setSceneCenter() and setSceneRadius() from a (world axis aligned) bounding box of the scene. - void AppGLWidget::setSceneBoundingBox(const Vec& min, const Vec& max) { _camera->setSceneBoundingBox(min,max); } - - void AppGLWidget::saveSnapshot(bool b) {} - void AppGLWidget::setStateFileName(const string& name) { stateFileName_ = name; }; - + void AppGLWidget::saveSnapshot(bool b) {} diff --git a/source/blender/freestyle/intern/app_blender/AppGLWidget.h b/source/blender/freestyle/intern/app_blender/AppGLWidget.h index 3cf7844876d..15238ba6269 100755 --- a/source/blender/freestyle/intern/app_blender/AppGLWidget.h +++ b/source/blender/freestyle/intern/app_blender/AppGLWidget.h @@ -47,6 +47,7 @@ using namespace std; # include "../rendering/GLDebugRenderer.h" //# include <QGLViewer/qglviewer.h> + //soc #include "AppGLWidget_camera.h" #include "AppGLWidget_vec.h" @@ -76,14 +77,15 @@ public: public: //inherited - inline real width() { return _width; } - inline real height() { return _height; } - void swapBuffers(); + inline unsigned int width() { return _width; } + inline unsigned int height() { return _height; } + inline void setWidth( unsigned int width ) { _width = width; } + inline void setHeight( unsigned int height ) { _height = height; } + void updateGL(); void makeCurrent(); // not-inherited - void setSceneBoundingBox(const Vec& min, const Vec& max); void saveSnapshot(bool b); void setStateFileName(const string& name); @@ -91,7 +93,7 @@ public: Camera * _camera; protected: - real _width, _height; + unsigned int _width, _height; Vec _min,_max; string stateFileName_; @@ -306,7 +308,7 @@ public: Vec max_(_ModelRootNode->bbox().getMax()[0], _ModelRootNode->bbox().getMax()[1], _ModelRootNode->bbox().getMax()[2]); - setSceneBoundingBox(min_, max_); + _camera->setSceneBoundingBox(min_, max_); _camera->showEntireScene(); } diff --git a/source/blender/freestyle/intern/app_blender/api.cpp b/source/blender/freestyle/intern/app_blender/api.cpp index 5f3d8224ec5..eb29580f891 100644 --- a/source/blender/freestyle/intern/app_blender/api.cpp +++ b/source/blender/freestyle/intern/app_blender/api.cpp @@ -20,7 +20,9 @@ extern "C" { AppGLWidget *view = new AppGLWidget; c->SetView(view); - + view->setWidth(640); + view->setHeight(640); + c->Load3DSFile( TEST_3DS_FILE ); c->InsertStyleModule( 0, TEST_STYLE_MODULE_FILE ); diff --git a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp index c29ba759139..94518cee58f 100755 --- a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp @@ -368,11 +368,13 @@ GLTextureManager::prepareTextureAlpha (string sname, GLuint itexname) BLI_splitdirstring(name, filename); //soc if (qim.isNull()) - if( qim ) + if (!qim) //soc { cerr << " Error: unable to read \"" << filename << "\"" << endl; + IMB_freeImBuf(qim); return false; } + if( qim->depth > 8) //soc { cerr<<" Error: \""<< filename <<"\" has "<< qim->depth <<" bits/pixel"<<endl; //soc @@ -416,9 +418,10 @@ GLTextureManager::prepareTextureLuminance (string sname, GLuint itexname) char filename[FILE_MAXFILE]; BLI_splitdirstring(name, filename); - if (!qim) //soc + if (!qim) //soc { cerr << " Error: unable to read \"" << filename << "\"" << endl; + IMB_freeImBuf(qim); return false; } if (qim->depth > 8) //soc @@ -463,11 +466,13 @@ GLTextureManager::prepareTextureLuminanceAndAlpha (string sname, GLuint itexname char filename[FILE_MAXFILE]; BLI_splitdirstring(name, filename); - if (!qim) //soc + if (!qim) //soc { cerr << " Error: unable to read \"" << filename << "\"" << endl; + IMB_freeImBuf(qim); return false; } + if (qim->depth > 8) //soc { cerr<<" Error: \""<<filename<<"\" has "<< qim->depth <<" bits/pixel"<<endl; //soc @@ -508,19 +513,24 @@ GLTextureManager::preparePaper (const char *name, GLuint itexname) ImBuf *qim = IMB_loadiffname(name, 0); char filename[FILE_MAXFILE]; BLI_splitdirstring((char *)name, filename); + qim->depth = 32; if (!qim) //soc { cerr << " Error: unable to read \"" << filename << "\"" << endl; + IMB_freeImBuf(qim); return false; } - if (qim->depth !=32) //soc - { - cerr<<" Error: \""<<filename<<"\" has "<<qim->depth<<" bits/pixel"<<endl; //soc - return false; - } - //soc QImage qim2=QGLWidget::convertToGLFormat( qim ); + //soc: no test because IMB_loadiffname creates 32 bit image directly + // + // if (qim->depth != 32) + // { + // cerr<<" Error: \""<<filename<<"\" has "<< qim->depth <<" bits/pixel"<<endl; //soc + // IMB_freeImBuf(qim); + // return false; + // } + // QImage qim2=QGLWidget::convertToGLFormat( qim ); glBindTexture(GL_TEXTURE_2D, itexname); @@ -532,10 +542,10 @@ GLTextureManager::preparePaper (const char *name, GLuint itexname) GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, qim->x, qim->y, 0, - GL_RGBA, GL_UNSIGNED_BYTE, qim->rect); //soc: here qim->rect, not qim2->rect, used + GL_RGBA, GL_UNSIGNED_BYTE, qim->rect); // soc: was qim2 //cout << " \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl; - cout << " \"" << StringUtils::toAscii(filename) << "\" loaded with "<< qim->depth << " bits per pixel" << endl; + cout << " \"" << StringUtils::toAscii(filename) << "\" loaded with 32 bits per pixel" << endl; return true; } |