【问题标题】:Upload part of Pixmap into GPU将 Pixmap 的一部分上传到 GPU
【发布时间】:2013-11-17 02:53:38
【问题描述】:

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

我想要实现的是

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

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

【问题讨论】:

    标签: java textures libgdx pixmap


    【解决方案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); 
    

    【讨论】:

    • mhm,这会将 200x200 作为一个纹理上传到 gpu,我只需要更新 gpu 中已经存在的纹理的一部分
    【解决方案2】:
    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);
    
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 2014-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-12-28
      相关资源
      最近更新 更多