added enableBlending flag to WFObj rendering

git-svn-id: svn://anubis/misc/wfobj@242 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2010-09-17 16:18:19 +00:00
parent 11033c5876
commit 9920ba04b8
2 changed files with 23 additions and 11 deletions

View File

@ -195,7 +195,7 @@ void WFObj::processInputLine(const std::string & input)
}
GLuint WFObj::render(bool doTextureInfo)
GLuint WFObj::render(bool doTextureInfo, bool enableBlending)
{
checkGLError();
GLuint list = glGenLists(1);
@ -331,13 +331,15 @@ GLuint WFObj::render(bool doTextureInfo)
}
if (inMaterial)
{
material.renderEnd(currentMaterialName, doTextureInfo);
material.renderEnd(currentMaterialName, doTextureInfo,
enableBlending);
inMaterial = false;
}
if (m_data[i].size() >= 2)
{
currentMaterialName = m_data[i][1];
material.renderBegin(currentMaterialName, doTextureInfo);
material.renderBegin(currentMaterialName, doTextureInfo,
enableBlending);
inMaterial = true;
}
}
@ -362,7 +364,7 @@ GLuint WFObj::render(bool doTextureInfo)
}
if (inMaterial)
{
material.renderEnd(currentMaterialName, doTextureInfo);
material.renderEnd(currentMaterialName, doTextureInfo, enableBlending);
inMaterial = false;
}
glEndList();
@ -493,7 +495,8 @@ void WFObj::WFMtl::processInputLine(const std::string & input)
}
}
void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo,
bool enableBlending)
{
map< string, vector< vector<string> > >::iterator it = m_data.find(mtlname);
if (it == m_data.end())
@ -610,6 +613,11 @@ void WFObj::WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
pushAttributes();
if (doTextureInfo)
{
if (enableBlending)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (foundTexture)
{
#ifdef DEBUGGL
@ -635,15 +643,16 @@ void WFObj::WFMtl::pushAttributes()
return;
m_attributesPushed = true;
#ifdef DEBUGGL
cout << " glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT)"
cout << " glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT)"
<< endl;
#endif
checkGLError();
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT);
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
checkGLError();
}
void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
void WFObj::WFMtl::renderEnd(const string & mtlname, bool doTextureInfo,
bool enableBlending)
{
map< string, vector< vector<string> > >::iterator it = m_data.find(mtlname);
if (it == m_data.end())

View File

@ -24,9 +24,11 @@ public:
WFMtl(WFObj * obj) { m_obj = obj; }
bool load(const FileLoader::Path & path);
void renderBegin(const std::string & mtlname,
bool doTextureInfo = true);
bool doTextureInfo = true,
bool enableBlending = false);
void renderEnd(const std::string & mtlname,
bool doTextureInfo = true);
bool doTextureInfo = true,
bool enableBlending = false);
protected:
/* methods */
@ -51,7 +53,8 @@ public:
};
bool load(const FileLoader::Path & path);
GLuint render(bool doTextureInfo = true);
GLuint render(bool doTextureInfo = true,
bool enableBlending = false);
const float * const getAABB() { return m_aabb; }
protected: