我想上传部分Pixmap (它的指定矩形)到GPU中的纹理(在指定的位置)。
我想要实现的是
void updateTextureFromPixmap(sourcePixmap,sourceRectangle,destTexture, destRectangle) {
destTexture.fill(copyfrom(sourcePixmap),copyarea(SourceRectangle),newArea(destRectangle));
}我应该使用glTexSubImage2D吗?我还在学习opengl ;/
发布于 2014-01-08 18:58:52
您可以使用Texture#draw将像素映射到纹理中。如下所示:
Pixmap imgA = new Pixmap(Gdx.files.internal("mypng"));
Texture texture = new Texture(200, 200, Pixmap.Format.RGBA8888);
texture.draw(imgA, 0, 0); 发布于 2014-03-27 02:27:00
public class PixmapHelper {
static Pixmap fullGraphics ;
static Pixmap miniObject;
public static void Initialize()
{
fullGraphics =AssetLoader.GetPixmap(Settings.TEX_MAP_OBJECTS);
miniObject=new Pixmap(8,8, Pixmap.Format.RGBA8888);
}
static void Draw(TextureRegion textureRegion,Texture dstTexture,int dstX,int dstY)
{
miniObject.drawPixmap(fullGraphics, 0,0, textureRegion.getRegionX(),textureRegion.getRegionY(),
textureRegion.getRegionWidth(),textureRegion.getRegionHeight());
dstTexture.draw(miniObject,dstX,dstY);
}
}https://stackoverflow.com/questions/20026627
复制相似问题