Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

rainyt
Copy link
Contributor

@rainyt rainyt commented May 15, 2024

  1. Referencing the OpenGLRenderer renderer eliminates the need for reconstruction and reduces the cost of initializing the Shader.

  2. Set default shaders for existing OpenGLRenderer renderers.

It is very effective in the following code:

package;

import openfl.geom.Matrix;
import openfl.display.FPS;
import openfl.events.Event;
import openfl.display.BitmapData;
import openfl.display.Bitmap;
import openfl.display.Sprite;

class Main extends Sprite {
	public function new() {
		super();

		var spr = new Sprite();
		spr.graphics.beginFill(0xff0000);
		spr.graphics.drawCircle(0, 0, 10);
		spr.graphics.endFill();

		var drawBitmapData = new BitmapData(500, 500, false, 0);
		drawBitmapData.disposeImage();

		var drawBitmap = new Bitmap(drawBitmapData);
		this.addChild(drawBitmap);

		this.addEventListener(Event.ENTER_FRAME, (e) -> {
			var m = new Matrix();
			m.translate(Math.random() * 500, Math.random() * 500);
			for (i in 0...100) {
				drawBitmapData.draw(spr, m);
			}
		});

		var fps = new FPS();
		this.addChild(fps);
	}
}

1. Referencing the OpenGLRenderer renderer eliminates the need for reconstruction and reduces the cost of initializing the Shader.

2. Set default shaders for existing OpenGLRenderer renderers.
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

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.