soc-2008-mxcurioni: corrected texture loading feedback, removed paper textures from the project

This commit is contained in:
Maxime Curioni
2008-09-25 16:35:53 +00:00
parent 7bb09a8a1c
commit 4be21b18f8
13 changed files with 17 additions and 212 deletions

View File

@@ -8,7 +8,7 @@ incs = ''
incs += '../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../python '
incs += '../render/extern/include ../render/intern/include ../include ../src'
incs += ' #/extern/glew/include'
incs += ' #/extern/glew/include #/intern/guardedalloc'
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_PNG_INC']

View File

@@ -265,27 +265,6 @@ void AppCanvas::Render(const StrokeRenderer *iRenderer)
glBlendFunc(GL_DST_COLOR, GL_ZERO);
if(_drawPaper)
{
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
float zfar = _pViewer->zfar();
zfar = zfar+0.1*zfar;
//draw background paper // FIXME
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, StrokeRenderer::_textureManager->getPaperTextureIndex(_paperTextureIndex));
glColor4f(1,1,1,0.0);
glBegin(GL_TRIANGLE_STRIP);
{
glTexCoord2f(0,0); glVertex3f(0, 0, -1);
glTexCoord2f(4,0); glVertex3f(2048, 0, -1);
glTexCoord2f(0,4); glVertex3f(0, 2048, -1);
glTexCoord2f(4,4); glVertex3f(2048, 2048, -1);
}
glEnd();
}
glPushAttrib(GL_COLOR_BUFFER_BIT);
glBlendEquation(GL_FUNC_SUBTRACT);
glBlendFunc(GL_ONE, GL_ONE);
@@ -362,26 +341,6 @@ void AppCanvas::RenderBasic(const StrokeRenderer *iRenderer)
}
glBlendFunc(GL_DST_COLOR, GL_ZERO);
if(_drawPaper)
{
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
float zfar = _pViewer->zfar();
zfar = zfar+0.1*zfar;
//draw background paper // FIXME
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, StrokeRenderer::_textureManager->getPaperTextureIndex(_paperTextureIndex));
glColor4f(1,1,1,0.0);
glBegin(GL_TRIANGLE_STRIP);
{
glTexCoord2f(0,0); glVertex3f(0, 0, -1);
glTexCoord2f(4,0); glVertex3f(2048, 0, -1);
glTexCoord2f(0,4); glVertex3f(0, 2048, -1);
glTexCoord2f(4,4); glVertex3f(2048, 2048, -1);
}
glEnd();
}
glDisable(GL_DEPTH_TEST);
glPushAttrib(GL_COLOR_BUFFER_BIT);

View File

