forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
15
Kha/Sources/kha/graphics4/BlendingFactor.hx
Normal file
15
Kha/Sources/kha/graphics4/BlendingFactor.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract BlendingFactor(Int) to Int {
|
||||
var Undefined = 0;
|
||||
var BlendOne = 1;
|
||||
var BlendZero = 2;
|
||||
var SourceAlpha = 3;
|
||||
var DestinationAlpha = 4;
|
||||
var InverseSourceAlpha = 5;
|
||||
var InverseDestinationAlpha = 6;
|
||||
var SourceColor = 7;
|
||||
var DestinationColor = 8;
|
||||
var InverseSourceColor = 9;
|
||||
var InverseDestinationColor = 10;
|
||||
}
|
9
Kha/Sources/kha/graphics4/BlendingOperation.hx
Normal file
9
Kha/Sources/kha/graphics4/BlendingOperation.hx
Normal file
@ -0,0 +1,9 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract BlendingOperation(Int) to Int {
|
||||
var Add = 0;
|
||||
var Subtract = 1;
|
||||
var ReverseSubtract = 2;
|
||||
var Min = 3;
|
||||
var Max = 4;
|
||||
}
|
12
Kha/Sources/kha/graphics4/CompareMode.hx
Normal file
12
Kha/Sources/kha/graphics4/CompareMode.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract CompareMode(Int) to Int {
|
||||
var Always = 0;
|
||||
var Never = 1;
|
||||
var Equal = 2;
|
||||
var NotEqual = 3;
|
||||
var Less = 4;
|
||||
var LessEqual = 5;
|
||||
var Greater = 6;
|
||||
var GreaterEqual = 7;
|
||||
}
|
3
Kha/Sources/kha/graphics4/ConstantLocation.hx
Normal file
3
Kha/Sources/kha/graphics4/ConstantLocation.hx
Normal file
@ -0,0 +1,3 @@
|
||||
package kha.graphics4;
|
||||
|
||||
interface ConstantLocation {}
|
19
Kha/Sources/kha/graphics4/CubeMap.hx
Normal file
19
Kha/Sources/kha/graphics4/CubeMap.hx
Normal file
@ -0,0 +1,19 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
|
||||
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 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;
|
||||
}
|
7
Kha/Sources/kha/graphics4/CullMode.hx
Normal file
7
Kha/Sources/kha/graphics4/CullMode.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract CullMode(Int) to Int {
|
||||
var Clockwise = 0;
|
||||
var CounterClockwise = 1;
|
||||
var None = 2;
|
||||
}
|
15
Kha/Sources/kha/graphics4/DepthStencilFormat.hx
Normal file
15
Kha/Sources/kha/graphics4/DepthStencilFormat.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract DepthStencilFormat(Int) to Int {
|
||||
var NoDepthAndStencil = 0;
|
||||
var DepthOnly = 1;
|
||||
var DepthAutoStencilAuto = 2;
|
||||
// This is platform specific, use with care!
|
||||
var Depth24Stencil8 = 3;
|
||||
var Depth32Stencil8 = 4;
|
||||
var Depth16 = 5;
|
||||
// var StencilOnlyIndex1 = 5;
|
||||
// var StencilOnlyIndex4 = 6;
|
||||
// var StencilOnlyIndex8 = 7;
|
||||
// var StencilOnlyIndex16 = 8;
|
||||
}
|
13
Kha/Sources/kha/graphics4/FragmentShader.hx
Normal file
13
Kha/Sources/kha/graphics4/FragmentShader.hx
Normal file
@ -0,0 +1,13 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
extern class FragmentShader {
|
||||
public function new(sources: Array<Blob>, files: Array<String>);
|
||||
public function delete(): Void;
|
||||
|
||||
/**
|
||||
Beware: This function is not portable.
|
||||
**/
|
||||
public static function fromSource(source: String): FragmentShader;
|
||||
}
|
16
Kha/Sources/kha/graphics4/GeometryShader.hx
Normal file
16
Kha/Sources/kha/graphics4/GeometryShader.hx
Normal file
@ -0,0 +1,16 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
#if cpp
|
||||
extern class GeometryShader {
|
||||
public function new(sources: Array<Blob>);
|
||||
public function delete(): Void;
|
||||
}
|
||||
#else
|
||||
class GeometryShader {
|
||||
public function new(sources: Array<Blob>) {}
|
||||
|
||||
public function delete(): Void {}
|
||||
}
|
||||
#end
|
77
Kha/Sources/kha/graphics4/Graphics.hx
Normal file
77
Kha/Sources/kha/graphics4/Graphics.hx
Normal file
@ -0,0 +1,77 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.arrays.Float32Array;
|
||||
import kha.arrays.Int32Array;
|
||||
import kha.Color;
|
||||
import kha.FastFloat;
|
||||
import kha.Image;
|
||||
import kha.math.FastMatrix3;
|
||||
import kha.math.FastMatrix4;
|
||||
import kha.math.FastVector2;
|
||||
import kha.math.FastVector3;
|
||||
import kha.math.FastVector4;
|
||||
import kha.Video;
|
||||
|
||||
interface Graphics {
|
||||
function begin(additionalRenderTargets: Array<Canvas> = null): Void;
|
||||
function beginFace(face: Int): Void;
|
||||
function beginEye(eye: Int): Void;
|
||||
function end(): Void;
|
||||
|
||||
function vsynced(): Bool;
|
||||
function refreshRate(): Int;
|
||||
|
||||
function clear(?color: Color, ?depth: Float, ?stencil: Int): Void;
|
||||
|
||||
function viewport(x: Int, y: Int, width: Int, height: Int): Void;
|
||||
function scissor(x: Int, y: Int, width: Int, height: Int): Void;
|
||||
|
||||
function disableScissor(): Void;
|
||||
function setVertexBuffer(vertexBuffer: VertexBuffer): Void;
|
||||
function setVertexBuffers(vertexBuffers: Array<kha.graphics4.VertexBuffer>): Void;
|
||||
function setIndexBuffer(indexBuffer: IndexBuffer): Void;
|
||||
|
||||
function setTexture(unit: TextureUnit, texture: Image): Void;
|
||||
function setTextureDepth(unit: TextureUnit, texture: Image): Void;
|
||||
function setTextureArray(unit: TextureUnit, texture: Image): Void;
|
||||
function setVideoTexture(unit: TextureUnit, texture: Video): Void;
|
||||
function setImageTexture(unit: TextureUnit, texture: Image): Void;
|
||||
function setTextureParameters(texunit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing, minificationFilter: TextureFilter,
|
||||
magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void;
|
||||
function setTexture3DParameters(texunit: TextureUnit, uAddressing: TextureAddressing, vAddressing: TextureAddressing, wAddressing: TextureAddressing,
|
||||
minificationFilter: TextureFilter, magnificationFilter: TextureFilter, mipmapFilter: MipMapFilter): Void;
|
||||
function setTextureCompareMode(texunit: TextureUnit, enabled: Bool): Void;
|
||||
function setCubeMapCompareMode(texunit: TextureUnit, enabled: Bool): Void;
|
||||
function setCubeMap(unit: TextureUnit, cubeMap: CubeMap): Void;
|
||||
function setCubeMapDepth(unit: TextureUnit, cubeMap: CubeMap): Void;
|
||||
function maxBoundTextures(): Int;
|
||||
// function maxTextureSize(): Int;
|
||||
// function supportsNonPow2Textures(): Bool;
|
||||
function setStencilReferenceValue(value: Int): Void;
|
||||
|
||||
function instancedRenderingAvailable(): Bool;
|
||||
|
||||
function setPipeline(pipeline: PipelineState): Void;
|
||||
|
||||
function setBool(location: ConstantLocation, value: Bool): Void;
|
||||
function setInt(location: ConstantLocation, value: Int): Void;
|
||||
function setInt2(location: ConstantLocation, value1: Int, value2: Int): Void;
|
||||
function setInt3(location: ConstantLocation, value1: Int, value2: Int, value3: Int): Void;
|
||||
function setInt4(location: ConstantLocation, value1: Int, value2: Int, value3: Int, value4: Int): Void;
|
||||
function setInts(location: ConstantLocation, ints: Int32Array): Void;
|
||||
function setFloat(location: ConstantLocation, value: FastFloat): Void;
|
||||
function setFloat2(location: ConstantLocation, value1: FastFloat, value2: FastFloat): Void;
|
||||
function setFloat3(location: ConstantLocation, value1: FastFloat, value2: FastFloat, value3: FastFloat): Void;
|
||||
function setFloat4(location: ConstantLocation, value1: FastFloat, value2: FastFloat, value3: FastFloat, value4: FastFloat): Void;
|
||||
function setFloats(location: ConstantLocation, floats: Float32Array): Void;
|
||||
function setVector2(location: ConstantLocation, value: FastVector2): Void;
|
||||
function setVector3(location: ConstantLocation, value: FastVector3): Void;
|
||||
function setVector4(location: ConstantLocation, value: FastVector4): Void;
|
||||
function setMatrix(location: ConstantLocation, value: FastMatrix4): Void;
|
||||
function setMatrix3(location: ConstantLocation, value: FastMatrix3): Void;
|
||||
|
||||
function drawIndexedVertices(start: Int = 0, count: Int = -1): Void;
|
||||
function drawIndexedVerticesInstanced(instanceCount: Int, start: Int = 0, count: Int = -1): Void;
|
||||
|
||||
function flush(): Void;
|
||||
}
|
1253
Kha/Sources/kha/graphics4/Graphics2.hx
Normal file
1253
Kha/Sources/kha/graphics4/Graphics2.hx
Normal file
File diff suppressed because it is too large
Load Diff
12
Kha/Sources/kha/graphics4/IndexBuffer.hx
Normal file
12
Kha/Sources/kha/graphics4/IndexBuffer.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.arrays.Uint32Array;
|
||||
|
||||
extern class IndexBuffer {
|
||||
public function new(indexCount: Int, usage: Usage, canRead: Bool = false);
|
||||
public function delete(): Void;
|
||||
public function lock(?start: Int, ?count: Int): Uint32Array;
|
||||
public function unlock(?count: Int): Void;
|
||||
public function set(): Void;
|
||||
public function count(): Int;
|
||||
}
|
7
Kha/Sources/kha/graphics4/MipMapFilter.hx
Normal file
7
Kha/Sources/kha/graphics4/MipMapFilter.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract MipMapFilter(Int) to Int {
|
||||
var NoMipFilter = 0;
|
||||
var PointMipFilter = 1;
|
||||
var LinearMipFilter = 2; // linear texture filter + linear mip filter -> trilinear filter
|
||||
}
|
9
Kha/Sources/kha/graphics4/PipelineState.hx
Normal file
9
Kha/Sources/kha/graphics4/PipelineState.hx
Normal file
@ -0,0 +1,9 @@
|
||||
package kha.graphics4;
|
||||
|
||||
extern class PipelineState extends PipelineStateBase {
|
||||
public function new();
|
||||
public function delete(): Void;
|
||||
public function compile(): Void;
|
||||
public function getConstantLocation(name: String): ConstantLocation;
|
||||
public function getTextureUnit(name: String): TextureUnit;
|
||||
}
|
148
Kha/Sources/kha/graphics4/PipelineStateBase.hx
Normal file
148
Kha/Sources/kha/graphics4/PipelineStateBase.hx
Normal file
@ -0,0 +1,148 @@
|
||||
package kha.graphics4;
|
||||
|
||||
class PipelineStateBase {
|
||||
public function new() {
|
||||
inputLayout = null;
|
||||
vertexShader = null;
|
||||
fragmentShader = null;
|
||||
geometryShader = null;
|
||||
tessellationControlShader = null;
|
||||
tessellationEvaluationShader = null;
|
||||
|
||||
cullMode = CullMode.None;
|
||||
|
||||
depthWrite = false;
|
||||
depthMode = CompareMode.Always;
|
||||
|
||||
stencilFrontMode = CompareMode.Always;
|
||||
stencilFrontBothPass = StencilAction.Keep;
|
||||
stencilFrontDepthFail = StencilAction.Keep;
|
||||
stencilFrontFail = StencilAction.Keep;
|
||||
|
||||
stencilBackMode = CompareMode.Always;
|
||||
stencilBackBothPass = StencilAction.Keep;
|
||||
stencilBackDepthFail = StencilAction.Keep;
|
||||
stencilBackFail = StencilAction.Keep;
|
||||
|
||||
stencilReferenceValue = Static(0);
|
||||
stencilReadMask = 0xff;
|
||||
stencilWriteMask = 0xff;
|
||||
|
||||
blendSource = BlendingFactor.BlendOne;
|
||||
blendDestination = BlendingFactor.BlendZero;
|
||||
blendOperation = BlendingOperation.Add;
|
||||
alphaBlendSource = BlendingFactor.BlendOne;
|
||||
alphaBlendDestination = BlendingFactor.BlendZero;
|
||||
alphaBlendOperation = BlendingOperation.Add;
|
||||
|
||||
colorWriteMasksRed = [];
|
||||
colorWriteMasksGreen = [];
|
||||
colorWriteMasksBlue = [];
|
||||
colorWriteMasksAlpha = [];
|
||||
for (i in 0...8)
|
||||
colorWriteMasksRed.push(true);
|
||||
for (i in 0...8)
|
||||
colorWriteMasksGreen.push(true);
|
||||
for (i in 0...8)
|
||||
colorWriteMasksBlue.push(true);
|
||||
for (i in 0...8)
|
||||
colorWriteMasksAlpha.push(true);
|
||||
|
||||
colorAttachmentCount = 1;
|
||||
colorAttachments = [];
|
||||
for (i in 0...8)
|
||||
colorAttachments.push(TextureFormat.RGBA32);
|
||||
|
||||
depthStencilAttachment = DepthStencilFormat.NoDepthAndStencil;
|
||||
|
||||
conservativeRasterization = false;
|
||||
}
|
||||
|
||||
public var inputLayout: Array<VertexStructure>;
|
||||
public var vertexShader: VertexShader;
|
||||
public var fragmentShader: FragmentShader;
|
||||
public var geometryShader: GeometryShader;
|
||||
public var tessellationControlShader: TessellationControlShader;
|
||||
public var tessellationEvaluationShader: TessellationEvaluationShader;
|
||||
|
||||
public var cullMode: CullMode;
|
||||
|
||||
public var depthWrite: Bool;
|
||||
public var depthMode: CompareMode;
|
||||
|
||||
public var stencilFrontMode: CompareMode;
|
||||
public var stencilFrontBothPass: StencilAction;
|
||||
public var stencilFrontDepthFail: StencilAction;
|
||||
public var stencilFrontFail: StencilAction;
|
||||
|
||||
public var stencilBackMode: CompareMode;
|
||||
public var stencilBackBothPass: StencilAction;
|
||||
public var stencilBackDepthFail: StencilAction;
|
||||
public var stencilBackFail: StencilAction;
|
||||
|
||||
public var stencilReferenceValue: StencilValue;
|
||||
public var stencilReadMask: Int;
|
||||
public var stencilWriteMask: Int;
|
||||
|
||||
// One, Zero deactivates blending
|
||||
public var blendSource: BlendingFactor;
|
||||
public var blendDestination: BlendingFactor;
|
||||
public var blendOperation: BlendingOperation;
|
||||
public var alphaBlendSource: BlendingFactor;
|
||||
public var alphaBlendDestination: BlendingFactor;
|
||||
public var alphaBlendOperation: BlendingOperation;
|
||||
|
||||
public var colorWriteMask(never, set): Bool;
|
||||
public var colorWriteMaskRed(get, set): Bool;
|
||||
public var colorWriteMaskGreen(get, set): Bool;
|
||||
public var colorWriteMaskBlue(get, set): Bool;
|
||||
public var colorWriteMaskAlpha(get, set): Bool;
|
||||
|
||||
public var colorWriteMasksRed: Array<Bool>;
|
||||
public var colorWriteMasksGreen: Array<Bool>;
|
||||
public var colorWriteMasksBlue: Array<Bool>;
|
||||
public var colorWriteMasksAlpha: Array<Bool>;
|
||||
|
||||
public var colorAttachmentCount: Int;
|
||||
public var colorAttachments: Array<TextureFormat>;
|
||||
|
||||
public var depthStencilAttachment: DepthStencilFormat;
|
||||
|
||||
inline function set_colorWriteMask(value: Bool): Bool {
|
||||
return colorWriteMaskRed = colorWriteMaskBlue = colorWriteMaskGreen = colorWriteMaskAlpha = value;
|
||||
}
|
||||
|
||||
inline function get_colorWriteMaskRed(): Bool {
|
||||
return colorWriteMasksRed[0];
|
||||
}
|
||||
|
||||
inline function set_colorWriteMaskRed(value: Bool): Bool {
|
||||
return colorWriteMasksRed[0] = value;
|
||||
}
|
||||
|
||||
inline function get_colorWriteMaskGreen(): Bool {
|
||||
return colorWriteMasksGreen[0];
|
||||
}
|
||||
|
||||
inline function set_colorWriteMaskGreen(value: Bool): Bool {
|
||||
return colorWriteMasksGreen[0] = value;
|
||||
}
|
||||
|
||||
inline function get_colorWriteMaskBlue(): Bool {
|
||||
return colorWriteMasksBlue[0];
|
||||
}
|
||||
|
||||
inline function set_colorWriteMaskBlue(value: Bool): Bool {
|
||||
return colorWriteMasksBlue[0] = value;
|
||||
}
|
||||
|
||||
inline function get_colorWriteMaskAlpha(): Bool {
|
||||
return colorWriteMasksAlpha[0];
|
||||
}
|
||||
|
||||
inline function set_colorWriteMaskAlpha(value: Bool): Bool {
|
||||
return colorWriteMasksAlpha[0] = value;
|
||||
}
|
||||
|
||||
public var conservativeRasterization: Bool;
|
||||
}
|
12
Kha/Sources/kha/graphics4/StencilAction.hx
Normal file
12
Kha/Sources/kha/graphics4/StencilAction.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract StencilAction(Int) to Int {
|
||||
var Keep = 0;
|
||||
var Zero = 1;
|
||||
var Replace = 2;
|
||||
var Increment = 3;
|
||||
var IncrementWrap = 4;
|
||||
var Decrement = 5;
|
||||
var DecrementWrap = 6;
|
||||
var Invert = 7;
|
||||
}
|
6
Kha/Sources/kha/graphics4/StencilValue.hx
Normal file
6
Kha/Sources/kha/graphics4/StencilValue.hx
Normal file
@ -0,0 +1,6 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum StencilValue {
|
||||
Dynamic;
|
||||
Static(value: Int);
|
||||
}
|
16
Kha/Sources/kha/graphics4/TessellationControlShader.hx
Normal file
16
Kha/Sources/kha/graphics4/TessellationControlShader.hx
Normal file
@ -0,0 +1,16 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
#if cpp
|
||||
extern class TessellationControlShader {
|
||||
public function new(sources: Array<Blob>, files: Array<String>);
|
||||
public function delete();
|
||||
}
|
||||
#else
|
||||
class TessellationControlShader {
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {}
|
||||
|
||||
public function delete(): Void {}
|
||||
}
|
||||
#end
|
16
Kha/Sources/kha/graphics4/TessellationEvaluationShader.hx
Normal file
16
Kha/Sources/kha/graphics4/TessellationEvaluationShader.hx
Normal file
@ -0,0 +1,16 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
#if cpp
|
||||
extern class TessellationEvaluationShader {
|
||||
public function new(sources: Array<Blob>, files: Array<String>);
|
||||
public function delete();
|
||||
}
|
||||
#else
|
||||
class TessellationEvaluationShader {
|
||||
public function new(sources: Array<Blob>, files: Array<String>) {}
|
||||
|
||||
public function delete(): Void {}
|
||||
}
|
||||
#end
|
6
Kha/Sources/kha/graphics4/TexDir.hx
Normal file
6
Kha/Sources/kha/graphics4/TexDir.hx
Normal file
@ -0,0 +1,6 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract TexDir(Int) to Int {
|
||||
var U = 0;
|
||||
var V = 1;
|
||||
}
|
7
Kha/Sources/kha/graphics4/TextureAddressing.hx
Normal file
7
Kha/Sources/kha/graphics4/TextureAddressing.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract TextureAddressing(Int) to Int {
|
||||
var Repeat = 0;
|
||||
var Mirror = 1;
|
||||
var Clamp = 2;
|
||||
}
|
7
Kha/Sources/kha/graphics4/TextureFilter.hx
Normal file
7
Kha/Sources/kha/graphics4/TextureFilter.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract TextureFilter(Int) to Int {
|
||||
var PointFilter = 0;
|
||||
var LinearFilter = 1;
|
||||
var AnisotropicFilter = 2;
|
||||
}
|
11
Kha/Sources/kha/graphics4/TextureFormat.hx
Normal file
11
Kha/Sources/kha/graphics4/TextureFormat.hx
Normal file
@ -0,0 +1,11 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract TextureFormat(Int) to Int {
|
||||
var RGBA32 = 0;
|
||||
var L8 = 1;
|
||||
var RGBA128 = 2; // Floats
|
||||
var DEPTH16 = 3;
|
||||
var RGBA64 = 4; // Half floats
|
||||
var A32 = 5; // Float
|
||||
var A16 = 6; // Half float
|
||||
}
|
3
Kha/Sources/kha/graphics4/TextureUnit.hx
Normal file
3
Kha/Sources/kha/graphics4/TextureUnit.hx
Normal file
@ -0,0 +1,3 @@
|
||||
package kha.graphics4;
|
||||
|
||||
interface TextureUnit {}
|
7
Kha/Sources/kha/graphics4/Usage.hx
Normal file
7
Kha/Sources/kha/graphics4/Usage.hx
Normal file
@ -0,0 +1,7 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract Usage(Int) to Int {
|
||||
var StaticUsage = 0;
|
||||
var DynamicUsage = 1; // Just calling it Dynamic causes problems in C++
|
||||
var ReadableUsage = 2;
|
||||
}
|
12
Kha/Sources/kha/graphics4/VertexBuffer.hx
Normal file
12
Kha/Sources/kha/graphics4/VertexBuffer.hx
Normal file
@ -0,0 +1,12 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.arrays.Float32Array;
|
||||
|
||||
extern class VertexBuffer {
|
||||
public function new(vertexCount: Int, structure: VertexStructure, usage: Usage, instanceDataStepRate: Int = 0, canRead: Bool = false);
|
||||
public function delete(): Void;
|
||||
public function lock(?start: Int, ?count: Int): Float32Array;
|
||||
public function unlock(?count: Int): Void;
|
||||
public function count(): Int;
|
||||
public function stride(): Int;
|
||||
}
|
94
Kha/Sources/kha/graphics4/VertexData.hx
Normal file
94
Kha/Sources/kha/graphics4/VertexData.hx
Normal file
@ -0,0 +1,94 @@
|
||||
package kha.graphics4;
|
||||
|
||||
enum abstract VertexData(Int) {
|
||||
var Float32_1X = 0;
|
||||
var Float32_2X = 1;
|
||||
var Float32_3X = 2;
|
||||
var Float32_4X = 3;
|
||||
var Float32_4X4 = 4;
|
||||
var Int8_1X = 5;
|
||||
var UInt8_1X = 6;
|
||||
var Int8_1X_Normalized = 7;
|
||||
var UInt8_1X_Normalized = 8;
|
||||
var Int8_2X = 9;
|
||||
var UInt8_2X = 10;
|
||||
var Int8_2X_Normalized = 11;
|
||||
var UInt8_2X_Normalized = 12;
|
||||
var Int8_4X = 13;
|
||||
var UInt8_4X = 14;
|
||||
var Int8_4X_Normalized = 15;
|
||||
var UInt8_4X_Normalized = 16;
|
||||
var Int16_1X = 17;
|
||||
var UInt16_1X = 18;
|
||||
var Int16_1X_Normalized = 19;
|
||||
var UInt16_1X_Normalized = 20;
|
||||
var Int16_2X = 21;
|
||||
var UInt16_2X = 22;
|
||||
var Int16_2X_Normalized = 23;
|
||||
var UInt16_2X_Normalized = 24;
|
||||
var Int16_4X = 25;
|
||||
var UInt16_4X = 26;
|
||||
var Int16_4X_Normalized = 27;
|
||||
var UInt16_4X_Normalized = 28;
|
||||
var Int32_1X = 29;
|
||||
var UInt32_1X = 30;
|
||||
var Int32_2X = 31;
|
||||
var UInt32_2X = 32;
|
||||
var Int32_3X = 33;
|
||||
var UInt32_3X = 34;
|
||||
var Int32_4X = 35;
|
||||
var UInt32_4X = 36;
|
||||
// deprecated
|
||||
var Float1 = Float32_1X;
|
||||
var Float2 = Float32_2X;
|
||||
var Float3 = Float32_3X;
|
||||
var Float4 = Float32_4X;
|
||||
var Float4x4 = Float32_4X4;
|
||||
var Short2Norm = Int16_2X_Normalized;
|
||||
var Short4Norm = Int16_4X_Normalized;
|
||||
|
||||
/**
|
||||
Return the element size of the given vertex data type in bytes.
|
||||
**/
|
||||
public static inline function getStride(vertexData: VertexData): Int {
|
||||
return switch (vertexData) {
|
||||
case Float32_1X: 4 * 1;
|
||||
case Float32_2X: 4 * 2;
|
||||
case Float32_3X: 4 * 3;
|
||||
case Float32_4X: 4 * 4;
|
||||
case Float32_4X4: 4 * 4 * 4;
|
||||
case Int8_1X: 1;
|
||||
case UInt8_1X: 1;
|
||||
case Int8_1X_Normalized: 1;
|
||||
case UInt8_1X_Normalized: 1;
|
||||
case Int8_2X: 1 * 2;
|
||||
case UInt8_2X: 1 * 2;
|
||||
case Int8_2X_Normalized: 1 * 2;
|
||||
case UInt8_2X_Normalized: 1 * 2;
|
||||
case Int8_4X: 1 * 4;
|
||||
case UInt8_4X: 1 * 4;
|
||||
case Int8_4X_Normalized: 1 * 4;
|
||||
case UInt8_4X_Normalized: 1 * 4;
|
||||
case Int16_1X: 2 * 1;
|
||||
case UInt16_1X: 2 * 1;
|
||||
case Int16_1X_Normalized: 2 * 1;
|
||||
case UInt16_1X_Normalized: 2 * 1;
|
||||
case Int16_2X: 2 * 2;
|
||||
case UInt16_2X: 2 * 2;
|
||||
case Int16_2X_Normalized: 2 * 2;
|
||||
case UInt16_2X_Normalized: 2 * 2;
|
||||
case Int16_4X: 2 * 4;
|
||||
case UInt16_4X: 2 * 4;
|
||||
case Int16_4X_Normalized: 2 * 4;
|
||||
case UInt16_4X_Normalized: 2 * 4;
|
||||
case Int32_1X: 4 * 1;
|
||||
case UInt32_1X: 4 * 1;
|
||||
case Int32_2X: 4 * 2;
|
||||
case UInt32_2X: 4 * 2;
|
||||
case Int32_3X: 4 * 3;
|
||||
case UInt32_3X: 4 * 3;
|
||||
case Int32_4X: 4 * 4;
|
||||
case UInt32_4X: 4 * 4;
|
||||
}
|
||||
}
|
||||
}
|
11
Kha/Sources/kha/graphics4/VertexElement.hx
Normal file
11
Kha/Sources/kha/graphics4/VertexElement.hx
Normal file
@ -0,0 +1,11 @@
|
||||
package kha.graphics4;
|
||||
|
||||
class VertexElement {
|
||||
public var name: String;
|
||||
public var data: VertexData;
|
||||
|
||||
public function new(name: String, data: VertexData) {
|
||||
this.name = name;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
13
Kha/Sources/kha/graphics4/VertexShader.hx
Normal file
13
Kha/Sources/kha/graphics4/VertexShader.hx
Normal file
@ -0,0 +1,13 @@
|
||||
package kha.graphics4;
|
||||
|
||||
import kha.Blob;
|
||||
|
||||
extern class VertexShader {
|
||||
public function new(sources: Array<Blob>, files: Array<String>);
|
||||
public function delete(): Void;
|
||||
|
||||
/**
|
||||
Beware: This function is not portable.
|
||||
**/
|
||||
public static function fromSource(source: String): VertexShader;
|
||||
}
|
70
Kha/Sources/kha/graphics4/VertexStructure.hx
Normal file
70
Kha/Sources/kha/graphics4/VertexStructure.hx
Normal file
@ -0,0 +1,70 @@
|
||||
package kha.graphics4;
|
||||
|
||||
class VertexStructure {
|
||||
public var elements: Array<VertexElement>;
|
||||
public var instanced: Bool;
|
||||
|
||||
public function new() {
|
||||
elements = new Array<VertexElement>();
|
||||
instanced = false;
|
||||
}
|
||||
|
||||
public function add(name: String, data: VertexData) {
|
||||
elements.push(new VertexElement(name, data));
|
||||
}
|
||||
|
||||
@:keep
|
||||
public function size(): Int {
|
||||
return elements.length;
|
||||
}
|
||||
|
||||
public function byteSize(): Int {
|
||||
var byteSize = 0;
|
||||
|
||||
for (i in 0...elements.length) {
|
||||
byteSize += dataByteSize(elements[i].data);
|
||||
}
|
||||
|
||||
return byteSize;
|
||||
}
|
||||
|
||||
public static function dataByteSize(data: VertexData): Int {
|
||||
switch (data) {
|
||||
case Float32_1X:
|
||||
return 1 * 4;
|
||||
case Float32_2X:
|
||||
return 2 * 4;
|
||||
case Float32_3X:
|
||||
return 3 * 4;
|
||||
case Float32_4X:
|
||||
return 4 * 4;
|
||||
case Float32_4X4:
|
||||
return 4 * 4 * 4;
|
||||
case Int8_1X, UInt8_1X, Int8_1X_Normalized, UInt8_1X_Normalized:
|
||||
return 1 * 1;
|
||||
case Int8_2X, UInt8_2X, Int8_2X_Normalized, UInt8_2X_Normalized:
|
||||
return 2 * 1;
|
||||
case Int8_4X, UInt8_4X, Int8_4X_Normalized, UInt8_4X_Normalized:
|
||||
return 4 * 1;
|
||||
case Int16_1X, UInt16_1X, Int16_1X_Normalized, UInt16_1X_Normalized:
|
||||
return 1 * 2;
|
||||
case Int16_2X, UInt16_2X, Int16_2X_Normalized, UInt16_2X_Normalized:
|
||||
return 2 * 2;
|
||||
case Int16_4X, UInt16_4X, Int16_4X_Normalized, UInt16_4X_Normalized:
|
||||
return 4 * 2;
|
||||
case Int32_1X, UInt32_1X:
|
||||
return 1 * 4;
|
||||
case Int32_2X, UInt32_2X:
|
||||
return 2 * 4;
|
||||
case Int32_3X, UInt32_3X:
|
||||
return 3 * 4;
|
||||
case Int32_4X, UInt32_4X:
|
||||
return 4 * 4;
|
||||
}
|
||||
}
|
||||
|
||||
@:keep
|
||||
public function get(index: Int): VertexElement {
|
||||
return elements[index];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user