Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create RenderTexture bigger than the game size. #4139

Closed
chaoyang805 opened this issue Nov 1, 2018 · 5 comments
Closed

Can't create RenderTexture bigger than the game size. #4139

chaoyang805 opened this issue Nov 1, 2018 · 5 comments

Comments

@chaoyang805
Copy link

Version

  • Phaser Version: Phaser v3.15.1
  • Operating system: macOS 10.14.1 beta
  • Browser: Chrome 70.0.3538.77

Description

I create a RenderTexture which is bigger than the initial game size and set a fill background to it. But only within the game size the background color was rendered. Is it a bug that RenderTexture can not bigger than the game size?

Example Test Code

Below is the sample code or clone from here https://github.com/chaoyang805/RenderTextureTest.git

var config = {
  width: 800,
  height: 600,
  parent: 'app',
  type: Phaser.WEBGL,
  backgroundColor: 0xacde00,
  physics: {
    default: 'impact',
    impact: {
      gravity: 0,
      maxVelocity: 100,
      debug: true
    }
  },
  scene: {
    preload: preload,
    create: create,
    update: update
  }
};

var game = new Phaser.Game(config);
var renderTexture
var cursors
function preload() {
  console.log('preload')
  this.load.image('avatar', 'assets/avatar.png');
}

function create() {
  let width = 1600;
  let height = 1200;
  // The world bounds is set bigger than game size so that camera scrolling is possible.
  this.impact.world.setBounds(0, 0, width, height, 10);
  console.log('create')
  // Create a renderTexture bigger than game size
  renderTexture = this.add.renderTexture(0, 0, width, height);
  renderTexture.fill(0x00f0f0);
  // Draw a bunch of objects along X axis.
  for (let i = 0; i < 100; i++) {
    renderTexture.draw('avatar', i * 60, 0);
  }
  cursors = this.input.keyboard.createCursorKeys();
}

function update(time, delta) {
  if (cursors.left.isDown) {
    this.cameras.main.scrollX -= 4;
  }
  if (cursors.right.isDown) {
    this.cameras.main.scrollX += 4;
  }
  if (cursors.up.isDown && this.cameras.main.zoom < 2) {
    this.cameras.main.zoom += 0.02;
  }
  if (cursors.down.isDown && this.cameras.main.zoom > 0.5) {
    this.cameras.main.zoom -= 0.02;
  }
}

Additional Information

@jorbascrumps
Copy link
Contributor

I'm seeing this behaviour as well. It's still unclear to me if this is in fact a bug or a misunderstanding of how a RenderTexture should behave. See this thread for my ongoing adventure.

@chaoyang805
Copy link
Author

I'm seeing this behaviour as well. It's still unclear to me if this is in fact a bug or a misunderstanding of how a RenderTexture should behave. See this thread for my ongoing adventure.

Yes, I saw this post. Still don't konw how to solve this 😞 .

@photonstorm
Copy link
Collaborator

It's almost certainly because of the gl scissor settings, which are enabled by default for cameras, and I suspect are scissoring all draws to the render texture beyond the camera range.

@chaoyang805
Copy link
Author

It's almost certainly because of the gl scissor settings, which are enabled by default for cameras, and I suspect are scissoring all draws to the render texture beyond the camera range.

So how to disable this scissor settings?

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

JasonHK pushed a commit to JasonHK/phaser that referenced this issue Jun 4, 2019
…uld be automatically clipped when drawn to in WebGL. They now reset the gl scissor and drawing height property in order to draw to their full size, regardless of the canvas size. Fix phaserjs#4139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants