1

我想将 Pixmap 的一部分(它的指定矩形)上传到 GPU 中的纹理(在指定位置)。

我想要实现的是

void updateTextureFromPixmap(sourcePixmap,sourceRectangle,destTexture, destRectangle) {  
    destTexture.fill(copyfrom(sourcePixmap),copyarea(SourceRectangle),newArea(destRectangle));
}

我应该使用 glTexSubImage2D 吗?我还在学习opengl ;/

4

2 回答 2

1

您可以使用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-01-08T10:58:51.770 回答
0
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);


    }
}
于 2014-03-26T18:27:00.047 回答