diff --git a/Backends/Android/kha/android/Graphics.hx b/Backends/Android/kha/android/Graphics.hx index 698a1f3d7..62a1988e4 100644 --- a/Backends/Android/kha/android/Graphics.hx +++ b/Backends/Android/kha/android/Graphics.hx @@ -58,6 +58,10 @@ class Graphics implements kha.graphics4.Graphics { } } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } @@ -185,8 +189,12 @@ class Graphics implements kha.graphics4.Graphics { this.indexBuffer = indexBuffer; } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } public function setTexture(stage: kha.graphics4.TextureUnit, texture: kha.Image): Void { diff --git a/Backends/Android/kha/graphics4/CubeMap.hx b/Backends/Android/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Android/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Empty/kha/graphics4/CubeMap.hx b/Backends/Empty/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Empty/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Flash/kha/flash/graphics4/Graphics.hx b/Backends/Flash/kha/flash/graphics4/Graphics.hx index c750a16b8..282f732d3 100644 --- a/Backends/Flash/kha/flash/graphics4/Graphics.hx +++ b/Backends/Flash/kha/flash/graphics4/Graphics.hx @@ -133,8 +133,12 @@ class Graphics implements kha.graphics4.Graphics { context.setDepthTest(write, getCompareMode(mode)); } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } private function getStencilAction(action: StencilAction): Context3DStencilAction { @@ -419,6 +423,10 @@ class Graphics implements kha.graphics4.Graphics { else context.setRenderToTexture(target.getFlashTexture(), enableDepthStencil(target.depthStencilFormat())); } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } diff --git a/Backends/Flash/kha/graphics4/CubeMap.hx b/Backends/Flash/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Flash/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/HTML5/kha/graphics4/CubeMap.hx b/Backends/HTML5/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..cfe82bebe --- /dev/null +++ b/Backends/HTML5/kha/graphics4/CubeMap.hx @@ -0,0 +1,147 @@ +package kha.graphics4; + +import js.html.webgl.GL; +import haxe.io.Bytes; +import kha.js.graphics4.Graphics; + +class CubeMap implements Canvas implements Resource { + + private var myWidth: Int; + private var myHeight: Int; + private var format: TextureFormat; + private var renderTarget: Bool; + private var depthStencilFormat: DepthStencilFormat; + private var graphics4: kha.graphics4.Graphics; + + public var frameBuffer: Dynamic = null; + public var texture: Dynamic = null; + public var depthTexture: Dynamic = null; + public var isDepthAttachment: Bool = false; + + private function new(size: Int, format: TextureFormat, renderTarget: Bool, depthStencilFormat: DepthStencilFormat) { + myWidth = size; + myHeight = size; + this.format = format; + this.renderTarget = renderTarget; + this.depthStencilFormat = depthStencilFormat; + if (renderTarget) createTexture(); + } + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + if (format == null) format = TextureFormat.RGBA32; + if (depthStencil == null) depthStencil = NoDepthAndStencil; + return new CubeMap(size, format, true, depthStencil); + } + + private function createTexture() { + if (SystemImpl.gl == null) return; + + texture = SystemImpl.gl.createTexture(); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, texture); + + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_MAG_FILTER, GL.LINEAR); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_MIN_FILTER, GL.LINEAR); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE); + + if (renderTarget) { + + frameBuffer = SystemImpl.gl.createFramebuffer(); + SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, frameBuffer); + + switch (format) { + case DEPTH16: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.DEPTH_COMPONENT, myWidth, myHeight, 0, GL.DEPTH_COMPONENT, GL.UNSIGNED_SHORT, null); + case RGBA128: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.RGBA, myWidth, myHeight, 0, GL.RGBA, GL.FLOAT, null); + case RGBA64: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.RGBA, myWidth, myHeight, 0, GL.RGBA, SystemImpl.halfFloat.HALF_FLOAT_OES, null); + case RGBA32: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.RGBA, myWidth, myHeight, 0, GL.RGBA, GL.UNSIGNED_BYTE, null); + case A32: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.ALPHA, myWidth, myHeight, 0, GL.ALPHA, GL.FLOAT, null); + case A16: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.ALPHA, myWidth, myHeight, 0, GL.ALPHA, SystemImpl.halfFloat.HALF_FLOAT_OES, null); + default: + for (i in 0...6) SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.RGBA, myWidth, myHeight, 0, GL.RGBA, GL.UNSIGNED_BYTE, null); + } + + if (format == DEPTH16) { + isDepthAttachment = true; + // OSX/Linux WebGL implementations throw incomplete framebuffer error, create color attachment + if (untyped __js__('navigator.appVersion.indexOf("Win")') == -1) { + var colortex = SystemImpl.gl.createTexture(); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, colortex); + for (i in 0...6) { + SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL.RGBA, myWidth, myHeight, 0, GL.RGBA, GL.UNSIGNED_BYTE, null); + SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_CUBE_MAP_POSITIVE_X + i, colortex, 0); + } + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, texture); + } + } + + initDepthStencilBuffer(depthStencilFormat); + SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, null); + } + + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, null); + } + + private function initDepthStencilBuffer(depthStencilFormat: DepthStencilFormat) { + switch (depthStencilFormat) { + case NoDepthAndStencil: {} + case DepthOnly: { + depthTexture = SystemImpl.gl.createTexture(); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, depthTexture); + SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP, 0, GL.DEPTH_COMPONENT, myWidth, myHeight, 0, GL.DEPTH_COMPONENT, GL.UNSIGNED_INT, null); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_MAG_FILTER, GL.NEAREST); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_MIN_FILTER, GL.NEAREST); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE); + SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, frameBuffer); + SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.DEPTH_ATTACHMENT, GL.TEXTURE_CUBE_MAP, depthTexture, 0); + } + case DepthAutoStencilAuto, Depth24Stencil8, Depth32Stencil8: + depthTexture = SystemImpl.gl.createTexture(); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, depthTexture); + SystemImpl.gl.texImage2D(GL.TEXTURE_CUBE_MAP, 0, GL.DEPTH_STENCIL, myWidth, myHeight, 0, GL.DEPTH_STENCIL, SystemImpl.depthTexture.UNSIGNED_INT_24_8_WEBGL, null); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_MAG_FILTER, GL.NEAREST); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_MIN_FILTER, GL.NEAREST); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE); + SystemImpl.gl.texParameteri(GL.TEXTURE_CUBE_MAP, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE); + SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, frameBuffer); + SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, GL.DEPTH_STENCIL_ATTACHMENT, GL.TEXTURE_CUBE_MAP, depthTexture, 0); + } + } + + public function set(stage: Int): Void { + SystemImpl.gl.activeTexture(GL.TEXTURE0 + stage); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, texture); + } + + public function setDepth(stage: Int): Void { + SystemImpl.gl.activeTexture(GL.TEXTURE0 + stage); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, depthTexture); + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return myWidth; } + public var height(get, null): Int; + private function get_height(): Int { return myHeight; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { + if (graphics4 == null) { + graphics4 = new Graphics(this); + } + return graphics4; + } +} diff --git a/Backends/HTML5/kha/js/graphics4/Graphics.hx b/Backends/HTML5/kha/js/graphics4/Graphics.hx index 5826b84d7..89f2b5fa3 100644 --- a/Backends/HTML5/kha/js/graphics4/Graphics.hx +++ b/Backends/HTML5/kha/js/graphics4/Graphics.hx @@ -36,18 +36,38 @@ import kha.WebGLImage; class Graphics implements kha.graphics4.Graphics { private var depthTest: Bool = false; private var depthMask: Bool = false; - private var framebuffer: Dynamic; private var indicesCount: Int; - private var renderTarget: WebGLImage; + private var renderTarget: Canvas; + private var renderTargetFrameBuffer: Dynamic; + private var renderTargetTexture: Dynamic; + private var isCubeMap: Bool = false; + private var isDepthAttachment: Bool = false; private var instancedExtension: Dynamic; private var blendMinMaxExtension: Dynamic; - public function new(renderTarget: WebGLImage = null) { + public function new(renderTarget: Canvas = null) { this.renderTarget = renderTarget; + init(); instancedExtension = SystemImpl.gl.getExtension("ANGLE_instanced_arrays"); blendMinMaxExtension = SystemImpl.gl.getExtension("EXT_blend_minmax"); } + private function init() { + if (renderTarget == null) return; + isCubeMap = Std.is(renderTarget, CubeMap); + if (isCubeMap) { + var cubeMap: CubeMap = cast(renderTarget, CubeMap); + renderTargetFrameBuffer = cubeMap.frameBuffer; + renderTargetTexture = cubeMap.texture; + isDepthAttachment = cubeMap.isDepthAttachment; + } + else { + var image: WebGLImage = cast(renderTarget, WebGLImage); + renderTargetFrameBuffer = image.frameBuffer; + renderTargetTexture = image.texture; + } + } + public function begin(additionalRenderTargets: Array = null): Void { SystemImpl.gl.enable(GL.BLEND); SystemImpl.gl.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); @@ -56,10 +76,11 @@ class Graphics implements kha.graphics4.Graphics { SystemImpl.gl.viewport(0, 0, System.windowWidth(), System.windowHeight()); } else { - SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, renderTarget.frameBuffer); + SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, renderTargetFrameBuffer); + // if (isCubeMap) SystemImpl.gl.framebufferTexture(GL.FRAMEBUFFER, GL.COLOR_ATTACHMENT0, GL.TEXTURE_CUBE_MAP, renderTargetTexture, 0); // Layered SystemImpl.gl.viewport(0, 0, renderTarget.width, renderTarget.height); if (additionalRenderTargets != null) { - SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL, GL.TEXTURE_2D, renderTarget.texture, 0); + SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL, GL.TEXTURE_2D, renderTargetTexture, 0); for (i in 0...additionalRenderTargets.length) { SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, SystemImpl.drawBuffers.COLOR_ATTACHMENT0_WEBGL + i + 1, GL.TEXTURE_2D, cast(additionalRenderTargets[i], WebGLImage).texture, 0); } @@ -72,6 +93,14 @@ class Graphics implements kha.graphics4.Graphics { } } + public function beginFace(face: Int): Void { + SystemImpl.gl.enable(GL.BLEND); + SystemImpl.gl.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); + SystemImpl.gl.bindFramebuffer(GL.FRAMEBUFFER, renderTargetFrameBuffer); + SystemImpl.gl.framebufferTexture2D(GL.FRAMEBUFFER, isDepthAttachment ? GL.DEPTH_ATTACHMENT : GL.COLOR_ATTACHMENT0, GL.TEXTURE_CUBE_MAP_POSITIVE_X + face, renderTargetTexture, 0); + SystemImpl.gl.viewport(0, 0, renderTarget.width, renderTarget.height); + } + public function beginEye(eye: Int): Void { SystemImpl.gl.enable(GL.BLEND); SystemImpl.gl.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA); @@ -255,10 +284,6 @@ class Graphics implements kha.graphics4.Graphics { // return false; //} - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; - } - public function setTexture(stage: kha.graphics4.TextureUnit, texture: kha.Image): Void { if (texture == null) { SystemImpl.gl.activeTexture(GL.TEXTURE0 + cast(stage, TextureUnit).value); @@ -336,6 +361,20 @@ class Graphics implements kha.graphics4.Graphics { } } + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + if (cubeMap == null) { + SystemImpl.gl.activeTexture(GL.TEXTURE0 + cast(stage, TextureUnit).value); + SystemImpl.gl.bindTexture(GL.TEXTURE_CUBE_MAP, null); + } + else { + cubeMap.set(cast(stage, TextureUnit).value); + } + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + cubeMap.setDepth(cast(stage, TextureUnit).value); + } + public function setCullMode(mode: CullMode): Void { switch (mode) { case None: diff --git a/Backends/Java/kha/graphics4/CubeMap.hx b/Backends/Java/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Java/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Kore/kha/graphics4/CubeMap.hx b/Backends/Kore/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Kore/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Kore/kha/kore/graphics4/Graphics.hx b/Backends/Kore/kha/kore/graphics4/Graphics.hx index 29437e8f8..18d29f462 100644 --- a/Backends/Kore/kha/kore/graphics4/Graphics.hx +++ b/Backends/Kore/kha/kore/graphics4/Graphics.hx @@ -271,8 +271,12 @@ class Graphics implements kha.graphics4.Graphics { return false; } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } @:functionCode(' @@ -633,6 +637,10 @@ class Graphics implements kha.graphics4.Graphics { else renderToTexture(additionalRenderTargets); } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } diff --git a/Backends/KoreHL/kha/graphics4/CubeMap.hx b/Backends/KoreHL/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/KoreHL/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/KoreHL/kha/korehl/graphics4/Graphics.hx b/Backends/KoreHL/kha/korehl/graphics4/Graphics.hx index 69f9f0997..7af7991eb 100644 --- a/Backends/KoreHL/kha/korehl/graphics4/Graphics.hx +++ b/Backends/KoreHL/kha/korehl/graphics4/Graphics.hx @@ -182,8 +182,12 @@ class Graphics implements kha.graphics4.Graphics { return false; } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } //@:functionCode('Kore::Graphics::setStencilParameters(convertCompareMode(compareMode), convertStencilAction(bothPass), convertStencilAction(depthFail), convertStencilAction(stencilFail), referenceValue, readMask, writeMask); ') @@ -468,6 +472,10 @@ class Graphics implements kha.graphics4.Graphics { else renderToTexture(additionalRenderTargets); } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } diff --git a/Backends/Krom/kha/graphics4/CubeMap.hx b/Backends/Krom/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Krom/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Krom/kha/krom/Graphics.hx b/Backends/Krom/kha/krom/Graphics.hx index 19f7ba498..2fd784d64 100644 --- a/Backends/Krom/kha/krom/Graphics.hx +++ b/Backends/Krom/kha/krom/Graphics.hx @@ -42,6 +42,10 @@ class Graphics implements kha.graphics4.Graphics { Krom.begin(renderTarget, additionalRenderTargets); } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } @@ -126,8 +130,12 @@ class Graphics implements kha.graphics4.Graphics { indexBuffer.set(); } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } public function setTexture(stage: kha.graphics4.TextureUnit, texture: kha.Image): Void { diff --git a/Backends/Node/kha/graphics4/CubeMap.hx b/Backends/Node/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Node/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Node/kha/js/EmptyGraphics4.hx b/Backends/Node/kha/js/EmptyGraphics4.hx index 5b80a224e..7f430ea72 100644 --- a/Backends/Node/kha/js/EmptyGraphics4.hx +++ b/Backends/Node/kha/js/EmptyGraphics4.hx @@ -40,6 +40,14 @@ class EmptyGraphics4 implements Graphics { } + public function beginFace(face: Int): Void { + + } + + public function beginEye(eye: Int): Void { + + } + public function end(): Void { } @@ -116,8 +124,12 @@ class EmptyGraphics4 implements Graphics { } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } public function renderTargetsInvertedY(): Bool { diff --git a/Backends/PSM/kha/graphics4/CubeMap.hx b/Backends/PSM/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/PSM/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/PSM/kha/psm/graphics4/Graphics.hx b/Backends/PSM/kha/psm/graphics4/Graphics.hx index bd6f09a28..416bf4969 100644 --- a/Backends/PSM/kha/psm/graphics4/Graphics.hx +++ b/Backends/PSM/kha/psm/graphics4/Graphics.hx @@ -71,8 +71,12 @@ class Graphics implements kha.graphics4.Graphics { } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } public function setStencilParameters(compareMode: CompareMode, bothPass: StencilAction, depthFail: StencilAction, stencilFail: StencilAction, referenceValue: Int, readMask: Int = 0xff, writeMask: Int = 0xff): Void { @@ -214,6 +218,10 @@ class Graphics implements kha.graphics4.Graphics { } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } diff --git a/Backends/Unity/kha/graphics4/CubeMap.hx b/Backends/Unity/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/Unity/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Backends/Unity/kha/unity/Graphics.hx b/Backends/Unity/kha/unity/Graphics.hx index 61ef8b9fc..9cbd5ca29 100644 --- a/Backends/Unity/kha/unity/Graphics.hx +++ b/Backends/Unity/kha/unity/Graphics.hx @@ -50,6 +50,10 @@ class Graphics implements kha.graphics4.Graphics { } } + public function beginFace(face: Int): Void { + + } + public function beginEye(eye: Int): Void { } @@ -139,8 +143,12 @@ class Graphics implements kha.graphics4.Graphics { } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } public function renderTargetsInvertedY(): Bool { diff --git a/Backends/WPF/kha/graphics4/CubeMap.hx b/Backends/WPF/kha/graphics4/CubeMap.hx new file mode 100644 index 000000000..68bfd55e9 --- /dev/null +++ b/Backends/WPF/kha/graphics4/CubeMap.hx @@ -0,0 +1,34 @@ +package kha.graphics4; + +import haxe.io.Bytes; + +class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = null, depthStencil: DepthStencilFormat = null): CubeMap { + return null; + } + + public function set(stage: Int): Void { + + } + + public function setDepth(stage: Int): Void { + + } + + public function unload(): Void { } + public function lock(level: Int = 0): Bytes { return null; } + public function unlock(): Void { } + + public var width(get, null): Int; + private function get_width(): Int { return 0; } + public var height(get, null): Int; + private function get_height(): Int { return 0; } + + public var g1(get, null): kha.graphics1.Graphics; + private function get_g1(): kha.graphics1.Graphics { return null; } + public var g2(get, null): kha.graphics2.Graphics; + private function get_g2(): kha.graphics2.Graphics { return null; } + public var g4(get, null): kha.graphics4.Graphics; + private function get_g4(): kha.graphics4.Graphics { return null; } +} diff --git a/Sources/kha/graphics1/Graphics4.hx b/Sources/kha/graphics1/Graphics4.hx index bec4e8166..98a25539b 100644 --- a/Sources/kha/graphics1/Graphics4.hx +++ b/Sources/kha/graphics1/Graphics4.hx @@ -29,6 +29,14 @@ class Graphics4 implements kha.graphics4.Graphics { g1.begin(); } + public function beginFace(face: Int): Void { + + } + + public function beginEye(eye: Int): Void { + + } + public function end(): Void { g1.end(); } @@ -85,8 +93,12 @@ class Graphics4 implements kha.graphics4.Graphics { } - public function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap { - return null; + public function setCubeMap(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + + } + + public function setCubeMapDepth(stage: kha.graphics4.TextureUnit, cubeMap: kha.graphics4.CubeMap): Void { + } public function renderTargetsInvertedY(): Bool { diff --git a/Sources/kha/graphics4/CubeMap.hx b/Sources/kha/graphics4/CubeMap.hx index d3b5e6951..b261fd33a 100644 --- a/Sources/kha/graphics4/CubeMap.hx +++ b/Sources/kha/graphics4/CubeMap.hx @@ -2,8 +2,22 @@ package kha.graphics4; import haxe.io.Bytes; -interface CubeMap { - var size(get, null): Int; - function lock(): Bytes; - function unlock(): Void; +extern class CubeMap implements Canvas implements Resource { + + public static function createRenderTarget(size: Int, format: TextureFormat = TextureFormat.RGBA32, depthStencil: DepthStencilFormat = NoDepthAndStencil): CubeMap; + + public function unload(): Void; + public function lock(level: Int = 0): Bytes; + public function unlock(): Void; + + public var size(get, null): Int; + public var width(get, null): Int; + public var height(get, null): Int; + + public var g1(get, null): kha.graphics1.Graphics; + public var g2(get, null): kha.graphics2.Graphics; + public var g4(get, null): kha.graphics4.Graphics; + + public function set(stage: Int): Void; + public function setDepth(stage: Int): Void; } diff --git a/Sources/kha/graphics4/Graphics.hx b/Sources/kha/graphics4/Graphics.hx index a7c548e03..f0b1ac564 100644 --- a/Sources/kha/graphics4/Graphics.hx +++ b/Sources/kha/graphics4/Graphics.hx @@ -14,6 +14,7 @@ import kha.Video; interface Graphics { function begin(additionalRenderTargets: Array = null): Void; + function beginFace(face: Int): Void; function beginEye(eye: Int): Void; function end(): Void; @@ -34,9 +35,10 @@ interface Graphics { function setTextureDepth(unit: TextureUnit, texture: Image): Void; function setVideoTexture(unit: TextureUnit, texture: Video): Void; function setTextureParameters(texunit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing, minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void; + function setCubeMap(unit: TextureUnit, cubeMap: CubeMap): Void; + function setCubeMapDepth(unit: TextureUnit, cubeMap: CubeMap): Void; //function maxTextureSize(): Int; //function supportsNonPow2Textures(): Bool; - function createCubeMap(size: Int, format: TextureFormat, usage: Usage, canRead: Bool = false): CubeMap; function renderTargetsInvertedY(): Bool; function instancedRenderingAvailable(): Bool;