1

I would like to upload part of Pixmap (specified Rectangle of it) to Texture in GPU (at specified position).

What i would like to achieve is

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

Should i use glTexSubImage2D ? I'm still learning opengl ;/

Daahrien
  • 10,190
  • 6
  • 39
  • 71
Paweł
  • 2,144
  • 1
  • 18
  • 25

2 Answers2

1

You can use Texture#draw to get a pixmap into a Texture. Like this:

Pixmap imgA = new Pixmap(Gdx.files.internal("mypng"));
Texture texture = new Texture(200, 200, Pixmap.Format.RGBA8888); 
texture.draw(imgA, 0, 0); 
Daahrien
  • 10,190
  • 6
  • 39
  • 71
  • mhm, this will upload 200x200 as one texture to gpu, i need to update only a part of texture which is already in gpu – Paweł Jan 10 '14 at 13:44
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);


    }
}
Rinnion
  • 89
  • 1
  • 9