Jump to content

Can't get some render to texture stuff get working


trsh
 Share

Recommended Posts

My code (you can paste it in PIXI's examples)

I expect in a `smallScreen` in corner to show what's going on on stage.  But no :/

const app = new PIXI.Application();
document.body.appendChild(app.view);

const geometry = new PIXI.Geometry()
    .addAttribute('aVertexPosition', [-100, -50, 100, -50, 0, 100]);

const shader = PIXI.Shader.from(`

    precision mediump float;
    attribute vec2 aVertexPosition;

    uniform mat3 translationMatrix;
    uniform mat3 projectionMatrix;

    void main() {
        gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
    }`,

`precision mediump float;

    void main() {
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    }

`);

const triangle = new PIXI.Mesh(geometry, shader);
const container = new PIXI.Container();
container.addChild(triangle);

const rtt = PIXI.RenderTexture.create(200,200);
const smallSCreen = PIXI.Sprite.from(rtt);
smallSCreen.x = 0;
smallSCreen.y = 0;
smallSCreen.width = 100;
smallSCreen.height = 100;

triangle.position.set(400, 300);

app.stage.addChild(container);
app.stage.addChild(smallSCreen);

app.ticker.add((delta) => {
    triangle.rotation += 0.01;
    app.renderer.render(container, rtt);
});

 

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...