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

View File

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