added doTextureInfo option to WFObj::render() and WFMtl class methods

git-svn-id: svn://anubis/misc/wfobj@77 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2008-11-13 23:21:22 +00:00
parent 9a1902b1cb
commit e642818e4a
2 changed files with 33 additions and 27 deletions

View File

@ -166,7 +166,7 @@ void WFObj::processInputLine(const std::string & input)
}
GLuint WFObj::render()
GLuint WFObj::render(bool doTextureInfo)
{
GLuint list = glGenLists(1);
glNewList(list, GL_COMPILE);
@ -301,13 +301,13 @@ GLuint WFObj::render()
}
if (inMaterial)
{
material.renderEnd(currentMaterialName);
material.renderEnd(currentMaterialName, doTextureInfo);
inMaterial = false;
}
if (m_data[i].size() >= 2)
{
currentMaterialName = m_data[i][1];
material.renderBegin(currentMaterialName);
material.renderBegin(currentMaterialName, doTextureInfo);
inMaterial = true;
}
}
@ -331,7 +331,7 @@ GLuint WFObj::render()
}
if (inMaterial)
{
material.renderEnd(currentMaterialName);
material.renderEnd(currentMaterialName, doTextureInfo);
inMaterial = false;
}
glEndList();
@ -492,7 +492,7 @@ void WFMtl::processInputLine(const std::string & input)
}
}
void WFMtl::renderBegin(const string & mtlname)
void WFMtl::renderBegin(const string & mtlname, bool doTextureInfo)
{
map< string, vector< vector<string> > >::iterator it = m_data.find(mtlname);
if (it == m_data.end())
@ -574,6 +574,8 @@ void WFMtl::renderBegin(const string & mtlname)
}
}
else if (type == "map_Kd") /* load a diffuse texture */
{
if (doTextureInfo)
{
/* TODO: figure out how i want to load the texture */
if (stmts[i].size() == 2)
@ -595,10 +597,13 @@ void WFMtl::renderBegin(const string & mtlname)
}
}
}
}
if (didSomething)
{
pushAttributes();
if (doTextureInfo)
{
if (foundTexture)
{
#ifdef DEBUGGL
@ -614,6 +619,7 @@ void WFMtl::renderBegin(const string & mtlname)
glDisable(GL_TEXTURE_2D);
}
}
}
}
void WFMtl::pushAttributes()
@ -627,7 +633,7 @@ void WFMtl::pushAttributes()
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT);
}
void WFMtl::renderEnd(const string & mtlname)
void WFMtl::renderEnd(const string & mtlname, bool doTextureInfo)
{
map< string, vector< vector<string> > >::iterator it = m_data.find(mtlname);
if (it == m_data.end())

View File

@ -13,7 +13,7 @@ public:
bool load(const std::string & filename,
loadTextureFunc_t loadTexture = NULL,
loadFileFunc_t loadFile = NULL);
GLuint render();
GLuint render(bool doTextureInfo = true);
const float * const getAABB() { return m_aabb; }
protected:
@ -53,8 +53,8 @@ public:
bool load(const std::string & filename,
WFObj::loadTextureFunc_t loadTexture = NULL,
WFObj::loadFileFunc_t loadFile = NULL);
void renderBegin(const std::string & mtlname);
void renderEnd(const std::string & mtlname);
void renderBegin(const std::string & mtlname, bool doTextureInfo = true);
void renderEnd(const std::string & mtlname, bool doTextureInfo = true);
protected:
/* methods */