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.

This commit is contained in:
Maxime Curioni
2008-05-28 21:19:56 +00:00
parent 58066fd0af
commit 9986b5cd73
6 changed files with 37 additions and 36 deletions

View File

@@ -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,

View File

@@ -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);

View File

@@ -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) {}

View File

@@ -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();
}

View File

@@ -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 );

View File

@@ -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;
}