我是 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 包含纹理坐标作为 vector ,我需要将纹理绑定(bind)到对象,但我找不到一个清楚的例子来说明如何做?我尝试过的一切都给我留下了一个白色的圆圈。
谢谢。
最佳答案
找到我的解决方案。我正在使用 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();
关于c++ - Cinder 如何纹理 .obj trimesh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26110455/