Jump to content

"Sub-texture" of a RenderTexture?


lordnoriyuki
 Share

Recommended Posts

I want a subset of a RenderTexture, but this doesn't seem to work:

var renderTexture = new PIXI.RenderTexture(1024, 1024);// render something into the renderTexturevar newSprite = new PIXI.Sprite(new PIXI.Texture(renderTexture, new Rectangle(0, 0, 240, 240)))// render this newSprite into a stage

The sprite with the sub-rectangle of the texture doesn't get rendered.

 

If I do the following it works fine (whole renderTexture on a sprite):

var newSprite = new PIXI.Sprite(renderTexture)

If I do the following it doesn't render either (whole renderTexture, but a new texture from the renderTexture):

var newSprite = new PIXI.Sprite(new PIXI.Texture(renderTexture))

How do I get a sprite which has a sub texture of an existing RenderTexture?

 

Thanks

 

- lordnoriyuki

 

Link to comment
Share on other sites

That doesn't seem to work either:



var imageTexture = PIXI.Texture.fromImage("image.png");
var renderTexture = new PIXI.RenderTexture(1024, 1024);

var imageSprite = new PIXI.Sprite(imageTexture);
    
renderTexture.render(imageSprite);

var subTexture = new PIXI.Texture(renderTexture.baseTexture, new PIXI.Rectangle(0, 0, 1024, 1024));
var subSprite = new PIXI.Sprite(subTexture);

stage.addChild(subSprite);

renderer.render(stage);


Nothing appears. If I change renderTexture.baseTexture to imageTexture, then it works fine.

 

-lordnoriyuki

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...