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:
parent
9a1902b1cb
commit
e642818e4a
54
WFObj.cc
54
WFObj.cc
@ -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())
|
||||
@ -575,21 +575,24 @@ void WFMtl::renderBegin(const string & mtlname)
|
||||
}
|
||||
else if (type == "map_Kd") /* load a diffuse texture */
|
||||
{
|
||||
/* TODO: figure out how i want to load the texture */
|
||||
if (stmts[i].size() == 2)
|
||||
if (doTextureInfo)
|
||||
{
|
||||
if (m_loadTexture != NULL)
|
||||
/* TODO: figure out how i want to load the texture */
|
||||
if (stmts[i].size() == 2)
|
||||
{
|
||||
GLuint tex = m_loadTexture( (basePath(m_fileName) +
|
||||
stmts[i][1]).c_str() );
|
||||
if (tex > 0)
|
||||
if (m_loadTexture != NULL)
|
||||
{
|
||||
GLuint tex = m_loadTexture( (basePath(m_fileName) +
|
||||
stmts[i][1]).c_str() );
|
||||
if (tex > 0)
|
||||
{
|
||||
#ifdef DEBUGGL
|
||||
cout << " glBindTexture(GL_TEXTURE_2D, " << tex << ")" << endl;
|
||||
cout << " glBindTexture(GL_TEXTURE_2D, " << tex << ")" << endl;
|
||||
#endif
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
foundTexture = true;
|
||||
didSomething = true;
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
foundTexture = true;
|
||||
didSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -599,19 +602,22 @@ void WFMtl::renderBegin(const string & mtlname)
|
||||
if (didSomething)
|
||||
{
|
||||
pushAttributes();
|
||||
if (foundTexture)
|
||||
if (doTextureInfo)
|
||||
{
|
||||
if (foundTexture)
|
||||
{
|
||||
#ifdef DEBUGGL
|
||||
cout << " glEnable(GL_TEXTURE_2D)" << endl;
|
||||
cout << " glEnable(GL_TEXTURE_2D)" << endl;
|
||||
#endif
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUGGL
|
||||
cout << " glDisable(GL_TEXTURE_2D)" << endl;
|
||||
cout << " glDisable(GL_TEXTURE_2D)" << endl;
|
||||
#endif
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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())
|
||||
|
6
WFObj.hh
6
WFObj.hh
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user