@@ -57,9 +57,6 @@ void Path::setRootDir(const string& iRootDir) {
_HelpIndexPath = _ProjectDir + string(DIR_SEP.c_str()) + "doc"
+ string(DIR_SEP.c_str()) + "html" + string(DIR_SEP.c_str())
+ "index.html";
_PapersDir = _ProjectDir + string(DIR_SEP.c_str()) + "data"
+ string(DIR_SEP.c_str()) + "textures" + string(DIR_SEP.c_str())
+ "papers" + string(DIR_SEP.c_str());
_EnvMapDir = _ProjectDir + string(DIR_SEP.c_str()) + "data"
+ string(DIR_SEP.c_str()) + "env_map" + string(DIR_SEP.c_str());
_MapsDir = _ProjectDir + string(DIR_SEP.c_str()) + "data"

View File

@@ -46,7 +46,6 @@ namespace Config {
string _PythonPath;
string _BrowserCmd;
string _HelpIndexPath;
string _PapersDir;
string _EnvMapDir;
string _MapsDir;
string _HomeDir;
@@ -65,7 +64,6 @@ namespace Config {
const string& getPythonPath() const {return _PythonPath;}
const string& getBrowserCmd() const {return _BrowserCmd;}
const string& getHelpIndexpath() const {return _HelpIndexPath;}
const string& getPapersDir() const {return _PapersDir;}
const string& getEnvMapDir() const {return _EnvMapDir;}
const string& getMapsDir() const {return _MapsDir;}
const string& getHomeDir() const {return _HomeDir;}
@@ -102,10 +100,6 @@ namespace Config {
static const real DEFAULT_SPHERE_RADIUS = 1.0;
static const real DEFAULT_DKR_EPSILON = 0.0;
// Papers
static const string DEFAULT_PAPER_TEXTURE("whitepaper.jpg");
} // End of namepace Config
#endif // APP_CONFIG_H

View File

@@ -988,16 +988,6 @@ string Controller::getModulesDir() const {
return dir;
}
void Controller::setPapersDir(const string& dir) {
//_current_dirs->setValue("papers/dir", dir);
}
string Controller::getPapersDir() const {
string dir = Config::Path::getInstance()->getPapersDir();
//_current_dirs->getValue("papers/dir", dir);
return dir;
}
void Controller::setHelpIndex(const string& index) {
_help_index = index;
}
@@ -1077,11 +1067,6 @@ void Controller::init_options(){
// Visibility
setQuantitativeInvisibility(true);
// Papers Textures
vector<string> sl;
sl.push_back( StringUtils::toAscii( cpath->getPapersDir() + Config::DEFAULT_PAPER_TEXTURE ) );
TextureManager::Options::setPaperTextures( sl );
// Drawing Buffers
setFrontBufferFlag(false);
setBackBufferFlag(true);

View File

@@ -132,8 +132,6 @@ public:
string getModelsDir() const;
void setModulesDir(const string& dir);
string getModulesDir() const;
void setPapersDir(const string& dir);
string getPapersDir() const;
void setHelpIndex(const string& dir);
string getHelpIndex() const;
void setBrowserCmd(const string& cmd);

View File

@@ -5,7 +5,7 @@
#include "BPy_Id.h"
#include "BPy_IntegrationType.h"
#include "BPy_Interface0D.h"
#include "Interface0D/BPy_CurvePoint.cpp"
#include "Interface0D/BPy_CurvePoint.h"
#include "Interface0D/CurvePoint/BPy_StrokeVertex.h"
#include "Interface0D/BPy_SVertex.h"
#include "Interface0D/BPy_ViewVertex.h"

View File

@@ -31,6 +31,7 @@ extern "C" {
#include "BLI_blenlib.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "MEM_guardedalloc.h"
}
#include "../system/StringUtils.h"
@@ -112,7 +113,6 @@ void GLStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const
//first texture, basically the only one for lighter strokes
glBindTexture(GL_TEXTURE_2D, iStrokeRep->getTextureId());
//glBindTexture(GL_TEXTURE_2D, _textureManager.getPaperTextureIndex());
vector<Strip*>& strips = iStrokeRep->getStrips();
for(vector<Strip*>::iterator s=strips.begin(), send=strips.end();
@@ -173,7 +173,6 @@ void GLStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
//first texture, basically the only one for lighter strokes
glBindTexture(GL_TEXTURE_2D, iStrokeRep->getTextureId());
//glBindTexture(GL_TEXTURE_2D, _textureManager.getPaperTextureIndex());
vector<Strip*>& strips = iStrokeRep->getStrips();
for(vector<Strip*>::iterator s=strips.begin(), send=strips.end();
@@ -272,29 +271,6 @@ GLTextureManager::~GLTextureManager ()
{
}
void
GLTextureManager::loadPapers ()
{
unsigned size = _papertextures.size();
_papertexname = new unsigned[size];
GLuint *tmp = new GLuint[size];
glGenTextures(size, tmp);
for(unsigned i=0;i<size;++i){
_papertexname[i] = tmp[i];
}
delete [] tmp;
// Papers textures
cout << "Loading papers textures..." << endl;
for (unsigned i = 0; i < size; i++){
cout << i << ": " << _papertextures[i] << endl;
preparePaper(_papertextures[i].c_str(), _papertexname[i]);
}
cout << "Done." << endl << endl;
}
void GLTextureManager::loadStandardBrushes()
{
// getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::HUMID_MEDIUM);
@@ -356,12 +332,11 @@ GLTextureManager::prepareTextureAlpha (string sname, GLuint itexname)
char * name = (char *) sname.c_str();
//soc
// QImage qim(name);
// QFileInfo fi(name);
// QString filename = fi.fileName();
ImBuf *qim = IMB_loadiffname(name, 0);
char filename[FILE_MAXFILE];
BLI_splitdirstring(name, filename);
char *p = BLI_strdup(name);
BLI_splitdirstring(p, filename);
MEM_freeN(p);
//soc if (qim.isNull())
if (!qim) //soc
@@ -394,7 +369,7 @@ GLTextureManager::prepareTextureAlpha (string sname, GLuint itexname)
GL_ALPHA, GL_UNSIGNED_BYTE, qim->rect); //soc
//soc 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 << " \"" << filename << "\" loaded with 32 bits per pixel" << endl;
return true;
@@ -407,12 +382,11 @@ GLTextureManager::prepareTextureLuminance (string sname, GLuint itexname)
char * name = (char *) sname.c_str();
//soc
// QImage qim(name);
// QFileInfo fi(name);
// QString filename = fi.fileName();
ImBuf *qim = IMB_loadiffname(name, 0);
char filename[FILE_MAXFILE];
BLI_splitdirstring(name, filename);
char *p = BLI_strdup(name);
BLI_splitdirstring(p, filename);
MEM_freeN(p);
if (!qim) //soc
{
@@ -442,7 +416,7 @@ GLTextureManager::prepareTextureLuminance (string sname, GLuint itexname)
GL_LUMINANCE, GL_UNSIGNED_BYTE, qim->rect); //soc
//soc 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 << " \"" << filename << "\" loaded with "<< qim->depth << " bits per pixel" << endl;
return true;
@@ -455,12 +429,11 @@ GLTextureManager::prepareTextureLuminanceAndAlpha (string sname, GLuint itexname
char * name = (char *) sname.c_str();
//soc
// QImage qim(name);
// QFileInfo fi(name);
// QString filename = fi.fileName();
ImBuf *qim = IMB_loadiffname(name, 0);
char filename[FILE_MAXFILE];
BLI_splitdirstring(name, filename);
char *p = BLI_strdup(name);
BLI_splitdirstring(p, filename);
MEM_freeN(p);
if (!qim) //soc
{
@@ -493,54 +466,10 @@ GLTextureManager::prepareTextureLuminanceAndAlpha (string sname, GLuint itexname
GL_ALPHA, GL_UNSIGNED_BYTE, qim->rect); //soc
//soc 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 << " \"" << filename << "\" loaded with "<< qim->depth << " bits per pixel" << endl;
return true;
}
bool
GLTextureManager::preparePaper (const char *name, GLuint itexname)
{
//soc
// QImage qim(name);
// QFileInfo fi(name);
// QString filename = fi.fileName();
ImBuf *qim = IMB_loadiffname(name, 0);
char filename[FILE_MAXFILE];
BLI_splitdirstring((char *)name, filename);
if (!qim) //soc
{
cerr << " Error: unable to read \"" << filename << "\"" << endl;
IMB_freeImBuf(qim);
return false;
}
//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);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, qim->x, qim->y, 0,
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 32 bits per pixel" << endl;
return true;
}

View File

@@ -64,12 +64,10 @@ protected:
virtual unsigned loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM);
protected:
virtual void loadPapers();
virtual void loadStandardBrushes();
bool prepareTextureAlpha (string name, GLuint itexname);
bool prepareTextureLuminance (string name, GLuint itexname);
bool prepareTextureLuminanceAndAlpha (string name, GLuint itexname);
bool preparePaper (const char *name, GLuint itexname);
};

View File

@@ -56,9 +56,7 @@ Canvas::Canvas()
_SelectedFEdge = 0;
_pInstance = this;
PseudoNoise::init(42);
_paperTextureIndex = 0;
_Renderer = 0;
_drawPaper = true;
_current_sm = NULL;
_steerableViewMap = new SteerableViewMap(NB_STEERABLE_VIEWMAP-1);
}
@@ -68,9 +66,7 @@ Canvas::Canvas(const Canvas& iBrother)
_SelectedFEdge = iBrother._SelectedFEdge;
_pInstance = this;
PseudoNoise::init(42);
_paperTextureIndex = iBrother._paperTextureIndex;
_Renderer = iBrother._Renderer;
_drawPaper = iBrother._drawPaper;
_current_sm = iBrother._current_sm;
_steerableViewMap = new SteerableViewMap(*(iBrother._steerableViewMap));
@@ -282,18 +278,6 @@ void Canvas::causalStyleModules(vector<unsigned>& vec, unsigned index) {
vec.push_back(i);
}
void Canvas::changePaperTexture(bool increment)
{
if(increment)
_paperTextureIndex = (_paperTextureIndex+1) % TextureManager::getPaperTexturesNumber();
else
{
_paperTextureIndex--;
if(_paperTextureIndex < 0)
_paperTextureIndex = TextureManager::getPaperTexturesNumber() - 1;
}
}
void Canvas::Render(const StrokeRenderer *iRenderer)
{
for (unsigned i = 0; i < _StyleModules.size(); i++) {

View File

@@ -76,8 +76,7 @@ protected:
std::deque<StrokeLayer*> _Layers;
std::deque<StyleModule*> _StyleModules;
FEdge *_SelectedFEdge;
int _paperTextureIndex;
bool _drawPaper;
StrokeRenderer *_Renderer;
StyleModule* _current_sm;
mapsMap _maps;
@@ -171,7 +170,6 @@ public:
inline FEdge * selectedFEdge() {return _SelectedFEdge;}
virtual int width() const = 0;
virtual int height() const = 0;
inline int currentPaperTextureIndex() const {return _paperTextureIndex;}
virtual BBox<Vec3r> scene3DBBox() const = 0;
inline const StrokeRenderer * renderer() const {return _Renderer;}
inline StyleModule* getCurrentStyleModule() { return _current_sm; }
@@ -187,10 +185,6 @@ public:
void setVisible(unsigned index, bool iVisible) ;
//inline void setDensityMap(InformationMap<RGBImage>* iMap) {_DensityMap = iMap;}
inline void AddLayer(StrokeLayer *iLayer) {_Layers.push_back(iLayer);}
inline void setCurrentPaperTextureIndex(int i) {_paperTextureIndex = i;}
void changePaperTexture(bool increment=true) ;
/*! enables/disables paper texture */
inline void togglePaperTexture() {_drawPaper = !_drawPaper;}
void resetModified(bool iMod=false);
void causalStyleModules(std::vector<unsigned>& vec, unsigned index = 0);
void setModified(unsigned index, bool b);

View File

@@ -48,11 +48,6 @@ bool StrokeRenderer::loadTextures()
return true;
}
// unsigned int StrokeRenderer::getPaperTextureIndex(unsigned int index)
// {
// return _textureManager->getPaperTextureIndex(index);
// }
/**********************************/
/* */
@@ -66,9 +61,6 @@ bool StrokeRenderer::loadTextures()
LIB_STROKE_EXPORT
TextureManager* TextureManager::_pInstance = 0;
LIB_STROKE_EXPORT
vector<string> TextureManager::_papertextures;
LIB_STROKE_EXPORT
string TextureManager::_patterns_path;
@@ -77,7 +69,6 @@ string TextureManager::_brushes_path;
TextureManager::TextureManager ()
{
_papertexname = NULL;
_hasLoadedTextures=false;
_pInstance = this;
_defaultTextureId = 0;
@@ -85,8 +76,6 @@ TextureManager::TextureManager ()
TextureManager::~TextureManager ()
{
if (_papertexname)
delete _papertexname;
if(!_brushesMap.empty())
_brushesMap.clear();
_pInstance = 0;
@@ -95,8 +84,7 @@ TextureManager::~TextureManager ()
void TextureManager::load()
{
if(_hasLoadedTextures)
return ;
loadPapers();
return;
loadStandardBrushes();
_hasLoadedTextures = true;
}
@@ -116,14 +104,6 @@ unsigned TextureManager::getBrushTextureIndex(string name, Stroke::MediumType lo
}
}
vector<string>& TextureManager::Options::getPaperTextures() {
return _papertextures;
}
void TextureManager::Options::setPaperTextures(const vector<string>& sl) {
_papertextures = sl;
}
void TextureManager::Options::setPatternsPath(const string& path) {
_patterns_path = path;
}
@@ -139,8 +119,3 @@ void TextureManager::Options::setBrushesPath(const string& path) {
string TextureManager::Options::getBrushesPath() {
return _brushes_path;
}
unsigned TextureManager::getPaperTexturesNumber() {
return _papertextures.size();
}

View File

@@ -59,16 +59,12 @@ public:
static TextureManager * getInstance() {return _pInstance;}
void load () ;
unsigned getBrushTextureIndex(string name, Stroke::MediumType iType = Stroke::OPAQUE_MEDIUM) ;
unsigned getPaperTextureIndex(unsigned i) { return _papertexname[i]; }
static unsigned getPaperTexturesNumber();
inline bool hasLoaded() const {return _hasLoadedTextures;}
inline unsigned int getDefaultTextureId() const {return _defaultTextureId;}
struct LIB_STROKE_EXPORT Options
{
static void setPaperTextures(const vector<string>& sl);
static vector<string>& getPaperTextures();
static void setPatternsPath(const string& path);
static string getPatternsPath();
@@ -78,7 +74,6 @@ public:
};
protected:
virtual void loadPapers() = 0;
virtual void loadStandardBrushes() = 0;
virtual unsigned loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM) = 0;
@@ -97,10 +92,8 @@ public:
static TextureManager * _pInstance;
bool _hasLoadedTextures;
brushesMap _brushesMap;
unsigned* _papertexname;
static string _patterns_path;
static string _brushes_path;
static vector<string> _papertextures;
unsigned int _defaultTextureId;
};
@@ -132,7 +125,6 @@ class LIB_STROKE_EXPORT StrokeRenderer
static bool loadTextures() ;
//static unsigned int getTextureIndex(unsigned int index) ;
//static unsigned int getPaperTextureIndex(unsigned int index) ;
static TextureManager *_textureManager;
};