texture is now correctly detected and used,
there seams to be a problem with the UV. They are not correctly
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
#define VERTEX_SHADER "Shader/VertexTextureShader.mv2shdr"
|
||||
#define FRAGMENT_SHADER "Shader/FragmentTextureShader.mv2shdr"
|
||||
#define TEXTURE_NAME "Textures/texture32R.tga"
|
||||
//#define TEXTURE_NAME "Textures/texture32R.tga"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// public constructor/destructor
|
||||
@@ -281,11 +281,13 @@ void OpenGLController::loadMsh(const char * path)
|
||||
gluiSamplerID = glGetUniformLocation(gluiShaderPrgmID, "textureSampler");
|
||||
|
||||
// get data
|
||||
std::list<std::string> listTextures;
|
||||
try
|
||||
{
|
||||
Object obj(path);
|
||||
vfVertices = obj.getVertex();
|
||||
vfUV = obj.getUV();
|
||||
listTextures = obj.getTexture();
|
||||
}
|
||||
catch (std::invalid_argument e)
|
||||
{
|
||||
@@ -296,15 +298,17 @@ void OpenGLController::loadMsh(const char * path)
|
||||
glGenTextures(1, &gluiTextureID);
|
||||
glBindTexture(GL_TEXTURE_2D, gluiTextureID);
|
||||
|
||||
std::list<std::string> listTextures;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (listTextures.empty())
|
||||
throw std::invalid_argument("no texture names");
|
||||
|
||||
TextureTGA tempTex(listTextures.front().c_str());
|
||||
std::string tempPath = path;
|
||||
|
||||
while (tempPath.back() != '/' && tempPath.back() != '\\')
|
||||
tempPath.pop_back();
|
||||
|
||||
TextureTGA tempTex(std::string(tempPath + listTextures.front()).c_str());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, tempTex.hasAlpha() ? GL_RGBA : GL_RGB, tempTex.getWidth(), tempTex.getHeight(), 0, tempTex.hasAlpha() ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, tempTex.getData().data());
|
||||
}
|
||||
catch (std::invalid_argument e)
|
||||
|
Reference in New Issue
Block a user