|
楼主 |
发表于 2009-5-9 23:34:30
|
显示全部楼层
下面是我用来贴纹理的代码:
- Image *img=NULL;
- //.....读取影像
- if(img)
- {
- Texture2D *txt=new Texture2D();
- txt->setWrap(Texture2D::WRAP_S,Texture2D::REPEAT);
- txt->setWrap(Texture2D::WRAP_T,Texture2D::REPEAT);
- txt->setFilter(Texture::MIN_FILTER,Texture::LINEAR);
- txt->setFilter(Texture::MAG_FILTER,Texture::NEAREST);
- txt->setImage(img);
- TexGen* gen=new TexGen();
- gen->setMode(TexGen::OBJECT_LINEAR);
- gen->setPlane(TexGen::S,Plane(0.f,0.f,1.f,0.f));
- StateSet* state=new StateSet();
- state->setTextureAttribute(0,txt,StateAttribute::OVERRIDE);
- state->setTextureMode(0,GL_TEXTURE_2D,StateAttribute::ON
- |StateAttribute::OVERRIDE);
- state->setTextureAttribute(0,gen,StateAttribute::OVERRIDE);
- state->setTextureMode(0,GL_TEXTURE_GEN_S,StateAttribute::ON
- |StateAttribute::OVERRIDE);
- state->setTextureMode(0,GL_TEXTURE_GEN_T,StateAttribute::ON
- |StateAttribute::OVERRIDE);
- node.setStateSet(state);
- }
复制代码
已经加了setWrap了.不知道是不是加的不正确. |
|