Cinder如何纹理.obj trimesh

时间:2014-09-29 23:25:49

标签: c++ texture-mapping cinder

我是c ++ / cinder的新手,我正在尝试将3ds .obj文件导入cinder并应用简单的纹理。我真的找不到任何关于如何做到这一点的简单教程,它似乎与freeGLUT略有不同。

  gl::Texture sTexture;
  sTexture = gl::Texture(loadImage(loadAsset("texture.jpg")));

  cinder::TriMesh mySphere;
  ObjLoader loader( loadFile( "mySphere/sphere.obj" ) );
  loader.load( &mySphere );
  gl::draw( mySphere );

据我所知,mySphere将纹理合成为矢量,我需要将纹理绑定到对象,但我无法找到明确的示例?我尝试的一切都给我留下了一个白色圆圈。

感谢。

1 个答案:

答案 0 :(得分:1)

找到我的解决方案。我正在使用sTexture.bind();但是sTexture.enableAndBind();需要。

 gl::Texture sTexture;
 sTexture = gl::Texture(loadImage(loadAsset("texture.jpg")));
 sTexture.enableAndBind();
 cinder::TriMesh mySphere;
 ObjLoader loader( loadFile( "mySphere/sphere.obj" ) );
 loader.load( &mySphere );
 gl::draw( mySphere );
 sTexture.unbind();
相关问题