首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >上传部分Pixmap到GPU

上传部分Pixmap到GPU
EN

Stack Overflow用户
提问于 2013-11-17 10:53:38
回答 2查看 90关注 0票数 1

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

我想要实现的是

代码语言:javascript
复制
void updateTextureFromPixmap(sourcePixmap,sourceRectangle,destTexture, destRectangle) {  
    destTexture.fill(copyfrom(sourcePixmap),copyarea(SourceRectangle),newArea(destRectangle));
}

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

EN

回答 2

Stack Overflow用户

发布于 2014-01-08 18:58:52

您可以使用Texture#draw将像素映射到纹理中。如下所示:

代码语言:javascript
复制
Pixmap imgA = new Pixmap(Gdx.files.internal("mypng"));
Texture texture = new Texture(200, 200, Pixmap.Format.RGBA8888); 
texture.draw(imgA, 0, 0); 
票数 1
EN

Stack Overflow用户

发布于 2014-03-27 02:27:00

代码语言:javascript
复制
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);


    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20026627

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档