ecs适配egret
This commit is contained in:
3
source/src/Graphics/Batcher/GraphicsResource.ts
Normal file
3
source/src/Graphics/Batcher/GraphicsResource.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
abstract class GraphicsResource {
|
||||
|
||||
}
|
||||
33
source/src/Graphics/GraphicsCapabilities.ts
Normal file
33
source/src/Graphics/GraphicsCapabilities.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
class GraphicsCapabilities {
|
||||
public supportsTextureFilterAnisotropic: boolean;
|
||||
public supportsNonPowerOfTwo: boolean;
|
||||
public supportsDepth24: boolean;
|
||||
public supportsPackedDepthStencil: boolean;
|
||||
public supportsDepthNonLinear: boolean;
|
||||
public supportsTextureMaxLevel: boolean;
|
||||
public supportsS3tc: boolean;
|
||||
public supportsDxt1: boolean;
|
||||
public supportsPvrtc: boolean;
|
||||
public supportsAtitc: boolean;
|
||||
public supportsFramebufferObjectARB: boolean;
|
||||
|
||||
public initialize(device: GraphicsDevice){
|
||||
this.platformInitialize(device);
|
||||
}
|
||||
|
||||
private platformInitialize(device: GraphicsDevice){
|
||||
let gl: WebGLRenderingContext = new egret.sys.RenderBuffer().context.getInstance();
|
||||
this.supportsNonPowerOfTwo = false;
|
||||
this.supportsTextureFilterAnisotropic = gl.getExtension("EXT_texture_filter_anisotropic") != null;
|
||||
this.supportsDepth24 = true;
|
||||
this.supportsPackedDepthStencil = true;
|
||||
this.supportsDepthNonLinear = false;
|
||||
this.supportsTextureMaxLevel = true;
|
||||
this.supportsS3tc = gl.getExtension("WEBGL_compressed_texture_s3tc") != null ||
|
||||
gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") != null;
|
||||
this.supportsDxt1 = this.supportsS3tc;
|
||||
this.supportsPvrtc = false;
|
||||
this.supportsAtitc = gl.getExtension("WEBGL_compressed_texture_astc") != null;
|
||||
this.supportsFramebufferObjectARB = false;
|
||||
}
|
||||
}
|
||||
10
source/src/Graphics/GraphicsDevice.ts
Normal file
10
source/src/Graphics/GraphicsDevice.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
class GraphicsDevice {
|
||||
private viewport: Viewport;
|
||||
|
||||
public graphicsCapabilities: GraphicsCapabilities;
|
||||
|
||||
constructor(){
|
||||
this.graphicsCapabilities = new GraphicsCapabilities();
|
||||
this.graphicsCapabilities.initialize(this);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ class PolyLight extends RenderableComponent {
|
||||
|
||||
public get bounds(){
|
||||
if (this._areBoundsDirty){
|
||||
this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, new Vector2(this._radius),
|
||||
this._bounds.calculateBounds(this.entity.position, this._localOffset, new Vector2(this._radius),
|
||||
Vector2.one, 0, this._radius * 2, this._radius * 2);
|
||||
this._areBoundsDirty = false;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,7 @@ abstract class Renderer {
|
||||
public onAddedToScene(scene: Scene){}
|
||||
|
||||
protected beginRender(cam: Camera){
|
||||
cam.transform.updateTransform();
|
||||
|
||||
let entities = SceneManager.scene.entities;
|
||||
for (let i = 0; i < entities.buffer.length; i ++){
|
||||
entities.buffer[i].transform.updateTransform();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
34
source/src/Graphics/Viewport.ts
Normal file
34
source/src/Graphics/Viewport.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
class Viewport {
|
||||
private _x: number;
|
||||
private _y: number;
|
||||
private _width: number;
|
||||
private _height: number;
|
||||
private _minDepth: number;
|
||||
private _maxDepth: number;
|
||||
|
||||
public get aspectRatio(){
|
||||
if ((this._height != 0) && (this._width != 0))
|
||||
return (this._width / this._height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public get bounds(){
|
||||
return new Rectangle(this._x, this._y, this._width, this._height);
|
||||
}
|
||||
public set bounds(value: Rectangle){
|
||||
this._x = value.x;
|
||||
this._y = value.y;
|
||||
this._width = value.width;
|
||||
this._height = value.height;
|
||||
}
|
||||
|
||||
constructor(x: number, y: number, width: number, height: number){
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
this._minDepth = 0;
|
||||
this._maxDepth = 1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user