diff --git a/lime/app/Application.hx b/lime/app/Application.hx index 8f510b9f7..e79a5a75d 100644 --- a/lime/app/Application.hx +++ b/lime/app/Application.hx @@ -57,6 +57,8 @@ class Application implements IKeyEventListener implements IMouseEventListener im WindowEventManager.addEventListener (this); var window = new Window (this); + window.create (config); + var renderer = new Renderer (window); } @@ -66,6 +68,8 @@ class Application implements IKeyEventListener implements IMouseEventListener im #if (cpp || neko) return lime_application_exec (handle); + #else + return 0; #end } diff --git a/lime/app/Config.hx b/lime/app/Config.hx index 62565c284..4893506e3 100644 --- a/lime/app/Config.hx +++ b/lime/app/Config.hx @@ -4,8 +4,12 @@ package lime.app; typedef Config = { @:optional var antialiasing:Int; + @:optional var background:Null; @:optional var borderless:Bool; @:optional var depthBuffer:Bool; + #if js + @:optional var element:js.html.HtmlElement; + #end @:optional var fps:Int; @:optional var fullscreen:Bool; @:optional var height:Int; diff --git a/lime/graphics/Renderer.hx b/lime/graphics/Renderer.hx index 5d8bebcd0..3e8fc6e1a 100644 --- a/lime/graphics/Renderer.hx +++ b/lime/graphics/Renderer.hx @@ -26,7 +26,9 @@ class Renderer { public static function flip ():Void { + #if (cpp || neko) lime_renderer_flip (instance.handle); + #end } diff --git a/lime/graphics/opengl/GL.hx b/lime/graphics/opengl/GL.hx index c101e939b..8598ffb77 100644 --- a/lime/graphics/opengl/GL.hx +++ b/lime/graphics/opengl/GL.hx @@ -1,6 +1,6 @@ package lime.graphics.opengl; -//import lime.utils.compat.Matrix3D; + import lime.utils.ArrayBuffer; import lime.utils.ArrayBufferView; import lime.utils.Float32Array; @@ -8,1301 +8,2018 @@ import lime.utils.IMemoryRange; import lime.utils.Int32Array; import lime.system.System; +#if js +import js.html.webgl.RenderingContext; +#end + +@:allow(lime.ui.Window) class GL { - - /* ClearBufferMask */ - public static inline var DEPTH_BUFFER_BIT = 0x00000100; - public static inline var STENCIL_BUFFER_BIT = 0x00000400; - public static inline var COLOR_BUFFER_BIT = 0x00004000; - - /* BeginMode */ - public static inline var POINTS = 0x0000; - public static inline var LINES = 0x0001; - public static inline var LINE_LOOP = 0x0002; - public static inline var LINE_STRIP = 0x0003; - public static inline var TRIANGLES = 0x0004; - public static inline var TRIANGLE_STRIP = 0x0005; - public static inline var TRIANGLE_FAN = 0x0006; - - /* AlphaFunction(not supported in ES20) */ - /* NEVER */ - /* LESS */ - /* EQUAL */ - /* LEQUAL */ - /* GREATER */ - /* NOTEQUAL */ - /* GEQUAL */ - /* ALWAYS */ - /* BlendingFactorDest */ - public static inline var ZERO = 0; - public static inline var ONE = 1; - public static inline var SRC_COLOR = 0x0300; - public static inline var ONE_MINUS_SRC_COLOR = 0x0301; - public static inline var SRC_ALPHA = 0x0302; - public static inline var ONE_MINUS_SRC_ALPHA = 0x0303; - public static inline var DST_ALPHA = 0x0304; - public static inline var ONE_MINUS_DST_ALPHA = 0x0305; - - /* BlendingFactorSrc */ - /* ZERO */ - /* ONE */ - public static inline var DST_COLOR = 0x0306; - public static inline var ONE_MINUS_DST_COLOR = 0x0307; - public static inline var SRC_ALPHA_SATURATE = 0x0308; - /* SRC_ALPHA */ - /* ONE_MINUS_SRC_ALPHA */ - /* DST_ALPHA */ - /* ONE_MINUS_DST_ALPHA */ - /* BlendEquationSeparate */ - public static inline var FUNC_ADD = 0x8006; - public static inline var BLEND_EQUATION = 0x8009; - public static inline var BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQUATION */ - public static inline var BLEND_EQUATION_ALPHA = 0x883D; - - /* BlendSubtract */ - public static inline var FUNC_SUBTRACT = 0x800A; - public static inline var FUNC_REVERSE_SUBTRACT = 0x800B; - - /* Separate Blend Functions */ - public static inline var BLEND_DST_RGB = 0x80C8; - public static inline var BLEND_SRC_RGB = 0x80C9; - public static inline var BLEND_DST_ALPHA = 0x80CA; - public static inline var BLEND_SRC_ALPHA = 0x80CB; - public static inline var CONSTANT_COLOR = 0x8001; - public static inline var ONE_MINUS_CONSTANT_COLOR = 0x8002; - public static inline var CONSTANT_ALPHA = 0x8003; - public static inline var ONE_MINUS_CONSTANT_ALPHA = 0x8004; - public static inline var BLEND_COLOR = 0x8005; - - /* GLBuffer Objects */ - public static inline var ARRAY_BUFFER = 0x8892; - public static inline var ELEMENT_ARRAY_BUFFER = 0x8893; - public static inline var ARRAY_BUFFER_BINDING = 0x8894; - public static inline var ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; - - public static inline var STREAM_DRAW = 0x88E0; - public static inline var STATIC_DRAW = 0x88E4; - public static inline var DYNAMIC_DRAW = 0x88E8; - - public static inline var BUFFER_SIZE = 0x8764; - public static inline var BUFFER_USAGE = 0x8765; - - public static inline var CURRENT_VERTEX_ATTRIB = 0x8626; - - /* CullFaceMode */ - public static inline var FRONT = 0x0404; - public static inline var BACK = 0x0405; - public static inline var FRONT_AND_BACK = 0x0408; - - /* DepthFunction */ - /* NEVER */ - /* LESS */ - /* EQUAL */ - /* LEQUAL */ - /* GREATER */ - /* NOTEQUAL */ - /* GEQUAL */ - /* ALWAYS */ - /* EnableCap */ - /* TEXTURE_2D */ - public static inline var CULL_FACE = 0x0B44; - public static inline var BLEND = 0x0BE2; - public static inline var DITHER = 0x0BD0; - public static inline var STENCIL_TEST = 0x0B90; - public static inline var DEPTH_TEST = 0x0B71; - public static inline var SCISSOR_TEST = 0x0C11; - public static inline var POLYGON_OFFSET_FILL = 0x8037; - public static inline var SAMPLE_ALPHA_TO_COVERAGE = 0x809E; - public static inline var SAMPLE_COVERAGE = 0x80A0; - - /* ErrorCode */ - public static inline var NO_ERROR = 0; - public static inline var INVALID_ENUM = 0x0500; - public static inline var INVALID_VALUE = 0x0501; - public static inline var INVALID_OPERATION = 0x0502; - public static inline var OUT_OF_MEMORY = 0x0505; - - /* FrontFaceDirection */ - public static inline var CW = 0x0900; - public static inline var CCW = 0x0901; - - /* GetPName */ - public static inline var LINE_WIDTH = 0x0B21; - public static inline var ALIASED_POINT_SIZE_RANGE = 0x846D; - public static inline var ALIASED_LINE_WIDTH_RANGE = 0x846E; - public static inline var CULL_FACE_MODE = 0x0B45; - public static inline var FRONT_FACE = 0x0B46; - public static inline var DEPTH_RANGE = 0x0B70; - public static inline var DEPTH_WRITEMASK = 0x0B72; - public static inline var DEPTH_CLEAR_VALUE = 0x0B73; - public static inline var DEPTH_FUNC = 0x0B74; - public static inline var STENCIL_CLEAR_VALUE = 0x0B91; - public static inline var STENCIL_FUNC = 0x0B92; - public static inline var STENCIL_FAIL = 0x0B94; - public static inline var STENCIL_PASS_DEPTH_FAIL = 0x0B95; - public static inline var STENCIL_PASS_DEPTH_PASS = 0x0B96; - public static inline var STENCIL_REF = 0x0B97; - public static inline var STENCIL_VALUE_MASK = 0x0B93; - public static inline var STENCIL_WRITEMASK = 0x0B98; - public static inline var STENCIL_BACK_FUNC = 0x8800; - public static inline var STENCIL_BACK_FAIL = 0x8801; - public static inline var STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; - public static inline var STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; - public static inline var STENCIL_BACK_REF = 0x8CA3; - public static inline var STENCIL_BACK_VALUE_MASK = 0x8CA4; - public static inline var STENCIL_BACK_WRITEMASK = 0x8CA5; - public static inline var VIEWPORT = 0x0BA2; - public static inline var SCISSOR_BOX = 0x0C10; - /* SCISSOR_TEST */ - public static inline var COLOR_CLEAR_VALUE = 0x0C22; - public static inline var COLOR_WRITEMASK = 0x0C23; - public static inline var UNPACK_ALIGNMENT = 0x0CF5; - public static inline var PACK_ALIGNMENT = 0x0D05; - public static inline var MAX_TEXTURE_SIZE = 0x0D33; - public static inline var MAX_VIEWPORT_DIMS = 0x0D3A; - public static inline var SUBPIXEL_BITS = 0x0D50; - public static inline var RED_BITS = 0x0D52; - public static inline var GREEN_BITS = 0x0D53; - public static inline var BLUE_BITS = 0x0D54; - public static inline var ALPHA_BITS = 0x0D55; - public static inline var DEPTH_BITS = 0x0D56; - public static inline var STENCIL_BITS = 0x0D57; - public static inline var POLYGON_OFFSET_UNITS = 0x2A00; - /* POLYGON_OFFSET_FILL */ - public static inline var POLYGON_OFFSET_FACTOR = 0x8038; - public static inline var TEXTURE_BINDING_2D = 0x8069; - public static inline var SAMPLE_BUFFERS = 0x80A8; - public static inline var SAMPLES = 0x80A9; - public static inline var SAMPLE_COVERAGE_VALUE = 0x80AA; - public static inline var SAMPLE_COVERAGE_INVERT = 0x80AB; - - /* GetTextureParameter */ - /* TEXTURE_MAG_FILTER */ - /* TEXTURE_MIN_FILTER */ - /* TEXTURE_WRAP_S */ - /* TEXTURE_WRAP_T */ - public static inline var COMPRESSED_TEXTURE_FORMATS = 0x86A3; - - /* HintMode */ - public static inline var DONT_CARE = 0x1100; - public static inline var FASTEST = 0x1101; - public static inline var NICEST = 0x1102; - - /* HintTarget */ - public static inline var GENERATE_MIPMAP_HINT = 0x8192; - - /* DataType */ - public static inline var BYTE = 0x1400; - public static inline var UNSIGNED_BYTE = 0x1401; - public static inline var SHORT = 0x1402; - public static inline var UNSIGNED_SHORT = 0x1403; - public static inline var INT = 0x1404; - public static inline var UNSIGNED_INT = 0x1405; - public static inline var FLOAT = 0x1406; - - /* PixelFormat */ - public static inline var DEPTH_COMPONENT = 0x1902; - public static inline var ALPHA = 0x1906; - public static inline var RGB = 0x1907; - public static inline var RGBA = 0x1908; - public static inline var LUMINANCE = 0x1909; - public static inline var LUMINANCE_ALPHA = 0x190A; - - /* PixelType */ - /* UNSIGNED_BYTE */ - public static inline var UNSIGNED_SHORT_4_4_4_4 = 0x8033; - public static inline var UNSIGNED_SHORT_5_5_5_1 = 0x8034; - public static inline var UNSIGNED_SHORT_5_6_5 = 0x8363; - - /* Shaders */ - public static inline var FRAGMENT_SHADER = 0x8B30; - public static inline var VERTEX_SHADER = 0x8B31; - public static inline var MAX_VERTEX_ATTRIBS = 0x8869; - public static inline var MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB; - public static inline var MAX_VARYING_VECTORS = 0x8DFC; - public static inline var MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; - public static inline var MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; - public static inline var MAX_TEXTURE_IMAGE_UNITS = 0x8872; - public static inline var MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD; - public static inline var SHADER_TYPE = 0x8B4F; - public static inline var DELETE_STATUS = 0x8B80; - public static inline var LINK_STATUS = 0x8B82; - public static inline var VALIDATE_STATUS = 0x8B83; - public static inline var ATTACHED_SHADERS = 0x8B85; - public static inline var ACTIVE_UNIFORMS = 0x8B86; - public static inline var ACTIVE_ATTRIBUTES = 0x8B89; - public static inline var SHADING_LANGUAGE_VERSION = 0x8B8C; - public static inline var CURRENT_PROGRAM = 0x8B8D; - - /* StencilFunction */ - public static inline var NEVER = 0x0200; - public static inline var LESS = 0x0201; - public static inline var EQUAL = 0x0202; - public static inline var LEQUAL = 0x0203; - public static inline var GREATER = 0x0204; - public static inline var NOTEQUAL = 0x0205; - public static inline var GEQUAL = 0x0206; - public static inline var ALWAYS = 0x0207; - - /* StencilOp */ - /* ZERO */ - public static inline var KEEP = 0x1E00; - public static inline var REPLACE = 0x1E01; - public static inline var INCR = 0x1E02; - public static inline var DECR = 0x1E03; - public static inline var INVERT = 0x150A; - public static inline var INCR_WRAP = 0x8507; - public static inline var DECR_WRAP = 0x8508; - - /* StringName */ - public static inline var VENDOR = 0x1F00; - public static inline var RENDERER = 0x1F01; - public static inline var VERSION = 0x1F02; - - /* TextureMagFilter */ - public static inline var NEAREST = 0x2600; - public static inline var LINEAR = 0x2601; - - /* TextureMinFilter */ - /* NEAREST */ - /* LINEAR */ - public static inline var NEAREST_MIPMAP_NEAREST = 0x2700; - public static inline var LINEAR_MIPMAP_NEAREST = 0x2701; - public static inline var NEAREST_MIPMAP_LINEAR = 0x2702; - public static inline var LINEAR_MIPMAP_LINEAR = 0x2703; - - /* TextureParameterName */ - public static inline var TEXTURE_MAG_FILTER = 0x2800; - public static inline var TEXTURE_MIN_FILTER = 0x2801; - public static inline var TEXTURE_WRAP_S = 0x2802; - public static inline var TEXTURE_WRAP_T = 0x2803; - - /* TextureTarget */ - public static inline var TEXTURE_2D = 0x0DE1; - public static inline var TEXTURE = 0x1702; - - public static inline var TEXTURE_CUBE_MAP = 0x8513; - public static inline var TEXTURE_BINDING_CUBE_MAP = 0x8514; - public static inline var TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; - public static inline var TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; - public static inline var TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; - public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; - public static inline var TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; - public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; - public static inline var MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; - - /* TextureUnit */ - public static inline var TEXTURE0 = 0x84C0; - public static inline var TEXTURE1 = 0x84C1; - public static inline var TEXTURE2 = 0x84C2; - public static inline var TEXTURE3 = 0x84C3; - public static inline var TEXTURE4 = 0x84C4; - public static inline var TEXTURE5 = 0x84C5; - public static inline var TEXTURE6 = 0x84C6; - public static inline var TEXTURE7 = 0x84C7; - public static inline var TEXTURE8 = 0x84C8; - public static inline var TEXTURE9 = 0x84C9; - public static inline var TEXTURE10 = 0x84CA; - public static inline var TEXTURE11 = 0x84CB; - public static inline var TEXTURE12 = 0x84CC; - public static inline var TEXTURE13 = 0x84CD; - public static inline var TEXTURE14 = 0x84CE; - public static inline var TEXTURE15 = 0x84CF; - public static inline var TEXTURE16 = 0x84D0; - public static inline var TEXTURE17 = 0x84D1; - public static inline var TEXTURE18 = 0x84D2; - public static inline var TEXTURE19 = 0x84D3; - public static inline var TEXTURE20 = 0x84D4; - public static inline var TEXTURE21 = 0x84D5; - public static inline var TEXTURE22 = 0x84D6; - public static inline var TEXTURE23 = 0x84D7; - public static inline var TEXTURE24 = 0x84D8; - public static inline var TEXTURE25 = 0x84D9; - public static inline var TEXTURE26 = 0x84DA; - public static inline var TEXTURE27 = 0x84DB; - public static inline var TEXTURE28 = 0x84DC; - public static inline var TEXTURE29 = 0x84DD; - public static inline var TEXTURE30 = 0x84DE; - public static inline var TEXTURE31 = 0x84DF; - public static inline var ACTIVE_TEXTURE = 0x84E0; - - /* TextureWrapMode */ - public static inline var REPEAT = 0x2901; - public static inline var CLAMP_TO_EDGE = 0x812F; - public static inline var MIRRORED_REPEAT = 0x8370; - - /* Uniform Types */ - public static inline var FLOAT_VEC2 = 0x8B50; - public static inline var FLOAT_VEC3 = 0x8B51; - public static inline var FLOAT_VEC4 = 0x8B52; - public static inline var INT_VEC2 = 0x8B53; - public static inline var INT_VEC3 = 0x8B54; - public static inline var INT_VEC4 = 0x8B55; - public static inline var BOOL = 0x8B56; - public static inline var BOOL_VEC2 = 0x8B57; - public static inline var BOOL_VEC3 = 0x8B58; - public static inline var BOOL_VEC4 = 0x8B59; - public static inline var FLOAT_MAT2 = 0x8B5A; - public static inline var FLOAT_MAT3 = 0x8B5B; - public static inline var FLOAT_MAT4 = 0x8B5C; - public static inline var SAMPLER_2D = 0x8B5E; - public static inline var SAMPLER_CUBE = 0x8B60; - - /* Vertex Arrays */ - public static inline var VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; - public static inline var VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; - public static inline var VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; - public static inline var VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; - public static inline var VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; - public static inline var VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; - public static inline var VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; - - /* Point Size */ - public static inline var VERTEX_PROGRAM_POINT_SIZE = 0x8642; - public static inline var POINT_SPRITE = 0x8861; - - /* GLShader Source */ - public static inline var COMPILE_STATUS = 0x8B81; - - /* GLShader Precision-Specified Types */ - public static inline var LOW_FLOAT = 0x8DF0; - public static inline var MEDIUM_FLOAT = 0x8DF1; - public static inline var HIGH_FLOAT = 0x8DF2; - public static inline var LOW_INT = 0x8DF3; - public static inline var MEDIUM_INT = 0x8DF4; - public static inline var HIGH_INT = 0x8DF5; - - /* GLFramebuffer Object. */ - public static inline var FRAMEBUFFER = 0x8D40; - public static inline var RENDERBUFFER = 0x8D41; - - public static inline var RGBA4 = 0x8056; - public static inline var RGB5_A1 = 0x8057; - public static inline var RGB565 = 0x8D62; - public static inline var DEPTH_COMPONENT16 = 0x81A5; - public static inline var STENCIL_INDEX = 0x1901; - public static inline var STENCIL_INDEX8 = 0x8D48; - public static inline var DEPTH_STENCIL = 0x84F9; - - public static inline var RENDERBUFFER_WIDTH = 0x8D42; - public static inline var RENDERBUFFER_HEIGHT = 0x8D43; - public static inline var RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; - public static inline var RENDERBUFFER_RED_SIZE = 0x8D50; - public static inline var RENDERBUFFER_GREEN_SIZE = 0x8D51; - public static inline var RENDERBUFFER_BLUE_SIZE = 0x8D52; - public static inline var RENDERBUFFER_ALPHA_SIZE = 0x8D53; - public static inline var RENDERBUFFER_DEPTH_SIZE = 0x8D54; - public static inline var RENDERBUFFER_STENCIL_SIZE = 0x8D55; - - public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; - public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; - public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; - public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; - - public static inline var COLOR_ATTACHMENT0 = 0x8CE0; - public static inline var DEPTH_ATTACHMENT = 0x8D00; - public static inline var STENCIL_ATTACHMENT = 0x8D20; - public static inline var DEPTH_STENCIL_ATTACHMENT = 0x821A; - - public static inline var NONE = 0; - - public static inline var FRAMEBUFFER_COMPLETE = 0x8CD5; - public static inline var FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; - public static inline var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; - public static inline var FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; - public static inline var FRAMEBUFFER_UNSUPPORTED = 0x8CDD; - - public static inline var FRAMEBUFFER_BINDING = 0x8CA6; - public static inline var RENDERBUFFER_BINDING = 0x8CA7; - public static inline var MAX_RENDERBUFFER_SIZE = 0x84E8; - - public static inline var INVALID_FRAMEBUFFER_OPERATION = 0x0506; - - /* WebGL-specific enums */ - public static inline var UNPACK_FLIP_Y_WEBGL = 0x9240; - public static inline var UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; - public static inline var CONTEXT_LOST_WEBGL = 0x9242; - public static inline var UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243; - public static inline var BROWSER_DEFAULT_WEBGL = 0x9244; - - public static var version(get_version, null):Int; - - public static function versionString():String { - return lime_gl_version(); - } - - public static function activeTexture(texture:Int):Void - { - lime_gl_active_texture(texture); - } - - public static function attachShader(program:GLProgram, shader:GLShader):Void - { - program.attach(shader); - lime_gl_attach_shader(program.id, shader.id); - } - - public static function bindAttribLocation(program:GLProgram, index:Int, name:String):Void - { - lime_gl_bind_attrib_location(program.id, index, name); - } - - public static function bindBuffer(target:Int, buffer:GLBuffer):Void - { - lime_gl_bind_buffer(target, buffer == null ? 0 : buffer.id); - } - - public static function bindFramebuffer(target:Int, framebuffer:GLFramebuffer):Void - { - lime_gl_bind_framebuffer(target, framebuffer == null ? 0 : framebuffer.id); - } - - public static function bindRenderbuffer(target:Int, renderbuffer:GLRenderbuffer):Void - { - lime_gl_bind_renderbuffer(target, renderbuffer == null ? 0 : renderbuffer.id); - } - - public static function bindTexture(target:Int, texture:GLTexture):Void - { - lime_gl_bind_texture(target, texture == null ? 0 : texture.id); - } - - public static function blendColor(red:Float, green:Float, blue:Float, alpha:Float):Void - { - lime_gl_blend_color(red, green, blue, alpha); - } - - public static function blendEquation(mode:Int):Void - { - lime_gl_blend_equation(mode); - } - - public static function blendEquationSeparate(modeRGB:Int, modeAlpha:Int):Void - { - lime_gl_blend_equation_separate(modeRGB, modeAlpha); - } - - public static function blendFunc(sfactor:Int, dfactor:Int):Void - { - lime_gl_blend_func(sfactor, dfactor); - } - - public static function blendFuncSeparate(srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void - { - lime_gl_blend_func_separate(srcRGB, dstRGB, srcAlpha, dstAlpha); - } - - public static function bufferData(target:Int, data:IMemoryRange, usage:Int):Void - { - lime_gl_buffer_data(target, data.getByteBuffer(), data.getStart(), data.getLength(), usage); - } - - public static function bufferSubData(target:Int, offset:Int, data:IMemoryRange ):Void - { - lime_gl_buffer_sub_data( target, offset, data.getByteBuffer(), data.getStart(), data.getLength() ); - } - - public static function checkFramebufferStatus(target:Int):Int - { - return lime_gl_check_framebuffer_status(target); - } - - public static function clear(mask:Int):Void - { - lime_gl_clear(mask); - } - - public static function clearColor(red:Float, green:Float, blue:Float, alpha:Float):Void - { - lime_gl_clear_color(red, green, blue, alpha); - } - - public static function clearDepth(depth:Float):Void - { - lime_gl_clear_depth(depth); - } - - public static function clearStencil(s:Int):Void - { - lime_gl_clear_stencil(s); - } - - public static function colorMask(red:Bool, green:Bool, blue:Bool, alpha:Bool):Void - { - lime_gl_color_mask(red, green, blue, alpha); - } - - public static function compileShader(shader:GLShader):Void - { - lime_gl_compile_shader(shader.id); - } - - public static function compressedTexImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:IMemoryRange):Void - { - lime_gl_compressed_tex_image_2d(target, level, internalformat, width, height, border, data == null ? null : data.getByteBuffer(), data == null ? null : data.getStart()); - } - - public static function compressedTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, data:IMemoryRange):Void - { - lime_gl_compressed_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, data == null ? null : data.getByteBuffer(), data == null ? null : data.getStart()); - } - - public static function copyTexImage2D(target:Int, level:Int, internalformat:Int, x:Int, y:Int, width:Int, height:Int, border:Int):Void - { - lime_gl_copy_tex_image_2d(target, level, internalformat, x, y, width, height, border); - } - - public static function copyTexSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, x:Int, y:Int, width:Int, height:Int):Void - { - lime_gl_copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height); - } - - public static function createBuffer():GLBuffer - { - return new GLBuffer(version, lime_gl_create_buffer()); - } - - public static function createFramebuffer():GLFramebuffer - { - return new GLFramebuffer(version, lime_gl_create_framebuffer()); - } - - public static function createProgram():GLProgram - { - return new GLProgram(version, lime_gl_create_program()); - } - - public static function createRenderbuffer():GLRenderbuffer - { - return new GLRenderbuffer(version, lime_gl_create_render_buffer()); - } - - public static function createShader(type:Int):GLShader - { - return new GLShader(version, lime_gl_create_shader(type)); - } - - public static function createTexture():GLTexture - { - return new GLTexture(version, lime_gl_create_texture()); - } - - public static function cullFace(mode:Int):Void - { - lime_gl_cull_face(mode); - } - - public static function deleteBuffer(buffer:GLBuffer):Void - { - lime_gl_delete_buffer(buffer.id); - buffer.invalidate(); - } - - public static function deleteFramebuffer(framebuffer:GLFramebuffer):Void - { - lime_gl_delete_framebuffer(framebuffer.id); - framebuffer.invalidate(); - } - - public static function deleteProgram(program:GLProgram):Void - { - lime_gl_delete_program(program.id); - program.invalidate(); - } - - public static function deleteRenderbuffer(renderbuffer:GLRenderbuffer):Void - { - lime_gl_delete_render_buffer(renderbuffer.id); - renderbuffer.invalidate(); - } - - public static function deleteShader(shader:GLShader):Void - { - lime_gl_delete_shader(shader.id); - shader.invalidate(); - } - - public static function deleteTexture(texture:GLTexture):Void - { - lime_gl_delete_texture(texture.id); - texture.invalidate(); - } - - public static function depthFunc(func:Int):Void - { - lime_gl_depth_func(func); - } - - public static function depthMask(flag:Bool):Void - { - lime_gl_depth_mask(flag); - } - - public static function depthRange(zNear:Float, zFar:Float):Void - { - lime_gl_depth_range(zNear, zFar); - } - - public static function detachShader(program:GLProgram, shader:GLShader):Void - { - lime_gl_detach_shader(program.id, shader.id); - } - - public static function disable(cap:Int):Void - { - lime_gl_disable(cap); - } - - public static function disableVertexAttribArray(index:Int):Void - { - lime_gl_disable_vertex_attrib_array(index); - } - - public static function drawArrays(mode:Int, first:Int, count:Int):Void - { - lime_gl_draw_arrays(mode, first, count); - } - - public static function drawElements(mode:Int, count:Int, type:Int, offset:Int):Void - { - lime_gl_draw_elements(mode, count, type, offset); - } - - public static function enable(cap:Int):Void - { - lime_gl_enable(cap); - } - - public static function enableVertexAttribArray(index:Int):Void - { - lime_gl_enable_vertex_attrib_array(index); - } - - public static function finish():Void - { - lime_gl_finish(); - } - - public static function flush():Void - { - lime_gl_flush(); - } - - public static function framebufferRenderbuffer(target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void - { - lime_gl_framebuffer_renderbuffer(target, attachment, renderbuffertarget, renderbuffer.id); - } - - public static function framebufferTexture2D(target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void - { - lime_gl_framebuffer_texture2D(target, attachment, textarget, texture.id, level); - } - - public static function frontFace(mode:Int):Void - { - lime_gl_front_face(mode); - } - - public static function generateMipmap(target:Int):Void - { - lime_gl_generate_mipmap(target); - } - - public static function getActiveAttrib(program:GLProgram, index:Int):GLActiveInfo - { - return lime_gl_get_active_attrib(program.id, index); - } - - public static function getActiveUniform(program:GLProgram, index:Int):GLActiveInfo - { - return lime_gl_get_active_uniform(program.id, index); - } - - public static function getAttachedShaders(program:GLProgram):Array - { - return program.getShaders(); - } - - public static function getAttribLocation(program:GLProgram, name:String):Int - { - return lime_gl_get_attrib_location(program.id, name); - } - - public static function getBufferParameter(target:Int, pname:Int):Int /*Dynamic*/ - { - return lime_gl_get_buffer_paramerter(target, pname); - } - - public static function getContextAttributes():GLContextAttributes - { - var base = lime_gl_get_context_attributes(); - base.premultipliedAlpha = false; - base.preserveDrawingBuffer = false; - return base; - } - - public static function getError():Int - { - return lime_gl_get_error(); - } - - public static function getExtension(name:String):Dynamic - { - //todo?! - return null; - // return lime_gl_get_extension(name); - } - - public static function getFramebufferAttachmentParameter(target:Int, attachment:Int, pname:Int):Int /*Dynamic*/ - { - return lime_gl_get_framebuffer_attachment_parameter(target, attachment, pname); - } - - public static function getParameter(pname:Int):Dynamic - { - return lime_gl_get_parameter(pname); - } - - public static function getProgramInfoLog(program:GLProgram):String - { - return lime_gl_get_program_info_log(program.id); - } - - public static function getProgramParameter(program:GLProgram, pname:Int):Int - { - return lime_gl_get_program_parameter(program.id, pname); - } - - public static function getRenderbufferParameter(target:Int, pname:Int):Int /*Dynamic*/ - { - return lime_gl_get_render_buffer_parameter(target, pname); - } - - public static function getShaderInfoLog(shader:GLShader):String - { - return lime_gl_get_shader_info_log(shader.id); - } - - public static function getShaderParameter(shader:GLShader, pname:Int):Int - { - return lime_gl_get_shader_parameter(shader.id, pname); - } - - public static function getShaderPrecisionFormat(shadertype:Int, precisiontype:Int):ShaderPrecisionFormat - { - return lime_gl_get_shader_precision_format(shadertype, precisiontype); - } - - public static function getShaderSource(shader:GLShader):String - { - return lime_gl_get_shader_source(shader.id); - } - - public static function getSupportedExtensions():Array - { - var result = new Array(); - lime_gl_get_supported_extensions(result); - return result; - } - - public static function getTexParameter(target:Int, pname:Int):Int /*Dynamic*/ - { - return lime_gl_get_tex_parameter(target, pname); - } - - public static function getUniform(program:GLProgram, location:GLUniformLocation):Dynamic - { - return lime_gl_get_uniform(program.id, location); - } - - public static function getUniformLocation(program:GLProgram, name:String):GLUniformLocation - { - return lime_gl_get_uniform_location(program.id, name); - } - - public static function getVertexAttrib(index:Int, pname:Int):Int /*Dynamic*/ - { - return lime_gl_get_vertex_attrib(index, pname); - } - - public static function getVertexAttribOffset(index:Int, pname:Int):Int - { - return lime_gl_get_vertex_attrib_offset(index, pname); - } - - public static function hint(target:Int, mode:Int):Void - { - lime_gl_hint(target, mode); - } - - public static function isBuffer(buffer:GLBuffer):Bool - { - return buffer != null && buffer.id > 0 && lime_gl_is_buffer(buffer.id); - } - - // This is non-static - // public function isContextLost():Bool { return false; } - public static function isEnabled(cap:Int):Bool - { - return lime_gl_is_enabled(cap); - } - - public static function isFramebuffer(framebuffer:GLFramebuffer):Bool - { - return framebuffer != null && framebuffer.id > 0 && lime_gl_is_framebuffer(framebuffer.id); - } - - public static function isProgram(program:GLProgram):Bool - { - return program != null && program.id > 0 && lime_gl_is_program(program.id); - } - - public static function isRenderbuffer(renderbuffer:GLRenderbuffer):Bool - { - return renderbuffer != null && renderbuffer.id > 0 && lime_gl_is_renderbuffer(renderbuffer.id); - } - - public static function isShader(shader:GLShader):Bool - { - return shader != null && shader.id > 0 && lime_gl_is_shader(shader.id); - } - - public static function isTexture(texture:GLTexture):Bool - { - return texture != null && texture.id > 0 && lime_gl_is_texture(texture.id); - } - - public static function lineWidth(width:Float):Void - { - lime_gl_line_width(width); - } - - public static function linkProgram(program:GLProgram):Void - { - lime_gl_link_program(program.id); - } - - static function load(inName:String, inArgCount:Int):Dynamic - { - try - { - return System.load("lime", inName, inArgCount); - - } catch(e:Dynamic) - { - trace(e); - return null; - } - } - - public static function pixelStorei(pname:Int, param:Int):Void - { - lime_gl_pixel_storei(pname, param); - } - - public static function polygonOffset(factor:Float, units:Float):Void - { - lime_gl_polygon_offset(factor, units); - } - - public static function readPixels(x:Int, y:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void - { - lime_gl_read_pixels(x, y, width, height, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart()); - } - - public static function renderbufferStorage(target:Int, internalformat:Int, width:Int, height:Int):Void - { - lime_gl_renderbuffer_storage(target, internalformat, width, height); - } - - public static function sampleCoverage(value:Float, invert:Bool):Void - { - lime_gl_sample_coverage(value, invert); - } - - public static function scissor(x:Int, y:Int, width:Int, height:Int):Void - { - lime_gl_scissor(x, y, width, height); - } - - public static function shaderSource(shader:GLShader, source:String):Void - { - lime_gl_shader_source(shader.id, source); - } - - public static function stencilFunc(func:Int, ref:Int, mask:Int):Void - { - lime_gl_stencil_func(func, ref, mask); - } - - public static function stencilFuncSeparate(face:Int, func:Int, ref:Int, mask:Int):Void - { - lime_gl_stencil_func_separate(face, func, ref, mask); - } - - public static function stencilMask(mask:Int):Void - { - lime_gl_stencil_mask(mask); - } - - public static function stencilMaskSeparate(face:Int, mask:Int):Void - { - lime_gl_stencil_mask_separate(face, mask); - } - - public static function stencilOp(fail:Int, zfail:Int, zpass:Int):Void - { - lime_gl_stencil_op(fail, zfail, zpass); - } - - public static function stencilOpSeparate(face:Int, fail:Int, zfail:Int, zpass:Int):Void - { - lime_gl_stencil_op_separate(face, fail, zfail, zpass); - } - - public static function texImage2D(target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, format:Int, type:Int, pixels:ArrayBufferView):Void - { - lime_gl_tex_image_2d(target, level, internalformat, width, height, border, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart()); - } - - public static function texParameterf(target:Int, pname:Int, param:Float):Void - { - lime_gl_tex_parameterf(target, pname, param); - } - - public static function texParameteri(target:Int, pname:Int, param:Int):Void - { - lime_gl_tex_parameteri(target, pname, param); - } - - public static function texSubImage2D(target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void - { - lime_gl_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart()); - } - - public static function uniform1f(location:GLUniformLocation, x:Float):Void - { - lime_gl_uniform1f(location, x); - } - - public static function uniform1fv(location:GLUniformLocation, x:Float32Array):Void - { - lime_gl_uniform1fv(location, x.getByteBuffer()); - } - - public static function uniform1i(location:GLUniformLocation, x:Int):Void - { - lime_gl_uniform1i(location, x); - } - - public static function uniform1iv(location:GLUniformLocation, v:Int32Array):Void - { - lime_gl_uniform1iv(location, v.getByteBuffer()); - } - - public static function uniform2f(location:GLUniformLocation, x:Float, y:Float):Void - { - lime_gl_uniform2f(location, x, y); - } - - public static function uniform2fv(location:GLUniformLocation, v:Float32Array):Void - { - lime_gl_uniform2fv(location, v.getByteBuffer()); - } - - public static function uniform2i(location:GLUniformLocation, x:Int, y:Int):Void - { - lime_gl_uniform2i(location, x, y); - } - - public static function uniform2iv(location:GLUniformLocation, v:Int32Array):Void - { - lime_gl_uniform2iv(location, v.getByteBuffer()); - } - - public static function uniform3f(location:GLUniformLocation, x:Float, y:Float, z:Float):Void - { - lime_gl_uniform3f(location, x, y, z); - } - - public static function uniform3fv(location:GLUniformLocation, v:Float32Array):Void - { - lime_gl_uniform3fv(location, v.getByteBuffer()); - } - - public static function uniform3i(location:GLUniformLocation, x:Int, y:Int, z:Int):Void - { - lime_gl_uniform3i(location, x, y, z); - } - - public static function uniform3iv(location:GLUniformLocation, v:Int32Array):Void - { - lime_gl_uniform3iv(location, v.getByteBuffer()); - } - - public static function uniform4f(location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void - { - lime_gl_uniform4f(location, x, y, z, w); - } - - public static function uniform4fv(location:GLUniformLocation, v:Float32Array):Void - { - lime_gl_uniform4fv(location, v.getByteBuffer()); - } - - public static function uniform4i(location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void - { - lime_gl_uniform4i(location, x, y, z, w); - } - - public static function uniform4iv(location:GLUniformLocation, v:Int32Array):Void - { - lime_gl_uniform4iv(location, v.getByteBuffer()); - } - - public static function uniformMatrix2fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void - { - lime_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 2); - } - - public static function uniformMatrix3fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void - { - lime_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 3); - } - - public static function uniformMatrix4fv(location:GLUniformLocation, transpose:Bool, v:Float32Array):Void - { - lime_gl_uniform_matrix(location, transpose, v.getByteBuffer(), 4); - } - - /*public static function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void - { - lime_gl_uniform_matrix(location, transpose, Float32Array.fromMatrix(matrix).getByteBuffer() , 4); - }*/ - - public static function useProgram(program:GLProgram):Void - { - lime_gl_use_program(program == null ? 0 : program.id); - } - - public static function validateProgram(program:GLProgram):Void - { - lime_gl_validate_program(program.id); - } - - public static function vertexAttrib1f(indx:Int, x:Float):Void - { - lime_gl_vertex_attrib1f(indx, x); - } - - public static function vertexAttrib1fv(indx:Int, values:Float32Array):Void - { - lime_gl_vertex_attrib1fv(indx, values.getByteBuffer()); - } - - public static function vertexAttrib2f(indx:Int, x:Float, y:Float):Void - { - lime_gl_vertex_attrib2f(indx, x, y); - } - - public static function vertexAttrib2fv(indx:Int, values:Float32Array):Void - { - lime_gl_vertex_attrib2fv(indx, values.getByteBuffer()); - } - - public static function vertexAttrib3f(indx:Int, x:Float, y:Float, z:Float):Void - { - lime_gl_vertex_attrib3f(indx, x, y, z); - } - - public static function vertexAttrib3fv(indx:Int, values:Float32Array):Void - { - lime_gl_vertex_attrib3fv(indx, values.getByteBuffer()); - } - - public static function vertexAttrib4f(indx:Int, x:Float, y:Float, z:Float, w:Float):Void - { - lime_gl_vertex_attrib4f(indx, x, y, z, w); - } - - public static function vertexAttrib4fv(indx:Int, values:Float32Array):Void - { - lime_gl_vertex_attrib4fv(indx, values.getByteBuffer()); - } - - public static function vertexAttribPointer(indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void - { - lime_gl_vertex_attrib_pointer(indx, size, type, normalized, stride, offset); - } - - public static function viewport(x:Int, y:Int, width:Int, height:Int):Void - { - lime_gl_viewport(x, y, width, height); - } - - - - - // Getters & Setters - - - - - static function get_version():Int { return 2; } - - - - - // Native Methods - - - - - static var lime_gl_active_texture = load("lime_gl_active_texture", 1); - static var lime_gl_attach_shader = load("lime_gl_attach_shader", 2); - static var lime_gl_bind_attrib_location = load("lime_gl_bind_attrib_location", 3); - static var lime_gl_bind_buffer = load("lime_gl_bind_buffer", 2); - static var lime_gl_bind_framebuffer = load("lime_gl_bind_framebuffer", 2); - static var lime_gl_bind_renderbuffer = load("lime_gl_bind_renderbuffer", 2); - static var lime_gl_bind_texture = load("lime_gl_bind_texture", 2); - static var lime_gl_blend_color = load("lime_gl_blend_color", 4); - static var lime_gl_blend_equation = load("lime_gl_blend_equation", 1); - static var lime_gl_blend_equation_separate = load("lime_gl_blend_equation_separate", 2); - static var lime_gl_blend_func = load("lime_gl_blend_func", 2); - static var lime_gl_blend_func_separate = load("lime_gl_blend_func_separate", 4); - static var lime_gl_buffer_data = load("lime_gl_buffer_data", 5); - static var lime_gl_buffer_sub_data = load("lime_gl_buffer_sub_data", 5); - static var lime_gl_check_framebuffer_status = load("lime_gl_check_framebuffer_status", 1); - static var lime_gl_clear = load("lime_gl_clear", 1); - static var lime_gl_clear_color = load("lime_gl_clear_color", 4); - static var lime_gl_clear_depth = load("lime_gl_clear_depth", 1); - static var lime_gl_clear_stencil = load("lime_gl_clear_stencil", 1); - static var lime_gl_color_mask = load("lime_gl_color_mask", 4); - static var lime_gl_compile_shader = load("lime_gl_compile_shader", 1); - static var lime_gl_compressed_tex_image_2d = load("lime_gl_compressed_tex_image_2d", -1); - static var lime_gl_compressed_tex_sub_image_2d = load("lime_gl_compressed_tex_sub_image_2d", -1); - static var lime_gl_copy_tex_image_2d = load("lime_gl_copy_tex_image_2d", -1); - static var lime_gl_copy_tex_sub_image_2d = load("lime_gl_copy_tex_sub_image_2d", -1); - static var lime_gl_create_buffer = load("lime_gl_create_buffer", 0); - static var lime_gl_create_framebuffer = load("lime_gl_create_framebuffer", 0); - static var lime_gl_create_program = load("lime_gl_create_program", 0); - static var lime_gl_create_render_buffer = load("lime_gl_create_render_buffer", 0); - static var lime_gl_create_shader = load("lime_gl_create_shader", 1); - static var lime_gl_create_texture = load("lime_gl_create_texture", 0); - static var lime_gl_cull_face = load("lime_gl_cull_face", 1); - static var lime_gl_delete_buffer = load("lime_gl_delete_buffer", 1); - static var lime_gl_delete_framebuffer = load("lime_gl_delete_framebuffer", 1); - static var lime_gl_delete_program = load("lime_gl_delete_program", 1); - static var lime_gl_delete_render_buffer = load("lime_gl_delete_render_buffer", 1); - static var lime_gl_delete_shader = load("lime_gl_delete_shader", 1); - static var lime_gl_delete_texture = load("lime_gl_delete_texture", 1); - static var lime_gl_depth_func = load("lime_gl_depth_func", 1); - static var lime_gl_depth_mask = load("lime_gl_depth_mask", 1); - static var lime_gl_depth_range = load("lime_gl_depth_range", 2); - static var lime_gl_detach_shader = load("lime_gl_detach_shader", 2); - static var lime_gl_disable = load("lime_gl_disable", 1); - static var lime_gl_disable_vertex_attrib_array = load("lime_gl_disable_vertex_attrib_array", 1); - static var lime_gl_draw_arrays = load("lime_gl_draw_arrays", 3); - static var lime_gl_draw_elements = load("lime_gl_draw_elements", 4); - static var lime_gl_enable = load("lime_gl_enable", 1); - static var lime_gl_enable_vertex_attrib_array = load("lime_gl_enable_vertex_attrib_array", 1); - static var lime_gl_finish = load("lime_gl_finish", 0); - static var lime_gl_flush = load("lime_gl_flush", 0); - static var lime_gl_framebuffer_renderbuffer = load("lime_gl_framebuffer_renderbuffer", 4); - static var lime_gl_framebuffer_texture2D = load("lime_gl_framebuffer_texture2D", 5); - static var lime_gl_front_face = load("lime_gl_front_face", 1); - static var lime_gl_generate_mipmap = load("lime_gl_generate_mipmap", 1); - static var lime_gl_get_active_attrib = load("lime_gl_get_active_attrib", 2); - static var lime_gl_get_active_uniform = load("lime_gl_get_active_uniform", 2); - static var lime_gl_get_attrib_location = load("lime_gl_get_attrib_location", 2); - static var lime_gl_get_buffer_paramerter = load("lime_gl_get_buffer_paramerter", 2); - static var lime_gl_get_context_attributes = load("lime_gl_get_context_attributes", 0); - static var lime_gl_get_error = load("lime_gl_get_error", 0); - static var lime_gl_get_framebuffer_attachment_parameter = load("lime_gl_get_framebuffer_attachment_parameter", 3); - static var lime_gl_get_parameter = load("lime_gl_get_parameter", 1); - // static var lime_gl_get_extension = load("lime_gl_get_extension", 1); - static var lime_gl_get_program_info_log = load("lime_gl_get_program_info_log", 1); - static var lime_gl_get_program_parameter = load("lime_gl_get_program_parameter", 2); - static var lime_gl_get_render_buffer_parameter = load("lime_gl_get_render_buffer_parameter", 2); - static var lime_gl_get_shader_info_log = load("lime_gl_get_shader_info_log", 1); - static var lime_gl_get_shader_parameter = load("lime_gl_get_shader_parameter", 2); - static var lime_gl_get_shader_precision_format = load("lime_gl_get_shader_precision_format", 2); - static var lime_gl_get_shader_source = load("lime_gl_get_shader_source", 1); - static var lime_gl_get_supported_extensions = load("lime_gl_get_supported_extensions", 1); - static var lime_gl_get_tex_parameter = load("lime_gl_get_tex_parameter", 2); - static var lime_gl_get_uniform = load("lime_gl_get_uniform", 2); - static var lime_gl_get_uniform_location = load("lime_gl_get_uniform_location", 2); - static var lime_gl_get_vertex_attrib = load("lime_gl_get_vertex_attrib", 2); - static var lime_gl_get_vertex_attrib_offset = load("lime_gl_get_vertex_attrib_offset", 2); - static var lime_gl_hint = load("lime_gl_hint", 2); - static var lime_gl_is_buffer = load("lime_gl_is_buffer", 1); - static var lime_gl_is_enabled = load("lime_gl_is_enabled", 1); - static var lime_gl_is_framebuffer = load("lime_gl_is_framebuffer", 1); - static var lime_gl_is_program = load("lime_gl_is_program", 1); - static var lime_gl_is_renderbuffer = load("lime_gl_is_renderbuffer", 1); - static var lime_gl_is_shader = load("lime_gl_is_shader", 1); - static var lime_gl_is_texture = load("lime_gl_is_texture", 1); - static var lime_gl_line_width = load("lime_gl_line_width", 1); - static var lime_gl_link_program = load("lime_gl_link_program", 1); - static var lime_gl_pixel_storei = load("lime_gl_pixel_storei", 2); - static var lime_gl_polygon_offset = load("lime_gl_polygon_offset", 2); - static var lime_gl_read_pixels = load("lime_gl_read_pixels", -1); - static var lime_gl_renderbuffer_storage = load("lime_gl_renderbuffer_storage", 4); - static var lime_gl_sample_coverage = load("lime_gl_sample_coverage", 2); - static var lime_gl_scissor = load("lime_gl_scissor", 4); - static var lime_gl_shader_source = load("lime_gl_shader_source", 2); - static var lime_gl_stencil_func = load("lime_gl_stencil_func", 3); - static var lime_gl_stencil_func_separate = load("lime_gl_stencil_func_separate", 4); - static var lime_gl_stencil_mask = load("lime_gl_stencil_mask", 1); - static var lime_gl_stencil_mask_separate = load("lime_gl_stencil_mask_separate", 2); - static var lime_gl_stencil_op = load("lime_gl_stencil_op", 3); - static var lime_gl_stencil_op_separate = load("lime_gl_stencil_op_separate", 4); - static var lime_gl_tex_image_2d = load("lime_gl_tex_image_2d", -1); - static var lime_gl_tex_parameterf = load("lime_gl_tex_parameterf", 3); - static var lime_gl_tex_parameteri = load("lime_gl_tex_parameteri", 3); - static var lime_gl_tex_sub_image_2d = load("lime_gl_tex_sub_image_2d", -1); - static var lime_gl_uniform1f = load("lime_gl_uniform1f", 2); - static var lime_gl_uniform1fv = load("lime_gl_uniform1fv", 2); - static var lime_gl_uniform1i = load("lime_gl_uniform1i", 2); - static var lime_gl_uniform1iv = load("lime_gl_uniform1iv", 2); - static var lime_gl_uniform2f = load("lime_gl_uniform2f", 3); - static var lime_gl_uniform2fv = load("lime_gl_uniform2fv", 2); - static var lime_gl_uniform2i = load("lime_gl_uniform2i", 3); - static var lime_gl_uniform2iv = load("lime_gl_uniform2iv", 2); - static var lime_gl_uniform3f = load("lime_gl_uniform3f", 4); - static var lime_gl_uniform3fv = load("lime_gl_uniform3fv", 2); - static var lime_gl_uniform3i = load("lime_gl_uniform3i", 4); - static var lime_gl_uniform3iv = load("lime_gl_uniform3iv", 2); - static var lime_gl_uniform4f = load("lime_gl_uniform4f", 5); - static var lime_gl_uniform4fv = load("lime_gl_uniform4fv", 2); - static var lime_gl_uniform4i = load("lime_gl_uniform4i", 5); - static var lime_gl_uniform4iv = load("lime_gl_uniform4iv", 2); - static var lime_gl_uniform_matrix = load("lime_gl_uniform_matrix", 4); - static var lime_gl_use_program = load("lime_gl_use_program", 1); - static var lime_gl_validate_program = load("lime_gl_validate_program", 1); - static var lime_gl_version = load("lime_gl_version", 0); - static var lime_gl_vertex_attrib1f = load("lime_gl_vertex_attrib1f", 2); - static var lime_gl_vertex_attrib1fv = load("lime_gl_vertex_attrib1fv", 2); - static var lime_gl_vertex_attrib2f = load("lime_gl_vertex_attrib2f", 3); - static var lime_gl_vertex_attrib2fv = load("lime_gl_vertex_attrib2fv", 2); - static var lime_gl_vertex_attrib3f = load("lime_gl_vertex_attrib3f", 4); - static var lime_gl_vertex_attrib3fv = load("lime_gl_vertex_attrib3fv", 2); - static var lime_gl_vertex_attrib4f = load("lime_gl_vertex_attrib4f", 5); - static var lime_gl_vertex_attrib4fv = load("lime_gl_vertex_attrib4fv", 2); - static var lime_gl_vertex_attrib_pointer = load("lime_gl_vertex_attrib_pointer", -1); - static var lime_gl_viewport = load("lime_gl_viewport", 4); - - -} - - -typedef ShaderPrecisionFormat = -{ - rangeMin : Int, - rangeMax : Int, - precision : Int, - -}; - - + + + public static inline var DEPTH_BUFFER_BIT = 0x00000100; + public static inline var STENCIL_BUFFER_BIT = 0x00000400; + public static inline var COLOR_BUFFER_BIT = 0x00004000; + + public static inline var POINTS = 0x0000; + public static inline var LINES = 0x0001; + public static inline var LINE_LOOP = 0x0002; + public static inline var LINE_STRIP = 0x0003; + public static inline var TRIANGLES = 0x0004; + public static inline var TRIANGLE_STRIP = 0x0005; + public static inline var TRIANGLE_FAN = 0x0006; + + public static inline var ZERO = 0; + public static inline var ONE = 1; + public static inline var SRC_COLOR = 0x0300; + public static inline var ONE_MINUS_SRC_COLOR = 0x0301; + public static inline var SRC_ALPHA = 0x0302; + public static inline var ONE_MINUS_SRC_ALPHA = 0x0303; + public static inline var DST_ALPHA = 0x0304; + public static inline var ONE_MINUS_DST_ALPHA = 0x0305; + + public static inline var DST_COLOR = 0x0306; + public static inline var ONE_MINUS_DST_COLOR = 0x0307; + public static inline var SRC_ALPHA_SATURATE = 0x0308; + + public static inline var FUNC_ADD = 0x8006; + public static inline var BLEND_EQUATION = 0x8009; + public static inline var BLEND_EQUATION_RGB = 0x8009; + public static inline var BLEND_EQUATION_ALPHA = 0x883D; + + public static inline var FUNC_SUBTRACT = 0x800A; + public static inline var FUNC_REVERSE_SUBTRACT = 0x800B; + + public static inline var BLEND_DST_RGB = 0x80C8; + public static inline var BLEND_SRC_RGB = 0x80C9; + public static inline var BLEND_DST_ALPHA = 0x80CA; + public static inline var BLEND_SRC_ALPHA = 0x80CB; + public static inline var CONSTANT_COLOR = 0x8001; + public static inline var ONE_MINUS_CONSTANT_COLOR = 0x8002; + public static inline var CONSTANT_ALPHA = 0x8003; + public static inline var ONE_MINUS_CONSTANT_ALPHA = 0x8004; + public static inline var BLEND_COLOR = 0x8005; + + public static inline var ARRAY_BUFFER = 0x8892; + public static inline var ELEMENT_ARRAY_BUFFER = 0x8893; + public static inline var ARRAY_BUFFER_BINDING = 0x8894; + public static inline var ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; + + public static inline var STREAM_DRAW = 0x88E0; + public static inline var STATIC_DRAW = 0x88E4; + public static inline var DYNAMIC_DRAW = 0x88E8; + + public static inline var BUFFER_SIZE = 0x8764; + public static inline var BUFFER_USAGE = 0x8765; + + public static inline var CURRENT_VERTEX_ATTRIB = 0x8626; + + public static inline var FRONT = 0x0404; + public static inline var BACK = 0x0405; + public static inline var FRONT_AND_BACK = 0x0408; + + public static inline var CULL_FACE = 0x0B44; + public static inline var BLEND = 0x0BE2; + public static inline var DITHER = 0x0BD0; + public static inline var STENCIL_TEST = 0x0B90; + public static inline var DEPTH_TEST = 0x0B71; + public static inline var SCISSOR_TEST = 0x0C11; + public static inline var POLYGON_OFFSET_FILL = 0x8037; + public static inline var SAMPLE_ALPHA_TO_COVERAGE = 0x809E; + public static inline var SAMPLE_COVERAGE = 0x80A0; + + public static inline var NO_ERROR = 0; + public static inline var INVALID_ENUM = 0x0500; + public static inline var INVALID_VALUE = 0x0501; + public static inline var INVALID_OPERATION = 0x0502; + public static inline var OUT_OF_MEMORY = 0x0505; + + public static inline var CW = 0x0900; + public static inline var CCW = 0x0901; + + public static inline var LINE_WIDTH = 0x0B21; + public static inline var ALIASED_POINT_SIZE_RANGE = 0x846D; + public static inline var ALIASED_LINE_WIDTH_RANGE = 0x846E; + public static inline var CULL_FACE_MODE = 0x0B45; + public static inline var FRONT_FACE = 0x0B46; + public static inline var DEPTH_RANGE = 0x0B70; + public static inline var DEPTH_WRITEMASK = 0x0B72; + public static inline var DEPTH_CLEAR_VALUE = 0x0B73; + public static inline var DEPTH_FUNC = 0x0B74; + public static inline var STENCIL_CLEAR_VALUE = 0x0B91; + public static inline var STENCIL_FUNC = 0x0B92; + public static inline var STENCIL_FAIL = 0x0B94; + public static inline var STENCIL_PASS_DEPTH_FAIL = 0x0B95; + public static inline var STENCIL_PASS_DEPTH_PASS = 0x0B96; + public static inline var STENCIL_REF = 0x0B97; + public static inline var STENCIL_VALUE_MASK = 0x0B93; + public static inline var STENCIL_WRITEMASK = 0x0B98; + public static inline var STENCIL_BACK_FUNC = 0x8800; + public static inline var STENCIL_BACK_FAIL = 0x8801; + public static inline var STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; + public static inline var STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; + public static inline var STENCIL_BACK_REF = 0x8CA3; + public static inline var STENCIL_BACK_VALUE_MASK = 0x8CA4; + public static inline var STENCIL_BACK_WRITEMASK = 0x8CA5; + public static inline var VIEWPORT = 0x0BA2; + public static inline var SCISSOR_BOX = 0x0C10; + + public static inline var COLOR_CLEAR_VALUE = 0x0C22; + public static inline var COLOR_WRITEMASK = 0x0C23; + public static inline var UNPACK_ALIGNMENT = 0x0CF5; + public static inline var PACK_ALIGNMENT = 0x0D05; + public static inline var MAX_TEXTURE_SIZE = 0x0D33; + public static inline var MAX_VIEWPORT_DIMS = 0x0D3A; + public static inline var SUBPIXEL_BITS = 0x0D50; + public static inline var RED_BITS = 0x0D52; + public static inline var GREEN_BITS = 0x0D53; + public static inline var BLUE_BITS = 0x0D54; + public static inline var ALPHA_BITS = 0x0D55; + public static inline var DEPTH_BITS = 0x0D56; + public static inline var STENCIL_BITS = 0x0D57; + public static inline var POLYGON_OFFSET_UNITS = 0x2A00; + + public static inline var POLYGON_OFFSET_FACTOR = 0x8038; + public static inline var TEXTURE_BINDING_2D = 0x8069; + public static inline var SAMPLE_BUFFERS = 0x80A8; + public static inline var SAMPLES = 0x80A9; + public static inline var SAMPLE_COVERAGE_VALUE = 0x80AA; + public static inline var SAMPLE_COVERAGE_INVERT = 0x80AB; + + public static inline var COMPRESSED_TEXTURE_FORMATS = 0x86A3; + + public static inline var DONT_CARE = 0x1100; + public static inline var FASTEST = 0x1101; + public static inline var NICEST = 0x1102; + + public static inline var GENERATE_MIPMAP_HINT = 0x8192; + + public static inline var BYTE = 0x1400; + public static inline var UNSIGNED_BYTE = 0x1401; + public static inline var SHORT = 0x1402; + public static inline var UNSIGNED_SHORT = 0x1403; + public static inline var INT = 0x1404; + public static inline var UNSIGNED_INT = 0x1405; + public static inline var FLOAT = 0x1406; + + public static inline var DEPTH_COMPONENT = 0x1902; + public static inline var ALPHA = 0x1906; + public static inline var RGB = 0x1907; + public static inline var RGBA = 0x1908; + public static inline var LUMINANCE = 0x1909; + public static inline var LUMINANCE_ALPHA = 0x190A; + + public static inline var UNSIGNED_SHORT_4_4_4_4 = 0x8033; + public static inline var UNSIGNED_SHORT_5_5_5_1 = 0x8034; + public static inline var UNSIGNED_SHORT_5_6_5 = 0x8363; + + public static inline var FRAGMENT_SHADER = 0x8B30; + public static inline var VERTEX_SHADER = 0x8B31; + public static inline var MAX_VERTEX_ATTRIBS = 0x8869; + public static inline var MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB; + public static inline var MAX_VARYING_VECTORS = 0x8DFC; + public static inline var MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; + public static inline var MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; + public static inline var MAX_TEXTURE_IMAGE_UNITS = 0x8872; + public static inline var MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD; + public static inline var SHADER_TYPE = 0x8B4F; + public static inline var DELETE_STATUS = 0x8B80; + public static inline var LINK_STATUS = 0x8B82; + public static inline var VALIDATE_STATUS = 0x8B83; + public static inline var ATTACHED_SHADERS = 0x8B85; + public static inline var ACTIVE_UNIFORMS = 0x8B86; + public static inline var ACTIVE_ATTRIBUTES = 0x8B89; + public static inline var SHADING_LANGUAGE_VERSION = 0x8B8C; + public static inline var CURRENT_PROGRAM = 0x8B8D; + + public static inline var NEVER = 0x0200; + public static inline var LESS = 0x0201; + public static inline var EQUAL = 0x0202; + public static inline var LEQUAL = 0x0203; + public static inline var GREATER = 0x0204; + public static inline var NOTEQUAL = 0x0205; + public static inline var GEQUAL = 0x0206; + public static inline var ALWAYS = 0x0207; + + public static inline var KEEP = 0x1E00; + public static inline var REPLACE = 0x1E01; + public static inline var INCR = 0x1E02; + public static inline var DECR = 0x1E03; + public static inline var INVERT = 0x150A; + public static inline var INCR_WRAP = 0x8507; + public static inline var DECR_WRAP = 0x8508; + + public static inline var VENDOR = 0x1F00; + public static inline var RENDERER = 0x1F01; + public static inline var VERSION = 0x1F02; + + public static inline var NEAREST = 0x2600; + public static inline var LINEAR = 0x2601; + + public static inline var NEAREST_MIPMAP_NEAREST = 0x2700; + public static inline var LINEAR_MIPMAP_NEAREST = 0x2701; + public static inline var NEAREST_MIPMAP_LINEAR = 0x2702; + public static inline var LINEAR_MIPMAP_LINEAR = 0x2703; + + public static inline var TEXTURE_MAG_FILTER = 0x2800; + public static inline var TEXTURE_MIN_FILTER = 0x2801; + public static inline var TEXTURE_WRAP_S = 0x2802; + public static inline var TEXTURE_WRAP_T = 0x2803; + + public static inline var TEXTURE_2D = 0x0DE1; + public static inline var TEXTURE = 0x1702; + + public static inline var TEXTURE_CUBE_MAP = 0x8513; + public static inline var TEXTURE_BINDING_CUBE_MAP = 0x8514; + public static inline var TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; + public static inline var TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; + public static inline var TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; + public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; + public static inline var TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; + public static inline var TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; + public static inline var MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; + + public static inline var TEXTURE0 = 0x84C0; + public static inline var TEXTURE1 = 0x84C1; + public static inline var TEXTURE2 = 0x84C2; + public static inline var TEXTURE3 = 0x84C3; + public static inline var TEXTURE4 = 0x84C4; + public static inline var TEXTURE5 = 0x84C5; + public static inline var TEXTURE6 = 0x84C6; + public static inline var TEXTURE7 = 0x84C7; + public static inline var TEXTURE8 = 0x84C8; + public static inline var TEXTURE9 = 0x84C9; + public static inline var TEXTURE10 = 0x84CA; + public static inline var TEXTURE11 = 0x84CB; + public static inline var TEXTURE12 = 0x84CC; + public static inline var TEXTURE13 = 0x84CD; + public static inline var TEXTURE14 = 0x84CE; + public static inline var TEXTURE15 = 0x84CF; + public static inline var TEXTURE16 = 0x84D0; + public static inline var TEXTURE17 = 0x84D1; + public static inline var TEXTURE18 = 0x84D2; + public static inline var TEXTURE19 = 0x84D3; + public static inline var TEXTURE20 = 0x84D4; + public static inline var TEXTURE21 = 0x84D5; + public static inline var TEXTURE22 = 0x84D6; + public static inline var TEXTURE23 = 0x84D7; + public static inline var TEXTURE24 = 0x84D8; + public static inline var TEXTURE25 = 0x84D9; + public static inline var TEXTURE26 = 0x84DA; + public static inline var TEXTURE27 = 0x84DB; + public static inline var TEXTURE28 = 0x84DC; + public static inline var TEXTURE29 = 0x84DD; + public static inline var TEXTURE30 = 0x84DE; + public static inline var TEXTURE31 = 0x84DF; + public static inline var ACTIVE_TEXTURE = 0x84E0; + + public static inline var REPEAT = 0x2901; + public static inline var CLAMP_TO_EDGE = 0x812F; + public static inline var MIRRORED_REPEAT = 0x8370; + + public static inline var FLOAT_VEC2 = 0x8B50; + public static inline var FLOAT_VEC3 = 0x8B51; + public static inline var FLOAT_VEC4 = 0x8B52; + public static inline var INT_VEC2 = 0x8B53; + public static inline var INT_VEC3 = 0x8B54; + public static inline var INT_VEC4 = 0x8B55; + public static inline var BOOL = 0x8B56; + public static inline var BOOL_VEC2 = 0x8B57; + public static inline var BOOL_VEC3 = 0x8B58; + public static inline var BOOL_VEC4 = 0x8B59; + public static inline var FLOAT_MAT2 = 0x8B5A; + public static inline var FLOAT_MAT3 = 0x8B5B; + public static inline var FLOAT_MAT4 = 0x8B5C; + public static inline var SAMPLER_2D = 0x8B5E; + public static inline var SAMPLER_CUBE = 0x8B60; + + public static inline var VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; + public static inline var VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; + public static inline var VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; + public static inline var VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; + public static inline var VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; + public static inline var VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; + public static inline var VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; + + public static inline var VERTEX_PROGRAM_POINT_SIZE = 0x8642; + public static inline var POINT_SPRITE = 0x8861; + + public static inline var COMPILE_STATUS = 0x8B81; + + public static inline var LOW_FLOAT = 0x8DF0; + public static inline var MEDIUM_FLOAT = 0x8DF1; + public static inline var HIGH_FLOAT = 0x8DF2; + public static inline var LOW_INT = 0x8DF3; + public static inline var MEDIUM_INT = 0x8DF4; + public static inline var HIGH_INT = 0x8DF5; + + public static inline var FRAMEBUFFER = 0x8D40; + public static inline var RENDERBUFFER = 0x8D41; + + public static inline var RGBA4 = 0x8056; + public static inline var RGB5_A1 = 0x8057; + public static inline var RGB565 = 0x8D62; + public static inline var DEPTH_COMPONENT16 = 0x81A5; + public static inline var STENCIL_INDEX = 0x1901; + public static inline var STENCIL_INDEX8 = 0x8D48; + public static inline var DEPTH_STENCIL = 0x84F9; + + public static inline var RENDERBUFFER_WIDTH = 0x8D42; + public static inline var RENDERBUFFER_HEIGHT = 0x8D43; + public static inline var RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; + public static inline var RENDERBUFFER_RED_SIZE = 0x8D50; + public static inline var RENDERBUFFER_GREEN_SIZE = 0x8D51; + public static inline var RENDERBUFFER_BLUE_SIZE = 0x8D52; + public static inline var RENDERBUFFER_ALPHA_SIZE = 0x8D53; + public static inline var RENDERBUFFER_DEPTH_SIZE = 0x8D54; + public static inline var RENDERBUFFER_STENCIL_SIZE = 0x8D55; + + public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; + public static inline var FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; + public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; + public static inline var FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; + + public static inline var COLOR_ATTACHMENT0 = 0x8CE0; + public static inline var DEPTH_ATTACHMENT = 0x8D00; + public static inline var STENCIL_ATTACHMENT = 0x8D20; + public static inline var DEPTH_STENCIL_ATTACHMENT = 0x821A; + + public static inline var NONE = 0; + + public static inline var FRAMEBUFFER_COMPLETE = 0x8CD5; + public static inline var FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; + public static inline var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; + public static inline var FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; + public static inline var FRAMEBUFFER_UNSUPPORTED = 0x8CDD; + + public static inline var FRAMEBUFFER_BINDING = 0x8CA6; + public static inline var RENDERBUFFER_BINDING = 0x8CA7; + public static inline var MAX_RENDERBUFFER_SIZE = 0x84E8; + + public static inline var INVALID_FRAMEBUFFER_OPERATION = 0x0506; + + public static inline var UNPACK_FLIP_Y_WEBGL = 0x9240; + public static inline var UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; + public static inline var CONTEXT_LOST_WEBGL = 0x9242; + public static inline var UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243; + public static inline var BROWSER_DEFAULT_WEBGL = 0x9244; + + public static var version (get, null):Int; + + #if js + private static var context:RenderingContext; + #end + + + public static inline function activeTexture (texture:Int):Void { + + #if js + context.activeTexture (texture); + #else + lime_gl_active_texture (texture); + #end + + } + + + public static inline function attachShader (program:GLProgram, shader:GLShader):Void { + + #if js + context.attachShader (program, shader); + #else + program.attach (shader); + lime_gl_attach_shader (program.id, shader.id); + #end + + } + + + public static inline function bindAttribLocation (program:GLProgram, index:Int, name:String):Void { + + #if js + context.bindAttribLocation (program, index, name); + #else + lime_gl_bind_attrib_location (program.id, index, name); + #end + + } + + + public static inline function bindBuffer (target:Int, buffer:GLBuffer):Void { + + #if js + context.bindBuffer (target, buffer); + #else + lime_gl_bind_buffer (target, buffer == null ? 0 : buffer.id); + #end + + } + + + public static inline function bindFramebuffer (target:Int, framebuffer:GLFramebuffer):Void { + + #if js + context.bindFramebuffer (target, framebuffer); + #else + lime_gl_bind_framebuffer (target, framebuffer == null ? 0 : framebuffer.id); + #end + + } + + + public static inline function bindRenderbuffer (target:Int, renderbuffer:GLRenderbuffer):Void { + + #if js + context.bindRenderbuffer (target, renderbuffer); + #else + lime_gl_bind_renderbuffer (target, renderbuffer == null ? 0 : renderbuffer.id); + #end + + } + + + public static inline function bindTexture (target:Int, texture:GLTexture):Void { + + #if js + context.bindTexture (target, texture); + #else + lime_gl_bind_texture(target, texture == null ? 0 : texture.id); + #end + + } + + + public static inline function blendColor (red:Float, green:Float, blue:Float, alpha:Float):Void { + + #if js + context.blendColor (red, green, blue, alpha); + #else + lime_gl_blend_color (red, green, blue, alpha); + #end + + } + + + public static inline function blendEquation (mode:Int):Void { + + #if js + context.blendEquation (mode); + #else + lime_gl_blend_equation (mode); + #end + + } + + + public static inline function blendEquationSeparate (modeRGB:Int, modeAlpha:Int):Void { + + #if js + context.blendEquationSeparate (modeRGB, modeAlpha); + #else + lime_gl_blend_equation_separate (modeRGB, modeAlpha); + #end + + } + + + public static inline function blendFunc (sfactor:Int, dfactor:Int):Void { + + #if js + context.blendFunc (sfactor, dfactor); + #else + lime_gl_blend_func (sfactor, dfactor); + #end + + } + + + public static inline function blendFuncSeparate (srcRGB:Int, dstRGB:Int, srcAlpha:Int, dstAlpha:Int):Void { + + #if js + context.blendFuncSeparate (srcRGB, dstRGB, srcAlpha, dstAlpha); + #else + lime_gl_blend_func_separate (srcRGB, dstRGB, srcAlpha, dstAlpha); + #end + + } + + + public static inline function bufferData (target:Int, data:ArrayBufferView, usage:Int):Void { + + #if js + context.bufferData (target, data, usage); + #else + lime_gl_buffer_data (target, data.getByteBuffer (), data.getStart (), data.getLength (), usage); + #end + + } + + + public static inline function bufferSubData (target:Int, offset:Int, data:ArrayBufferView):Void { + + #if js + context.bufferSubData (target, offset, data); + #else + lime_gl_buffer_sub_data (target, offset, data.getByteBuffer (), data.getStart (), data.getLength ()); + #end + + } + + + public static inline function checkFramebufferStatus (target:Int):Int { + + #if js + return context.checkFramebufferStatus (target); + #else + return lime_gl_check_framebuffer_status (target); + #end + + } + + + public static inline function clear (mask:Int):Void { + + #if js + context.clear (mask); + #else + lime_gl_clear (mask); + #end + + } + + + public static inline function clearColor (red:Float, green:Float, blue:Float, alpha:Float):Void { + + #if js + context.clearColor (red, green, blue, alpha); + #else + lime_gl_clear_color (red, green, blue, alpha); + #end + + } + + + public static inline function clearDepth (depth:Float):Void { + + #if js + context.clearDepth (depth); + #else + lime_gl_clear_depth (depth); + #end + + } + + + public static inline function clearStencil (s:Int):Void { + + #if js + context.clearStencil (s); + #else + lime_gl_clear_stencil (s); + #end + + } + + + public static inline function colorMask (red:Bool, green:Bool, blue:Bool, alpha:Bool):Void { + + #if js + context.colorMask (red, green, blue, alpha); + #else + lime_gl_color_mask (red, green, blue, alpha); + #end + + } + + + public static inline function compileShader (shader:GLShader):Void { + + #if js + context.compileShader (shader); + #else + lime_gl_compile_shader (shader.id); + #end + + } + + + public static inline function compressedTexImage2D (target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, data:ArrayBufferView):Void { + + #if js + context.compressedTexImage2D (target, level, internalformat, width, height, border, data); + #else + lime_gl_compressed_tex_image_2d (target, level, internalformat, width, height, border, data == null ? null : data.getByteBuffer (), data == null ? null : data.getStart ()); + #end + + } + + + public static inline function compressedTexSubImage2D (target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, data:ArrayBufferView):Void { + + #if js + context.compressedTexSubImage2D (target, level, xoffset, yoffset, width, height, format, data); + #else + lime_gl_compressed_tex_sub_image_2d (target, level, xoffset, yoffset, width, height, format, data == null ? null : data.getByteBuffer (), data == null ? null : data.getStart ()); + #end + + } + + + public static inline function copyTexImage2D (target:Int, level:Int, internalformat:Int, x:Int, y:Int, width:Int, height:Int, border:Int):Void { + + #if js + context.copyTexImage2D (target, level, internalformat, x, y, width, height, border); + #else + lime_gl_copy_tex_image_2d (target, level, internalformat, x, y, width, height, border); + #end + + } + + + public static inline function copyTexSubImage2D (target:Int, level:Int, xoffset:Int, yoffset:Int, x:Int, y:Int, width:Int, height:Int):Void { + + #if js + context.copyTexSubImage2D (target, level, xoffset, yoffset, x, y, width, height); + #else + lime_gl_copy_tex_sub_image_2d (target, level, xoffset, yoffset, x, y, width, height); + #end + + } + + + public static inline function createBuffer ():GLBuffer { + + #if js + return context.createBuffer (); + #else + return new GLBuffer (version, lime_gl_create_buffer ()); + #end + + } + + + public static inline function createFramebuffer ():GLFramebuffer { + + #if js + return context.createFramebuffer (); + #else + return new GLFramebuffer (version, lime_gl_create_framebuffer ()); + #end + + } + + + public static inline function createProgram ():GLProgram { + + #if js + return context.createProgram (); + #else + return new GLProgram (version, lime_gl_create_program ()); + #end + + } + + + public static inline function createRenderbuffer ():GLRenderbuffer { + + #if js + return context.createRenderbuffer (); + #else + return new GLRenderbuffer (version, lime_gl_create_render_buffer ()); + #end + + } + + + public static inline function createShader (type:Int):GLShader { + + #if js + return context.createShader (type); + #else + return new GLShader (version, lime_gl_create_shader (type)); + #end + + } + + + public static inline function createTexture ():GLTexture { + + #if js + return context.createTexture (); + #else + return new GLTexture (version, lime_gl_create_texture ()); + #end + + } + + + public static inline function cullFace (mode:Int):Void { + + #if js + context.cullFace (mode); + #else + lime_gl_cull_face (mode); + #end + + } + + + public static inline function deleteBuffer (buffer:GLBuffer):Void { + + #if js + context.deleteBuffer (buffer); + #else + lime_gl_delete_buffer (buffer.id); + buffer.invalidate (); + #end + + } + + + public static inline function deleteFramebuffer (framebuffer:GLFramebuffer):Void { + + #if js + context.deleteFramebuffer (framebuffer); + #else + lime_gl_delete_framebuffer (framebuffer.id); + framebuffer.invalidate (); + #end + + } + + + public static inline function deleteProgram (program:GLProgram):Void { + + #if js + context.deleteProgram (program); + #else + lime_gl_delete_program (program.id); + program.invalidate (); + #end + + } + + + public static inline function deleteRenderbuffer (renderbuffer:GLRenderbuffer):Void { + + #if js + context.deleteRenderbuffer (renderbuffer); + #else + lime_gl_delete_render_buffer (renderbuffer.id); + renderbuffer.invalidate (); + #end + + } + + + public static inline function deleteShader (shader:GLShader):Void { + + #if js + context.deleteShader (shader); + #else + lime_gl_delete_shader (shader.id); + shader.invalidate (); + #end + + } + + + public static inline function deleteTexture (texture:GLTexture):Void { + + #if js + context.deleteTexture (texture); + #else + lime_gl_delete_texture (texture.id); + texture.invalidate (); + #end + + } + + + public static inline function depthFunc (func:Int):Void { + + #if js + context.depthFunc (func); + #else + lime_gl_depth_func (func); + #end + + } + + + public static inline function depthMask (flag:Bool):Void { + + #if js + context.depthMask (flag); + #else + lime_gl_depth_mask (flag); + #end + + } + + + public static inline function depthRange (zNear:Float, zFar:Float):Void { + + #if js + context.depthRange (zNear, zFar); + #else + lime_gl_depth_range (zNear, zFar); + #end + + } + + + public static inline function detachShader (program:GLProgram, shader:GLShader):Void { + + #if js + context.detachShader (program, shader); + #else + lime_gl_detach_shader (program.id, shader.id); + #end + + } + + + public static inline function disable (cap:Int):Void { + + #if js + context.disable (cap); + #else + lime_gl_disable (cap); + #end + + } + + + public static inline function disableVertexAttribArray (index:Int):Void { + + #if js + context.disableVertexAttribArray (index); + #else + lime_gl_disable_vertex_attrib_array (index); + #end + + } + + + public static inline function drawArrays (mode:Int, first:Int, count:Int):Void { + + #if js + context.drawArrays (mode, first, count); + #else + lime_gl_draw_arrays (mode, first, count); + #end + + } + + + public static inline function drawElements (mode:Int, count:Int, type:Int, offset:Int):Void { + + #if js + context.drawElements (mode, count, type, offset); + #else + lime_gl_draw_elements (mode, count, type, offset); + #end + + } + + + public static inline function enable (cap:Int):Void { + + #if js + context.enable (cap); + #else + lime_gl_enable (cap); + #end + + } + + + public static inline function enableVertexAttribArray (index:Int):Void { + + #if js + context.enableVertexAttribArray (index); + #else + lime_gl_enable_vertex_attrib_array (index); + #end + + } + + + public static inline function finish ():Void { + + #if js + context.finish (); + #else + lime_gl_finish (); + #end + + } + + + public static inline function flush ():Void { + + #if js + context.flush (); + #else + lime_gl_flush (); + #end + + } + + + public static inline function framebufferRenderbuffer (target:Int, attachment:Int, renderbuffertarget:Int, renderbuffer:GLRenderbuffer):Void { + + #if js + context.framebufferRenderbuffer (target, attachment, renderbuffertarget, renderbuffer); + #else + lime_gl_framebuffer_renderbuffer (target, attachment, renderbuffertarget, renderbuffer.id); + #end + + } + + + public static inline function framebufferTexture2D (target:Int, attachment:Int, textarget:Int, texture:GLTexture, level:Int):Void { + + #if js + context.framebufferTexture2D (target, attachment, textarget, texture, level); + #else + lime_gl_framebuffer_texture2D (target, attachment, textarget, texture.id, level); + #end + + } + + + public static inline function frontFace (mode:Int):Void { + + #if js + context.frontFace (mode); + #else + lime_gl_front_face (mode); + #end + + } + + + public static inline function generateMipmap (target:Int):Void { + + #if js + context.generateMipmap (target); + #else + lime_gl_generate_mipmap (target); + #end + + } + + + public static inline function getActiveAttrib (program:GLProgram, index:Int):GLActiveInfo { + + #if js + return context.getActiveAttrib (program, index); + #else + return lime_gl_get_active_attrib (program.id, index); + #end + + } + + + public static inline function getActiveUniform (program:GLProgram, index:Int):GLActiveInfo { + + #if js + return context.getActiveUniform (program, index); + #else + return lime_gl_get_active_uniform (program.id, index); + #end + + } + + + public static inline function getAttachedShaders (program:GLProgram):Array { + + #if js + return context.getAttachedShaders (program); + #else + return program.getShaders (); + #end + + } + + + public static inline function getAttribLocation (program:GLProgram, name:String):Int { + + #if js + return context.getAttribLocation (program, name); + #else + return lime_gl_get_attrib_location (program.id, name); + #end + + } + + + public static inline function getBufferParameter (target:Int, pname:Int):Int /*Dynamic*/ { + + #if js + return context.getBufferParameter (target, pname); + #else + return lime_gl_get_buffer_paramerter (target, pname); + #end + + } + + + public static inline function getContextAttributes ():GLContextAttributes { + + #if js + return context.getContextAttributes (); + #else + var base = lime_gl_get_context_attributes (); + base.premultipliedAlpha = false; + base.preserveDrawingBuffer = false; + return base; + #end + + } + + + public static inline function getError ():Int { + + #if js + return context.getError (); + #else + return lime_gl_get_error (); + #end + + } + + + public static inline function getExtension (name:String):Dynamic { + + #if js + return context.getExtension (name); + #else + //todo?! + return null; + // return lime_gl_get_extension(name); + #end + + } + + + public static inline function getFramebufferAttachmentParameter (target:Int, attachment:Int, pname:Int):Int /*Dynamic*/ { + + #if js + return context.getFramebufferAttachmentParameter (target, attachment, pname); + #else + return lime_gl_get_framebuffer_attachment_parameter (target, attachment, pname); + #end + + } + + + public static inline function getParameter (pname:Int):Dynamic { + + #if js + return context.getParameter (pname); + #else + return lime_gl_get_parameter (pname); + #end + + } + + + public static inline function getProgramInfoLog (program:GLProgram):String { + + #if js + return context.getProgramInfoLog (program); + #else + return lime_gl_get_program_info_log (program.id); + #end + + } + + + public static inline function getProgramParameter (program:GLProgram, pname:Int):Int { + + #if js + return context.getProgramParameter (program, pname); + #else + return lime_gl_get_program_parameter (program.id, pname); + #end + + } + + + public static inline function getRenderbufferParameter (target:Int, pname:Int):Int /*Dynamic*/ { + + #if js + return context.getRenderbufferParameter (target, pname); + #else + return lime_gl_get_render_buffer_parameter (target, pname); + #end + + } + + + public static inline function getShaderInfoLog (shader:GLShader):String { + + #if js + return context.getShaderInfoLog (shader); + #else + return lime_gl_get_shader_info_log (shader.id); + #end + + } + + + public static inline function getShaderParameter (shader:GLShader, pname:Int):Int { + + #if js + return context.getShaderParameter (shader, pname); + #else + return lime_gl_get_shader_parameter (shader.id, pname); + #end + + } + + + public static inline function getShaderPrecisionFormat (shadertype:Int, precisiontype:Int):GLShaderPrecisionFormat { + + #if js + return context.getShaderPrecisionFormat (shadertype, precisiontype); + #else + return lime_gl_get_shader_precision_format (shadertype, precisiontype); + #end + + } + + + public static inline function getShaderSource (shader:GLShader):String { + + #if js + return context.getShaderSource (shader); + #else + return lime_gl_get_shader_source (shader.id); + #end + + } + + + public static inline function getSupportedExtensions ():Array { + + #if js + return context.getSupportedExtensions (); + #else + var result = new Array (); + lime_gl_get_supported_extensions (result); + return result; + #end + + } + + + public static inline function getTexParameter (target:Int, pname:Int):Int /*Dynamic*/ { + + #if js + return context.getTexParameter (target, pname); + #else + return lime_gl_get_tex_parameter (target, pname); + #end + + } + + + public static inline function getUniform (program:GLProgram, location:GLUniformLocation):Dynamic { + + #if js + return context.getUniform (program, location); + #else + return lime_gl_get_uniform (program.id, location); + #end + + } + + + public static inline function getUniformLocation (program:GLProgram, name:String):GLUniformLocation { + + #if js + return context.getUniformLocation (program, name); + #else + return lime_gl_get_uniform_location (program.id, name); + #end + + } + + + public static inline function getVertexAttrib (index:Int, pname:Int):Int /*Dynamic*/ { + + #if js + return context.getVertexAttrib (index, pname); + #else + return lime_gl_get_vertex_attrib (index, pname); + #end + + } + + + public static inline function getVertexAttribOffset (index:Int, pname:Int):Int { + + #if js + return context.getVertexAttribOffset (index, pname); + #else + return lime_gl_get_vertex_attrib_offset (index, pname); + #end + + } + + + public static inline function hint (target:Int, mode:Int):Void { + + #if js + context.hint (target, mode); + #else + lime_gl_hint (target, mode); + #end + + } + + + public static inline function isBuffer (buffer:GLBuffer):Bool { + + #if js + return context.isBuffer (buffer); + #else + return buffer != null && buffer.id > 0 && lime_gl_is_buffer (buffer.id); + #end + + } + + + // This is non-static + // public function isContextLost():Bool { return false; } + + + public static inline function isEnabled (cap:Int):Bool { + + #if js + return context.isEnabled (cap); + #else + return lime_gl_is_enabled (cap); + #end + + } + + + public static inline function isFramebuffer (framebuffer:GLFramebuffer):Bool { + + #if js + return context.isFramebuffer (framebuffer); + #else + return framebuffer != null && framebuffer.id > 0 && lime_gl_is_framebuffer (framebuffer.id); + #end + + } + + + public static inline function isProgram (program:GLProgram):Bool { + + #if js + return context.isProgram (program); + #else + return program != null && program.id > 0 && lime_gl_is_program (program.id); + #end + + } + + + public static inline function isRenderbuffer (renderbuffer:GLRenderbuffer):Bool { + + #if js + return context.isRenderbuffer (renderbuffer); + #else + return renderbuffer != null && renderbuffer.id > 0 && lime_gl_is_renderbuffer (renderbuffer.id); + #end + + } + + + public static inline function isShader (shader:GLShader):Bool { + + #if js + return context.isShader (shader); + #else + return shader != null && shader.id > 0 && lime_gl_is_shader (shader.id); + #end + + } + + + public static inline function isTexture (texture:GLTexture):Bool { + + #if js + return context.isTexture (texture); + #else + return texture != null && texture.id > 0 && lime_gl_is_texture (texture.id); + #end + + } + + + public static inline function lineWidth (width:Float):Void { + + #if js + context.lineWidth (width); + #else + lime_gl_line_width (width); + #end + + } + + + public static inline function linkProgram (program:GLProgram):Void { + + #if js + context.linkProgram (program); + #else + lime_gl_link_program (program.id); + #end + + } + + + public static inline function pixelStorei (pname:Int, param:Int):Void { + + #if js + context.pixelStorei (pname, param); + #else + lime_gl_pixel_storei (pname, param); + #end + + } + + + public static inline function polygonOffset (factor:Float, units:Float):Void { + + #if js + context.polygonOffset (factor, units); + #else + lime_gl_polygon_offset (factor, units); + #end + + } + + + public static inline function readPixels (x:Int, y:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void { + + #if js + context.readPixels (x, y, width, height, format, type, pixels); + #else + lime_gl_read_pixels (x, y, width, height, format, type, pixels == null ? null : pixels.getByteBuffer (), pixels == null ? null : pixels.getStart ()); + #end + + } + + + public static inline function renderbufferStorage (target:Int, internalformat:Int, width:Int, height:Int):Void { + + #if js + context.renderbufferStorage (target, internalformat, width, height); + #else + lime_gl_renderbuffer_storage (target, internalformat, width, height); + #end + + } + + + public static inline function sampleCoverage (value:Float, invert:Bool):Void { + + #if js + context.sampleCoverage (value, invert); + #else + lime_gl_sample_coverage (value, invert); + #end + + } + + + public static inline function scissor (x:Int, y:Int, width:Int, height:Int):Void { + + #if js + context.scissor (x, y, width, height); + #else + lime_gl_scissor (x, y, width, height); + #end + + } + + + public static inline function shaderSource (shader:GLShader, source:String):Void { + + #if js + context.shaderSource (shader, source); + #else + lime_gl_shader_source (shader.id, source); + #end + + } + + + public static inline function stencilFunc (func:Int, ref:Int, mask:Int):Void { + + #if js + context.stencilFunc (func, ref, mask); + #else + lime_gl_stencil_func (func, ref, mask); + #end + + } + + + public static inline function stencilFuncSeparate (face:Int, func:Int, ref:Int, mask:Int):Void { + + #if js + context.stencilFuncSeparate (face, func, ref, mask); + #else + lime_gl_stencil_func_separate (face, func, ref, mask); + #end + + } + + + public static inline function stencilMask (mask:Int):Void { + + #if js + context.stencilMask (mask); + #else + lime_gl_stencil_mask (mask); + #end + + } + + + public static inline function stencilMaskSeparate (face:Int, mask:Int):Void { + + #if js + context.stencilMaskSeparate (face, mask); + #else + lime_gl_stencil_mask_separate (face, mask); + #end + + } + + + public static inline function stencilOp (fail:Int, zfail:Int, zpass:Int):Void { + + #if js + context.stencilOp (fail, zfail, zpass); + #else + lime_gl_stencil_op (fail, zfail, zpass); + #end + + } + + + public static inline function stencilOpSeparate (face:Int, fail:Int, zfail:Int, zpass:Int):Void { + + #if js + context.stencilOpSeparate (face, fail, zfail, zpass); + #else + lime_gl_stencil_op_separate (face, fail, zfail, zpass); + #end + + } + + + public static inline function texImage2D (target:Int, level:Int, internalformat:Int, width:Int, height:Int, border:Int, format:Int, type:Int, pixels:ArrayBufferView):Void { + + #if js + context.texImage2D (target, level, internalformat, width, height, border, format, type, pixels); + #else + lime_gl_tex_image_2d (target, level, internalformat, width, height, border, format, type, pixels == null ? null : pixels.getByteBuffer (), pixels == null ? null : pixels.getStart ()); + #end + + } + + + public static inline function texParameterf (target:Int, pname:Int, param:Float):Void { + + #if js + context.texParameterf (target, pname, param); + #else + lime_gl_tex_parameterf (target, pname, param); + #end + + } + + + public static inline function texParameteri (target:Int, pname:Int, param:Int):Void { + + #if js + context.texParameteri (target, pname, param); + #else + lime_gl_tex_parameteri (target, pname, param); + #end + + } + + + public static inline function texSubImage2D (target:Int, level:Int, xoffset:Int, yoffset:Int, width:Int, height:Int, format:Int, type:Int, pixels:ArrayBufferView):Void { + + #if js + context.texSubImage2D (target, level, xoffset, yoffset, width, height, format, type, pixels); + #else + lime_gl_tex_sub_image_2d (target, level, xoffset, yoffset, width, height, format, type, pixels == null ? null : pixels.getByteBuffer(), pixels == null ? null : pixels.getStart()); + #end + + } + + + public static inline function uniform1f (location:GLUniformLocation, x:Float):Void { + + #if js + context.uniform1f (location, x); + #else + lime_gl_uniform1f (location, x); + #end + + } + + + public static inline function uniform1fv (location:GLUniformLocation, x:Float32Array):Void { + + #if js + context.uniform1fv (location, x); + #else + lime_gl_uniform1fv (location, x.getByteBuffer ()); + #end + + } + + + public static inline function uniform1i (location:GLUniformLocation, x:Int):Void { + + #if js + context.uniform1i (location, x); + #else + lime_gl_uniform1i (location, x); + #end + + } + + + public static inline function uniform1iv (location:GLUniformLocation, v:Int32Array):Void { + + #if js + context.uniform1iv (location, v); + #else + lime_gl_uniform1iv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniform2f (location:GLUniformLocation, x:Float, y:Float):Void { + + #if js + context.uniform2f (location, x, y); + #else + lime_gl_uniform2f (location, x, y); + #end + + } + + + public static inline function uniform2fv (location:GLUniformLocation, v:Float32Array):Void { + + #if js + context.uniform2fv (location, v); + #else + lime_gl_uniform2fv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniform2i (location:GLUniformLocation, x:Int, y:Int):Void { + + #if js + context.uniform2i (location, x, y); + #else + lime_gl_uniform2i (location, x, y); + #end + + } + + + public static inline function uniform2iv (location:GLUniformLocation, v:Int32Array):Void { + + #if js + context.uniform2iv (location, v); + #else + lime_gl_uniform2iv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniform3f (location:GLUniformLocation, x:Float, y:Float, z:Float):Void { + + #if js + context.uniform3f (location, x, y, z); + #else + lime_gl_uniform3f (location, x, y, z); + #end + + } + + + public static inline function uniform3fv (location:GLUniformLocation, v:Float32Array):Void { + + #if js + context.uniform3fv (location, v); + #else + lime_gl_uniform3fv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniform3i (location:GLUniformLocation, x:Int, y:Int, z:Int):Void { + + #if js + context.uniform3i (location, x, y, z); + #else + lime_gl_uniform3i (location, x, y, z); + #end + + } + + + public static inline function uniform3iv (location:GLUniformLocation, v:Int32Array):Void { + + #if js + context.uniform3iv (location, v); + #else + lime_gl_uniform3iv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniform4f (location:GLUniformLocation, x:Float, y:Float, z:Float, w:Float):Void { + + #if js + context.uniform4f (location, x, y, z, w); + #else + lime_gl_uniform4f (location, x, y, z, w); + #end + + } + + + public static inline function uniform4fv (location:GLUniformLocation, v:Float32Array):Void { + + #if js + context.uniform4fv (location, v); + #else + lime_gl_uniform4fv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniform4i (location:GLUniformLocation, x:Int, y:Int, z:Int, w:Int):Void { + + #if js + context.uniform4i (location, x, y, z, w); + #else + lime_gl_uniform4i (location, x, y, z, w); + #end + + } + + + public static inline function uniform4iv (location:GLUniformLocation, v:Int32Array):Void { + + #if js + context.uniform4iv (location, v); + #else + lime_gl_uniform4iv (location, v.getByteBuffer ()); + #end + + } + + + public static inline function uniformMatrix2fv (location:GLUniformLocation, transpose:Bool, v:Float32Array):Void { + + #if js + context.uniformMatrix2fv (location, transpose, v); + #else + lime_gl_uniform_matrix (location, transpose, v.getByteBuffer (), 2); + #end + + } + + + public static inline function uniformMatrix3fv (location:GLUniformLocation, transpose:Bool, v:Float32Array):Void { + + #if js + context.uniformMatrix3fv (location, transpose, v); + #else + lime_gl_uniform_matrix (location, transpose, v.getByteBuffer (), 3); + #end + + } + + + public static inline function uniformMatrix4fv (location:GLUniformLocation, transpose:Bool, v:Float32Array):Void { + + #if js + context.uniformMatrix4fv (location, transpose, v); + #else + lime_gl_uniform_matrix (location, transpose, v.getByteBuffer (), 4); + #end + + } + + + /*public static inline function uniformMatrix3D(location:GLUniformLocation, transpose:Bool, matrix:Matrix3D):Void { + + lime_gl_uniform_matrix(location, transpose, Float32Array.fromMatrix(matrix).getByteBuffer() , 4); + + }*/ + + + public static inline function useProgram (program:GLProgram):Void { + + #if js + context.useProgram (program); + #else + lime_gl_use_program (program == null ? 0 : program.id); + #end + + } + + + public static inline function validateProgram (program:GLProgram):Void { + + #if js + context.validateProgram (program); + #else + lime_gl_validate_program (program.id); + #end + + } + + + public static inline function vertexAttrib1f (indx:Int, x:Float):Void { + + #if js + context.vertexAttrib1f (indx, x); + #else + lime_gl_vertex_attrib1f (indx, x); + #end + + } + + + public static inline function vertexAttrib1fv (indx:Int, values:Float32Array):Void { + + #if js + context.vertexAttrib1fv (indx, values); + #else + lime_gl_vertex_attrib1fv (indx, values.getByteBuffer ()); + #end + + } + + + public static inline function vertexAttrib2f (indx:Int, x:Float, y:Float):Void { + + #if js + context.vertexAttrib2f (indx, x, y); + #else + lime_gl_vertex_attrib2f (indx, x, y); + #end + + } + + + public static inline function vertexAttrib2fv (indx:Int, values:Float32Array):Void { + + #if js + context.vertexAttrib2fv (indx, values); + #else + lime_gl_vertex_attrib2fv (indx, values.getByteBuffer()); + #end + + } + + + public static inline function vertexAttrib3f (indx:Int, x:Float, y:Float, z:Float):Void { + + #if js + context.vertexAttrib3f (indx, x, y, z); + #else + lime_gl_vertex_attrib3f (indx, x, y, z); + #end + + } + + + public static inline function vertexAttrib3fv (indx:Int, values:Float32Array):Void { + + #if js + context.vertexAttrib3fv (indx, values); + #else + lime_gl_vertex_attrib3fv (indx, values.getByteBuffer ()); + #end + + } + + + public static inline function vertexAttrib4f (indx:Int, x:Float, y:Float, z:Float, w:Float):Void { + + #if js + context.vertexAttrib4f (indx, x, y, z, w); + #else + lime_gl_vertex_attrib4f (indx, x, y, z, w); + #end + + } + + + public static inline function vertexAttrib4fv (indx:Int, values:Float32Array):Void { + + #if js + context.vertexAttrib4fv (indx, values); + #else + lime_gl_vertex_attrib4fv (indx, values.getByteBuffer ()); + #end + + } + + + public static inline function vertexAttribPointer (indx:Int, size:Int, type:Int, normalized:Bool, stride:Int, offset:Int):Void { + + #if js + context.vertexAttribPointer (indx, size, type, normalized, stride, offset); + #else + lime_gl_vertex_attrib_pointer (indx, size, type, normalized, stride, offset); + #end + + } + + + public static inline function viewport (x:Int, y:Int, width:Int, height:Int):Void { + + #if js + context.viewport (x, y, width, height); + #else + lime_gl_viewport (x, y, width, height); + #end + + } + + + private static function get_version ():Int { return 2; } + + + #if (cpp || neko) + + private static var lime_gl_active_texture = System.load ("lime", "lime_gl_active_texture", 1); + private static var lime_gl_attach_shader = System.load ("lime", "lime_gl_attach_shader", 2); + private static var lime_gl_bind_attrib_location = System.load ("lime", "lime_gl_bind_attrib_location", 3); + private static var lime_gl_bind_buffer = System.load ("lime", "lime_gl_bind_buffer", 2); + private static var lime_gl_bind_framebuffer = System.load ("lime", "lime_gl_bind_framebuffer", 2); + private static var lime_gl_bind_renderbuffer = System.load ("lime", "lime_gl_bind_renderbuffer", 2); + private static var lime_gl_bind_texture = System.load ("lime", "lime_gl_bind_texture", 2); + private static var lime_gl_blend_color = System.load ("lime", "lime_gl_blend_color", 4); + private static var lime_gl_blend_equation = System.load ("lime", "lime_gl_blend_equation", 1); + private static var lime_gl_blend_equation_separate = System.load ("lime", "lime_gl_blend_equation_separate", 2); + private static var lime_gl_blend_func = System.load ("lime", "lime_gl_blend_func", 2); + private static var lime_gl_blend_func_separate = System.load ("lime", "lime_gl_blend_func_separate", 4); + private static var lime_gl_buffer_data = System.load ("lime", "lime_gl_buffer_data", 5); + private static var lime_gl_buffer_sub_data = System.load ("lime", "lime_gl_buffer_sub_data", 5); + private static var lime_gl_check_framebuffer_status = System.load ("lime", "lime_gl_check_framebuffer_status", 1); + private static var lime_gl_clear = System.load ("lime", "lime_gl_clear", 1); + private static var lime_gl_clear_color = System.load ("lime", "lime_gl_clear_color", 4); + private static var lime_gl_clear_depth = System.load ("lime", "lime_gl_clear_depth", 1); + private static var lime_gl_clear_stencil = System.load ("lime", "lime_gl_clear_stencil", 1); + private static var lime_gl_color_mask = System.load ("lime", "lime_gl_color_mask", 4); + private static var lime_gl_compile_shader = System.load ("lime", "lime_gl_compile_shader", 1); + private static var lime_gl_compressed_tex_image_2d = System.load ("lime", "lime_gl_compressed_tex_image_2d", -1); + private static var lime_gl_compressed_tex_sub_image_2d = System.load ("lime", "lime_gl_compressed_tex_sub_image_2d", -1); + private static var lime_gl_copy_tex_image_2d = System.load ("lime", "lime_gl_copy_tex_image_2d", -1); + private static var lime_gl_copy_tex_sub_image_2d = System.load ("lime", "lime_gl_copy_tex_sub_image_2d", -1); + private static var lime_gl_create_buffer = System.load ("lime", "lime_gl_create_buffer", 0); + private static var lime_gl_create_framebuffer = System.load ("lime", "lime_gl_create_framebuffer", 0); + private static var lime_gl_create_program = System.load ("lime", "lime_gl_create_program", 0); + private static var lime_gl_create_render_buffer = System.load ("lime", "lime_gl_create_render_buffer", 0); + private static var lime_gl_create_shader = System.load ("lime", "lime_gl_create_shader", 1); + private static var lime_gl_create_texture = System.load ("lime", "lime_gl_create_texture", 0); + private static var lime_gl_cull_face = System.load ("lime", "lime_gl_cull_face", 1); + private static var lime_gl_delete_buffer = System.load ("lime", "lime_gl_delete_buffer", 1); + private static var lime_gl_delete_framebuffer = System.load ("lime", "lime_gl_delete_framebuffer", 1); + private static var lime_gl_delete_program = System.load ("lime", "lime_gl_delete_program", 1); + private static var lime_gl_delete_render_buffer = System.load ("lime", "lime_gl_delete_render_buffer", 1); + private static var lime_gl_delete_shader = System.load ("lime", "lime_gl_delete_shader", 1); + private static var lime_gl_delete_texture = System.load ("lime", "lime_gl_delete_texture", 1); + private static var lime_gl_depth_func = System.load ("lime", "lime_gl_depth_func", 1); + private static var lime_gl_depth_mask = System.load ("lime", "lime_gl_depth_mask", 1); + private static var lime_gl_depth_range = System.load ("lime", "lime_gl_depth_range", 2); + private static var lime_gl_detach_shader = System.load ("lime", "lime_gl_detach_shader", 2); + private static var lime_gl_disable = System.load ("lime", "lime_gl_disable", 1); + private static var lime_gl_disable_vertex_attrib_array = System.load ("lime", "lime_gl_disable_vertex_attrib_array", 1); + private static var lime_gl_draw_arrays = System.load ("lime", "lime_gl_draw_arrays", 3); + private static var lime_gl_draw_elements = System.load ("lime", "lime_gl_draw_elements", 4); + private static var lime_gl_enable = System.load ("lime", "lime_gl_enable", 1); + private static var lime_gl_enable_vertex_attrib_array = System.load ("lime", "lime_gl_enable_vertex_attrib_array", 1); + private static var lime_gl_finish = System.load ("lime", "lime_gl_finish", 0); + private static var lime_gl_flush = System.load ("lime", "lime_gl_flush", 0); + private static var lime_gl_framebuffer_renderbuffer = System.load ("lime", "lime_gl_framebuffer_renderbuffer", 4); + private static var lime_gl_framebuffer_texture2D = System.load ("lime", "lime_gl_framebuffer_texture2D", 5); + private static var lime_gl_front_face = System.load ("lime", "lime_gl_front_face", 1); + private static var lime_gl_generate_mipmap = System.load ("lime", "lime_gl_generate_mipmap", 1); + private static var lime_gl_get_active_attrib = System.load ("lime", "lime_gl_get_active_attrib", 2); + private static var lime_gl_get_active_uniform = System.load ("lime", "lime_gl_get_active_uniform", 2); + private static var lime_gl_get_attrib_location = System.load ("lime", "lime_gl_get_attrib_location", 2); + private static var lime_gl_get_buffer_paramerter = System.load ("lime", "lime_gl_get_buffer_paramerter", 2); + private static var lime_gl_get_context_attributes = System.load ("lime", "lime_gl_get_context_attributes", 0); + private static var lime_gl_get_error = System.load ("lime", "lime_gl_get_error", 0); + private static var lime_gl_get_framebuffer_attachment_parameter = System.load ("lime", "lime_gl_get_framebuffer_attachment_parameter", 3); + private static var lime_gl_get_parameter = System.load ("lime", "lime_gl_get_parameter", 1); + // static var lime_gl_get_extension = System.load ("lime", "lime_gl_get_extension", 1); + private static var lime_gl_get_program_info_log = System.load ("lime", "lime_gl_get_program_info_log", 1); + private static var lime_gl_get_program_parameter = System.load ("lime", "lime_gl_get_program_parameter", 2); + private static var lime_gl_get_render_buffer_parameter = System.load ("lime", "lime_gl_get_render_buffer_parameter", 2); + private static var lime_gl_get_shader_info_log = System.load ("lime", "lime_gl_get_shader_info_log", 1); + private static var lime_gl_get_shader_parameter = System.load ("lime", "lime_gl_get_shader_parameter", 2); + private static var lime_gl_get_shader_precision_format = System.load ("lime", "lime_gl_get_shader_precision_format", 2); + private static var lime_gl_get_shader_source = System.load ("lime", "lime_gl_get_shader_source", 1); + private static var lime_gl_get_supported_extensions = System.load ("lime", "lime_gl_get_supported_extensions", 1); + private static var lime_gl_get_tex_parameter = System.load ("lime", "lime_gl_get_tex_parameter", 2); + private static var lime_gl_get_uniform = System.load ("lime", "lime_gl_get_uniform", 2); + private static var lime_gl_get_uniform_location = System.load ("lime", "lime_gl_get_uniform_location", 2); + private static var lime_gl_get_vertex_attrib = System.load ("lime", "lime_gl_get_vertex_attrib", 2); + private static var lime_gl_get_vertex_attrib_offset = System.load ("lime", "lime_gl_get_vertex_attrib_offset", 2); + private static var lime_gl_hint = System.load ("lime", "lime_gl_hint", 2); + private static var lime_gl_is_buffer = System.load ("lime", "lime_gl_is_buffer", 1); + private static var lime_gl_is_enabled = System.load ("lime", "lime_gl_is_enabled", 1); + private static var lime_gl_is_framebuffer = System.load ("lime", "lime_gl_is_framebuffer", 1); + private static var lime_gl_is_program = System.load ("lime", "lime_gl_is_program", 1); + private static var lime_gl_is_renderbuffer = System.load ("lime", "lime_gl_is_renderbuffer", 1); + private static var lime_gl_is_shader = System.load ("lime", "lime_gl_is_shader", 1); + private static var lime_gl_is_texture = System.load ("lime", "lime_gl_is_texture", 1); + private static var lime_gl_line_width = System.load ("lime", "lime_gl_line_width", 1); + private static var lime_gl_link_program = System.load ("lime", "lime_gl_link_program", 1); + private static var lime_gl_pixel_storei = System.load ("lime", "lime_gl_pixel_storei", 2); + private static var lime_gl_polygon_offset = System.load ("lime", "lime_gl_polygon_offset", 2); + private static var lime_gl_read_pixels = System.load ("lime", "lime_gl_read_pixels", -1); + private static var lime_gl_renderbuffer_storage = System.load ("lime", "lime_gl_renderbuffer_storage", 4); + private static var lime_gl_sample_coverage = System.load ("lime", "lime_gl_sample_coverage", 2); + private static var lime_gl_scissor = System.load ("lime", "lime_gl_scissor", 4); + private static var lime_gl_shader_source = System.load ("lime", "lime_gl_shader_source", 2); + private static var lime_gl_stencil_func = System.load ("lime", "lime_gl_stencil_func", 3); + private static var lime_gl_stencil_func_separate = System.load ("lime", "lime_gl_stencil_func_separate", 4); + private static var lime_gl_stencil_mask = System.load ("lime", "lime_gl_stencil_mask", 1); + private static var lime_gl_stencil_mask_separate = System.load ("lime", "lime_gl_stencil_mask_separate", 2); + private static var lime_gl_stencil_op = System.load ("lime", "lime_gl_stencil_op", 3); + private static var lime_gl_stencil_op_separate = System.load ("lime", "lime_gl_stencil_op_separate", 4); + private static var lime_gl_tex_image_2d = System.load ("lime", "lime_gl_tex_image_2d", -1); + private static var lime_gl_tex_parameterf = System.load ("lime", "lime_gl_tex_parameterf", 3); + private static var lime_gl_tex_parameteri = System.load ("lime", "lime_gl_tex_parameteri", 3); + private static var lime_gl_tex_sub_image_2d = System.load ("lime", "lime_gl_tex_sub_image_2d", -1); + private static var lime_gl_uniform1f = System.load ("lime", "lime_gl_uniform1f", 2); + private static var lime_gl_uniform1fv = System.load ("lime", "lime_gl_uniform1fv", 2); + private static var lime_gl_uniform1i = System.load ("lime", "lime_gl_uniform1i", 2); + private static var lime_gl_uniform1iv = System.load ("lime", "lime_gl_uniform1iv", 2); + private static var lime_gl_uniform2f = System.load ("lime", "lime_gl_uniform2f", 3); + private static var lime_gl_uniform2fv = System.load ("lime", "lime_gl_uniform2fv", 2); + private static var lime_gl_uniform2i = System.load ("lime", "lime_gl_uniform2i", 3); + private static var lime_gl_uniform2iv = System.load ("lime", "lime_gl_uniform2iv", 2); + private static var lime_gl_uniform3f = System.load ("lime", "lime_gl_uniform3f", 4); + private static var lime_gl_uniform3fv = System.load ("lime", "lime_gl_uniform3fv", 2); + private static var lime_gl_uniform3i = System.load ("lime", "lime_gl_uniform3i", 4); + private static var lime_gl_uniform3iv = System.load ("lime", "lime_gl_uniform3iv", 2); + private static var lime_gl_uniform4f = System.load ("lime", "lime_gl_uniform4f", 5); + private static var lime_gl_uniform4fv = System.load ("lime", "lime_gl_uniform4fv", 2); + private static var lime_gl_uniform4i = System.load ("lime", "lime_gl_uniform4i", 5); + private static var lime_gl_uniform4iv = System.load ("lime", "lime_gl_uniform4iv", 2); + private static var lime_gl_uniform_matrix = System.load ("lime", "lime_gl_uniform_matrix", 4); + private static var lime_gl_use_program = System.load ("lime", "lime_gl_use_program", 1); + private static var lime_gl_validate_program = System.load ("lime", "lime_gl_validate_program", 1); + private static var lime_gl_version = System.load ("lime", "lime_gl_version", 0); + private static var lime_gl_vertex_attrib1f = System.load ("lime", "lime_gl_vertex_attrib1f", 2); + private static var lime_gl_vertex_attrib1fv = System.load ("lime", "lime_gl_vertex_attrib1fv", 2); + private static var lime_gl_vertex_attrib2f = System.load ("lime", "lime_gl_vertex_attrib2f", 3); + private static var lime_gl_vertex_attrib2fv = System.load ("lime", "lime_gl_vertex_attrib2fv", 2); + private static var lime_gl_vertex_attrib3f = System.load ("lime", "lime_gl_vertex_attrib3f", 4); + private static var lime_gl_vertex_attrib3fv = System.load ("lime", "lime_gl_vertex_attrib3fv", 2); + private static var lime_gl_vertex_attrib4f = System.load ("lime", "lime_gl_vertex_attrib4f", 5); + private static var lime_gl_vertex_attrib4fv = System.load ("lime", "lime_gl_vertex_attrib4fv", 2); + private static var lime_gl_vertex_attrib_pointer = System.load ("lime", "lime_gl_vertex_attrib_pointer", -1); + private static var lime_gl_viewport = System.load ("lime", "lime_gl_viewport", 4); + + #end + +} \ No newline at end of file diff --git a/lime/graphics/opengl/GLActiveInfo.hx b/lime/graphics/opengl/GLActiveInfo.hx index 30f57cf83..caccb30ec 100644 --- a/lime/graphics/opengl/GLActiveInfo.hx +++ b/lime/graphics/opengl/GLActiveInfo.hx @@ -1,10 +1,16 @@ package lime.graphics.opengl; +#if js +typedef GLActiveInfo = js.html.webgl.ActiveInfo; +#else typedef GLActiveInfo = { + + size:Int, + type:Int, + name:String + +} - size : Int, - type : Int, - name : String -} //GLActiveInfo \ No newline at end of file +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLBuffer.hx b/lime/graphics/opengl/GLBuffer.hx index 272583e90..bea0a5f8b 100644 --- a/lime/graphics/opengl/GLBuffer.hx +++ b/lime/graphics/opengl/GLBuffer.hx @@ -1,10 +1,20 @@ package lime.graphics.opengl; +#if js +typedef GLBuffer = js.html.webgl.Buffer; +#else class GLBuffer extends GLObject { + + + private override function getType ():String { + + return "Buffer"; + + } + + +} - override function getType ():String { - return "Buffer"; - } -} //GLBuffer \ No newline at end of file +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLContextAttributes.hx b/lime/graphics/opengl/GLContextAttributes.hx index 2dadbb6f8..0c46bf9f1 100644 --- a/lime/graphics/opengl/GLContextAttributes.hx +++ b/lime/graphics/opengl/GLContextAttributes.hx @@ -1,13 +1,19 @@ package lime.graphics.opengl; +#if js +typedef GLContextAttributes = js.html.webgl.ContextAttributes; +#else typedef GLContextAttributes = { - - alpha:Bool, - depth:Bool, - stencil:Bool, - antialias:Bool, - premultipliedAlpha:Bool, - preserveDrawingBuffer:Bool - -} //GLContextAttributes \ No newline at end of file + + alpha:Bool, + depth:Bool, + stencil:Bool, + antialias:Bool, + premultipliedAlpha:Bool, + preserveDrawingBuffer:Bool + +} + + +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLFramebuffer.hx b/lime/graphics/opengl/GLFramebuffer.hx index 0a1b1bc55..58c836030 100644 --- a/lime/graphics/opengl/GLFramebuffer.hx +++ b/lime/graphics/opengl/GLFramebuffer.hx @@ -1,10 +1,20 @@ package lime.graphics.opengl; +#if js +typedef GLFramebuffer = js.html.webgl.Framebuffer; +#else class GLFramebuffer extends GLObject { + + + private override function getType ():String { + + return "Framebuffer"; + + } + + +} - override function getType () : String { - return "Framebuffer"; - } -} //GLFramebuffer \ No newline at end of file +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLProgram.hx b/lime/graphics/opengl/GLProgram.hx index a4ed0305e..a5fc77110 100644 --- a/lime/graphics/opengl/GLProgram.hx +++ b/lime/graphics/opengl/GLProgram.hx @@ -1,27 +1,45 @@ package lime.graphics.opengl; +#if js +typedef GLProgram = js.html.webgl.Program; +#else class GLProgram extends GLObject { - - public var shaders:Array; - - public function new( version:Int, id:Dynamic ) { + + + public var shaders:Array; + + + public function new (version:Int, id:Dynamic) { + + super (version, id); + shaders = new Array (); + + } + + + public function attach (shader:GLShader):Void { + + shaders.push (shader); + + } + + + public function getShaders ():Array { + + return shaders.copy (); + + } + + + private override function getType ():String { + + return "Program"; + + } + + +} - super (version, id); - shaders = new Array (); - } //new - - public function attach( shader:GLShader ) : Void { - shaders.push(shader); - } //attach - - public function getShaders() : Array { - return shaders.copy(); - } //getShaders - - override function getType ():String { - return "Program"; - } //getType - -} //GLProgram \ No newline at end of file +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLRenderbuffer.hx b/lime/graphics/opengl/GLRenderbuffer.hx index 27ae3d8ef..bd48fab9b 100644 --- a/lime/graphics/opengl/GLRenderbuffer.hx +++ b/lime/graphics/opengl/GLRenderbuffer.hx @@ -1,10 +1,20 @@ package lime.graphics.opengl; +#if js +typedef GLRenderbuffer = js.html.webgl.Renderbuffer; +#else class GLRenderbuffer extends GLObject { - - override function getType ():String { - return "Renderbuffer"; - } + + + private override function getType ():String { + + return "Renderbuffer"; + + } -} //GLRenderbuffer \ No newline at end of file + +} + + +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLShader.hx b/lime/graphics/opengl/GLShader.hx index ddddbf7b3..bb00e5110 100644 --- a/lime/graphics/opengl/GLShader.hx +++ b/lime/graphics/opengl/GLShader.hx @@ -1,10 +1,20 @@ package lime.graphics.opengl; +#if js +typedef GLShader = js.html.webgl.Shader; +#else class GLShader extends GLObject { - - override function getType ():String { - return "Shader"; - } + + + private override function getType ():String { + + return "Shader"; + + } -} //GLShader \ No newline at end of file + +} + + +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLShaderPrecisionFormat.hx b/lime/graphics/opengl/GLShaderPrecisionFormat.hx new file mode 100644 index 000000000..f52721a64 --- /dev/null +++ b/lime/graphics/opengl/GLShaderPrecisionFormat.hx @@ -0,0 +1,16 @@ +package lime.graphics.opengl; +#if js +typedef GLShaderPrecisionFormat = js.html.webgl.ShaderPrecisionFormat; +#else + + +typedef GLShaderPrecisionFormat = { + + rangeMin:Int, + rangeMax:Int, + precision:Int + +}; + + +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLTexture.hx b/lime/graphics/opengl/GLTexture.hx index 0a123b20e..fd6254f55 100644 --- a/lime/graphics/opengl/GLTexture.hx +++ b/lime/graphics/opengl/GLTexture.hx @@ -1,10 +1,20 @@ package lime.graphics.opengl; +#if js +typedef GLTexture = js.html.webgl.Texture; +#else class GLTexture extends GLObject { - - override function getType ():String { - return "Texture"; - } + + + private override function getType ():String { + + return "Texture"; + + } -} //GLTexture \ No newline at end of file + +} + + +#end \ No newline at end of file diff --git a/lime/graphics/opengl/GLUniformLocation.hx b/lime/graphics/opengl/GLUniformLocation.hx index 22a7fef0b..b531539ca 100644 --- a/lime/graphics/opengl/GLUniformLocation.hx +++ b/lime/graphics/opengl/GLUniformLocation.hx @@ -1,4 +1,10 @@ package lime.graphics.opengl; +#if js +typedef GLUniformLocation = js.html.webgl.UniformLocation; +#else -typedef GLUniformLocation = Int; \ No newline at end of file +typedef GLUniformLocation = Int; + + +#end \ No newline at end of file diff --git a/lime/system/System.hx b/lime/system/System.hx index 644648966..7f93af9cc 100644 --- a/lime/system/System.hx +++ b/lime/system/System.hx @@ -14,6 +14,8 @@ class System { static private function findHaxeLib (library:String):String { + #if sys + try { var proc = new Process ("haxelib", [ "path", library ]); @@ -48,6 +50,8 @@ class System { } catch (e:Dynamic) { } + #end + return ""; } @@ -55,6 +59,8 @@ class System { public static function load (library:String, method:String, args:Int = 0):Dynamic { + #if sys + #if (iphone || emscripten || android) return cpp.Lib.load (library, method, args); #end @@ -125,6 +131,12 @@ class System { } #end + #else + + var result = null; + + #end + return result; } @@ -132,18 +144,24 @@ class System { private static function sysName ():String { + #if sys #if cpp var sys_string = cpp.Lib.load ("std", "sys_string", 0); return sys_string (); #else return Sys.systemName (); #end + #else + return null; + #end } private static function tryLoad (name:String, library:String, func:String, args:Int):Dynamic { + #if sys + try { #if cpp @@ -168,6 +186,8 @@ class System { } + #end + return null; } @@ -175,6 +195,8 @@ class System { private static function loaderTrace (message:String) { + #if sys + #if cpp var get_env = cpp.Lib.load ("std", "get_env", 1); var debug = (get_env ("OPENFL_LOAD_DEBUG") != null); @@ -188,6 +210,8 @@ class System { } + #end + } diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index 7f9cdf751..2c5d03520 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -2,24 +2,195 @@ package lime.ui; import lime.app.Application; +import lime.app.Config; +import lime.graphics.RenderEvent; +import lime.graphics.RenderEventManager; import lime.system.System; +#if js +import lime.graphics.opengl.GL; +import js.html.webgl.RenderingContext; +import js.html.CanvasElement; +import js.Browser; +#end + +@:access(lime.graphics.RenderEventManager) class Window { public var handle:Dynamic; + public var height:Int; + public var width:Int; + + #if js + private var canvas:CanvasElement; + #end public function new (application:Application) { - #if (cpp || neko) + + + } + + + public function create (config:Config):Void { + + #if js + + if (Std.is (config.element, CanvasElement)) { + + canvas = cast config.element; + + } else { + + canvas = cast Browser.document.createElement ("canvas"); + + } + + var context:RenderingContext = cast canvas.getContext ("webgl"); + + if (context == null) { + + context = cast canvas.getContext ("experimental-webgl"); + + } + + #if debug + context = untyped WebGLDebugUtils.makeDebugContext (context); + #end + + GL.context = context; + + var style = canvas.style; + style.setProperty ("-webkit-transform", "translateZ(0)", null); + style.setProperty ("transform", "translateZ(0)", null); + + width = config.width; + height = config.height; + + //__originalWidth = width; + //__originalHeight = height; + + if (width == 0 && height == 0) { + + if (config.element != null) { + + width = config.element.clientWidth; + height = config.element.clientHeight; + + } else { + + width = Browser.window.innerWidth; + height = Browser.window.innerHeight; + + } + + //__fullscreen = true; + + } + + //stageWidth = width; + //stageHeight = height; + + if (canvas != null) { + + canvas.width = width; + canvas.height = height; + + /*} else { + + __div.style.width = width + "px"; + __div.style.height = height + "px"; + */ + } + + //__resize (); + + //Browser.window.addEventListener ("resize", window_onResize); + //Browser.window.addEventListener ("focus", window_onFocus); + //Browser.window.addEventListener ("blur", window_onBlur); + + if (config.element != null) { + + if (canvas != null) { + + if (config.element != cast canvas) { + + config.element.appendChild (canvas); + + } + + } else { + + //element.appendChild (__div); + + } + + } + + + #if stats + var __stats = untyped __js__("new Stats ()"); + __stats.domElement.style.position = "absolute"; + __stats.domElement.style.top = "0px"; + Browser.document.body.appendChild (__stats.domElement); + #end + + /*var keyEvents = [ "keydown", "keyup" ]; + var touchEvents = [ "touchstart", "touchmove", "touchend" ]; + var mouseEvents = [ "mousedown", "mousemove", "mouseup", "click", "dblclick", "mousewheel" ]; + var focusEvents = [ "focus", "blur" ]; + + var element = __canvas != null ? __canvas : __div; + + for (type in keyEvents) { + + Browser.window.addEventListener (type, window_onKey, false); + + } + + for (type in touchEvents) { + + element.addEventListener (type, element_onTouch, true); + + } + + for (type in mouseEvents) { + + element.addEventListener (type, element_onMouse, true); + + } + + for (type in focusEvents) { + + element.addEventListener (type, element_onFocus, true); + + } + + Browser.window.requestAnimationFrame (cast __render); + */ + render (); + + #elseif (cpp || neko) handle = lime_window_create (application.handle); #end } + #if js + private function render ():Void { + + RenderEventManager.instance.handleEvent (new RenderEvent ()); + + Browser.window.requestAnimationFrame (cast render); + + } + #end + + #if (cpp || neko) private static var lime_window_create = System.load ("lime", "lime_window_create", 1); #end diff --git a/lime/utils/ArrayBuffer.hx b/lime/utils/ArrayBuffer.hx index 1b752d893..f02372bfb 100644 --- a/lime/utils/ArrayBuffer.hx +++ b/lime/utils/ArrayBuffer.hx @@ -1,3 +1,10 @@ package lime.utils; +#if js +typedef ArrayBuffer = js.html.ArrayBuffer; +#else -typedef ArrayBuffer = lime.utils.ByteArray; \ No newline at end of file + +typedef ArrayBuffer = lime.utils.ByteArray; + + +#end \ No newline at end of file diff --git a/lime/utils/ArrayBufferView.hx b/lime/utils/ArrayBufferView.hx index 1310ed0b2..677920cf8 100644 --- a/lime/utils/ArrayBufferView.hx +++ b/lime/utils/ArrayBufferView.hx @@ -1,238 +1,244 @@ package lime.utils; +#if html5 +typedef ArrayBufferView = js.html.ArrayBufferView; +#else -#if lime_native - import lime.utils.ByteArray; - import lime.utils.IMemoryRange; +import lime.utils.ByteArray; +import lime.utils.IMemoryRange; - #if cpp - import haxe.io.BytesData; - #end +#if cpp +import haxe.io.BytesData; +#end - class ArrayBufferView implements IMemoryRange { - - public var buffer (default, null) : ByteArray; - public var byteOffset (default, null) : Int; - public var byteLength (default, null) : Int; - - #if cpp - var bytes : BytesData; - #end - - function new( lengthOrBuffer:Dynamic, byteOffset:Int = 0, length:Null = null ) { - - if (Std.is(lengthOrBuffer, Int)) { - - byteLength = Std.int(lengthOrBuffer); - this.byteOffset = 0; - buffer = new ArrayBuffer(Std.int(lengthOrBuffer)); - - } else { - - buffer = lengthOrBuffer; - - if (buffer == null) { - throw "Invalid input buffer"; - } - - this.byteOffset = byteOffset; - - if (byteOffset > buffer.length) { - throw "Invalid starting position"; - } - - if (length == null) { - byteLength = buffer.length - byteOffset; - } else { - byteLength = length; - if (byteLength + byteOffset > buffer.length) { - throw "Invalid buffer length"; - } - } - - } - - buffer.bigEndian = false; - - #if cpp - bytes = buffer.getData(); - #end - - } +class ArrayBufferView implements IMemoryRange { + + + public var buffer (default, null) : ByteArray; + public var byteOffset (default, null) : Int; + public var byteLength (default, null) : Int; + + #if cpp + var bytes : BytesData; + #end + + + function new( lengthOrBuffer:Dynamic, byteOffset:Int = 0, length:Null = null ) { + + if (Std.is(lengthOrBuffer, Int)) { + + byteLength = Std.int(lengthOrBuffer); + this.byteOffset = 0; + buffer = new ArrayBuffer(Std.int(lengthOrBuffer)); + + } else { + + buffer = lengthOrBuffer; + + if (buffer == null) { + throw "Invalid input buffer"; + } + + this.byteOffset = byteOffset; + + if (byteOffset > buffer.length) { + throw "Invalid starting position"; + } + + if (length == null) { + byteLength = buffer.length - byteOffset; + } else { + byteLength = length; + + if (byteLength + byteOffset > buffer.length) { + throw "Invalid buffer length"; + } + } + + } + + buffer.bigEndian = false; + + #if cpp + bytes = buffer.getData(); + #end + + } + + public function getByteBuffer() : ByteArray { + + return buffer; + + } + + public function getLength() : Int { + + return byteLength; + + } + + public function getStart() : Int { + + return byteOffset; + + } + + inline public function getInt8( position:Int ) : Int { + + #if cpp + return untyped __global__.__hxcpp_memory_get_byte(bytes, position + byteOffset); + #else + buffer.position = position + byteOffset; + return buffer.readByte(); + #end + + } + + inline public function setInt8( position:Int, value:Int ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_byte(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeByte(value); + #end + + } + + inline public function getUInt8( position:Int ) : Int { + + #if cpp + return untyped __global__.__hxcpp_memory_get_byte(bytes, position + byteOffset) & 0xff; + #else + buffer.position = position + byteOffset; + return buffer.readUnsignedByte(); + #end + + } + + inline public function setUInt8( position:Int, value:Int ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_byte(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeByte(value); + #end + + } + + inline public function getInt16( position:Int ) : Int { + + #if cpp + untyped return __global__.__hxcpp_memory_get_i16(bytes, position + byteOffset); + #else + buffer.position = position + byteOffset; + return buffer.readShort(); + #end + + } + + inline public function setInt16( position:Int, value:Int ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i16(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeShort(Std.int(value)); + #end + + } + + inline public function getUInt16( position:Int ) : Int { + + #if cpp + untyped return __global__.__hxcpp_memory_get_ui16(bytes, position + byteOffset) & 0xffff; + #else + buffer.position = position + byteOffset; + return buffer.readUnsignedShort(); + #end + + } + + inline public function setUInt16( position:Int, value:Int ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_ui16(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeShort(Std.int(value)); + #end + + } + + inline public function getInt32( position:Int ) : Int { + + #if cpp + untyped return __global__.__hxcpp_memory_get_i32(bytes, position + byteOffset); + #else + buffer.position = position + byteOffset; + return buffer.readInt(); + #end + + } + + inline public function setInt32( position:Int, value:Int ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i32(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeInt(Std.int(value)); + #end + + } + + inline public function getUInt32( position:Int ) : Int { + + #if cpp + untyped return __global__.__hxcpp_memory_get_ui32(bytes, position + byteOffset); + #else + buffer.position = position + byteOffset; + return buffer.readUnsignedInt(); + #end + + } + + inline public function setUInt32( position:Int, value:Int ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_ui32(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeUnsignedInt(Std.int(value)); + #end + + } + + inline public function getFloat32( position:Int ) : Float { + + #if cpp + untyped return __global__.__hxcpp_memory_get_float(bytes, position + byteOffset); + #else + buffer.position = position + byteOffset; + return buffer.readFloat(); + #end + + } + + inline public function setFloat32( position:Int, value:Float ) { + + #if cpp + untyped __global__.__hxcpp_memory_set_float(bytes, position + byteOffset, value); + #else + buffer.position = position + byteOffset; + buffer.writeFloat(value); + #end + + } + +} - public function getByteBuffer() : ByteArray { - - return buffer; - - } - - public function getLength() : Int { - - return byteLength; - - } - - public function getStart() : Int { - - return byteOffset; - - } - - inline public function getInt8( position:Int ) : Int { - - #if cpp - return untyped __global__.__hxcpp_memory_get_byte(bytes, position + byteOffset); - #else - buffer.position = position + byteOffset; - return buffer.readByte(); - #end - - } - - inline public function setInt8( position:Int, value:Int ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_byte(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeByte(value); - #end - - } - - inline public function getUInt8( position:Int ) : Int { - - #if cpp - return untyped __global__.__hxcpp_memory_get_byte(bytes, position + byteOffset) & 0xff; - #else - buffer.position = position + byteOffset; - return buffer.readUnsignedByte(); - #end - - } - - inline public function setUInt8( position:Int, value:Int ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_byte(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeByte(value); - #end - - } - - inline public function getInt16( position:Int ) : Int { - - #if cpp - untyped return __global__.__hxcpp_memory_get_i16(bytes, position + byteOffset); - #else - buffer.position = position + byteOffset; - return buffer.readShort(); - #end - - } - - inline public function setInt16( position:Int, value:Int ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i16(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeShort(Std.int(value)); - #end - - } - - inline public function getUInt16( position:Int ) : Int { - - #if cpp - untyped return __global__.__hxcpp_memory_get_ui16(bytes, position + byteOffset) & 0xffff; - #else - buffer.position = position + byteOffset; - return buffer.readUnsignedShort(); - #end - - } - - inline public function setUInt16( position:Int, value:Int ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_ui16(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeShort(Std.int(value)); - #end - - } - - inline public function getInt32( position:Int ) : Int { - - #if cpp - untyped return __global__.__hxcpp_memory_get_i32(bytes, position + byteOffset); - #else - buffer.position = position + byteOffset; - return buffer.readInt(); - #end - - } - - inline public function setInt32( position:Int, value:Int ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i32(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeInt(Std.int(value)); - #end - - } - - inline public function getUInt32( position:Int ) : Int { - - #if cpp - untyped return __global__.__hxcpp_memory_get_ui32(bytes, position + byteOffset); - #else - buffer.position = position + byteOffset; - return buffer.readUnsignedInt(); - #end - - } - - inline public function setUInt32( position:Int, value:Int ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_ui32(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeUnsignedInt(Std.int(value)); - #end - - } - - inline public function getFloat32( position:Int ) : Float { - - #if cpp - untyped return __global__.__hxcpp_memory_get_float(bytes, position + byteOffset); - #else - buffer.position = position + byteOffset; - return buffer.readFloat(); - #end - - } - - inline public function setFloat32( position:Int, value:Float ) { - - #if cpp - untyped __global__.__hxcpp_memory_set_float(bytes, position + byteOffset, value); - #else - buffer.position = position + byteOffset; - buffer.writeFloat(value); - #end - - } - - } //ArrayBufferView -#end //lime_native +#end \ No newline at end of file diff --git a/lime/utils/Float32Array.hx b/lime/utils/Float32Array.hx index 56ef9a5ca..13ba0130c 100644 --- a/lime/utils/Float32Array.hx +++ b/lime/utils/Float32Array.hx @@ -1,119 +1,142 @@ package lime.utils; +#if js +typedef Float32Array = js.html.Float32Array; +#else -//import lime.utils.compat.Matrix3D; class Float32Array extends ArrayBufferView implements ArrayAccess { - - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 4; + + + public var BYTES_PER_ELEMENT (default, null):Int; + public var length (default, null):Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 4; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray) << 2); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var floats:Array = bufferOrArray; + this.length = (length != null) ? length : floats.length - start; + + super (this.length << 2); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_float (bytes, (i << 2), floats[i + start]); + #else + buffer.writeFloat (floats[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, Float32Array)) { + + var floats:Float32Array = bufferOrArray; + this.length = (length != null) ? length : floats.length - start; + + super (this.length << 2); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_float (bytes, (i << 2), floats[i + start]); + #else + buffer.writeFloat (floats[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, (length != null) ? length << 2 : null); + + if ((byteLength & 0x03) > 0) { + + throw "Invalid array size"; + + } + + this.length = byteLength >> 2; + + if ((this.length << 2) != byteLength) { + + throw "Invalid length multiple"; + + } + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is (bufferOrArray, Array)) { + + var floats:Array = bufferOrArray; + + for (i in 0...floats.length) { + + setFloat32 ((i + offset) << 2, floats[i]); + + } + + } else if (Std.is (bufferOrArray, Float32Array)) { + + var floats:Float32Array = bufferOrArray; + + for (i in 0...floats.length) { + + setFloat32 ((i + offset) << 2, floats[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):Float32Array { + + end = (end == null) ? length : end; + return new Float32Array (buffer, start << 2, end - start); + + } + + + /*public static function fromMatrix (matrix:Matrix3D):Float32Array { + + return new Float32Array (matrix.rawData); + + }*/ + + + @:noCompletion @:keep inline public function __get (index:Int):Float { return getFloat32 (index << 2); } + @:noCompletion @:keep inline public function __set (index:Int, value:Float) { setFloat32 (index << 2, value); } + + +} - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray) << 2); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - var floats:Array = bufferOrArray; - this.length = (length != null) ? length : floats.length - start; - super(this.length << 2); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_float(bytes, (i << 2), floats[i + start]); - #else - buffer.writeFloat(floats[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, Float32Array)) { - - var floats:Float32Array = bufferOrArray; - this.length = (length != null) ? length : floats.length - start; - super(this.length << 2); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_float(bytes, (i << 2), floats[i + start]); - #else - buffer.writeFloat(floats[i + start]); - #end - - } - - } else { - - super(bufferOrArray, start, (length != null) ? length << 2 : null); - - if ((byteLength & 0x03) > 0) { - throw "Invalid array size"; - } - - this.length = byteLength >> 2; - - if ((this.length << 2) != byteLength) { - throw "Invalid length multiple"; - } - - } - - } //new - - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - - if (Std.is(bufferOrArray, Array)) { - - var floats:Array = bufferOrArray; - - for (i in 0...floats.length) { - setFloat32((i + offset) << 2, floats[i]); - } - - } else if (Std.is(bufferOrArray, Float32Array)) { - - var floats:Float32Array = bufferOrArray; - - for (i in 0...floats.length) { - setFloat32((i + offset) << 2, floats[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } //set - - public function subarray( start:Int, end:Null = null ) : Float32Array { - - end = (end == null) ? length : end; - return new Float32Array(buffer, start << 2, end - start); - - } //subarray - - /*public static function fromMatrix( matrix:Matrix3D ) : Float32Array { - - return new Float32Array(matrix.rawData); - - } //fromMatrix*/ - - @:noCompletion @:keep inline public function __get( index:Int ):Float { return getFloat32(index << 2); } - @:noCompletion @:keep inline public function __set( index:Int, value:Float ) { setFloat32(index << 2, value); } - -} //Float32Array +#end \ No newline at end of file diff --git a/lime/utils/Int16Array.hx b/lime/utils/Int16Array.hx index b37f8356b..96e2e3ca4 100644 --- a/lime/utils/Int16Array.hx +++ b/lime/utils/Int16Array.hx @@ -1,112 +1,135 @@ package lime.utils; +#if js +typedef Int16Array = js.html.Int16Array; +#else class Int16Array extends ArrayBufferView implements ArrayAccess { - - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 2; - - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray) << 1); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 1); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i16(bytes, (i << 1), ints[i + start]); - #else - buffer.writeShort(ints[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, Int16Array)) { - - var ints:Int16Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 1); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i16(bytes, (i << 1), ints[i + start]); - #else - buffer.writeShort(ints[i + start]); - #end - - } - - } else { - - super(bufferOrArray, start, (length != null) ? length << 1 : null); - - if ((byteLength & 0x01) > 0) { - throw "Invalid array size"; - } - - this.length = byteLength >> 1; - - if ((this.length << 1) != byteLength) { - throw "Invalid length multiple"; - } - - } - - } + + + public var BYTES_PER_ELEMENT (default, null) : Int; + public var length (default, null) : Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 2; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray) << 1); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 1); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i16 (bytes, (i << 1), ints[i + start]); + #else + buffer.writeShort (ints[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, Int16Array)) { + + var ints:Int16Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 1); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i16 (bytes, (i << 1), ints[i + start]); + #else + buffer.writeShort (ints[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, (length != null) ? length << 1 : null); + + if ((byteLength & 0x01) > 0) { + + throw "Invalid array size"; + + } + + this.length = byteLength >> 1; + + if ((this.length << 1) != byteLength) { + + throw "Invalid length multiple"; + + } + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + + for (i in 0...ints.length) { + + setInt16 ((i + offset) << 1, ints[i]); + + } + + } else if (Std.is (bufferOrArray, Int16Array)) { + + var ints:Int16Array = bufferOrArray; + + for (i in 0...ints.length) { + + setInt16 ((i + offset) << 1, ints[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):Int16Array { + + end = (end == null) ? length : end; + return new Int16Array (buffer, start << 1, end - start); + + } + + + @:noCompletion @:keep inline public function __get (index:Int):Int { return getInt16 (index << 1); } + @:noCompletion @:keep inline public function __set (index:Int, value:Int) { setInt16 (index << 1, value); } + + +} - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - - for (i in 0...ints.length) { - setInt16((i + offset) << 1, ints[i]); - } - - } else if (Std.is(bufferOrArray, Int16Array)) { - - var ints:Int16Array = bufferOrArray; - - for (i in 0...ints.length) { - setInt16((i + offset) << 1, ints[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } - - public function subarray( start:Int, end:Null = null ) : Int16Array { - - end = (end == null) ? length : end; - return new Int16Array(buffer, start << 1, end - start); - - } - - @:noCompletion @:keep inline public function __get( index:Int ):Int { return getInt16(index << 1); } - @:noCompletion @:keep inline public function __set( index:Int, value:Int ) { setInt16(index << 1, value); } - -} //Int16Array +#end \ No newline at end of file diff --git a/lime/utils/Int32Array.hx b/lime/utils/Int32Array.hx index 81ec3b6e6..b5e95a77a 100644 --- a/lime/utils/Int32Array.hx +++ b/lime/utils/Int32Array.hx @@ -1,115 +1,135 @@ package lime.utils; - +#if js +typedef Int32Array = js.html.Int32Array; +#else class Int32Array extends ArrayBufferView implements ArrayAccess { - - - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - - - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 4; - - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray) << 2); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 2); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i32(bytes, (i << 2), ints[i + start]); - #else - buffer.writeInt(ints[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, Int32Array)) { - - var ints:Int32Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 2); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i32(bytes, (i << 2), ints[i + start]); - #else - buffer.writeInt(ints[i + start]); - #end - - } - - } else { - - super(bufferOrArray, start, (length != null) ? length << 2 : null); - - if ((byteLength & 0x03) > 0) { - throw "Invalid array size"; - } - - this.length = byteLength >> 2; - - if ((this.length << 2) != byteLength) { - throw "Invalid length multiple"; - } - - } - - } //new + + + public var BYTES_PER_ELEMENT (default, null) : Int; + public var length (default, null) : Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 4; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray) << 2); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 2); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i32 (bytes, (i << 2), ints[i + start]); + #else + buffer.writeInt (ints[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, Int32Array)) { + + var ints:Int32Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 2); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i32(bytes, (i << 2), ints[i + start]); + #else + buffer.writeInt(ints[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, (length != null) ? length << 2 : null); + + if ((byteLength & 0x03) > 0) { + + throw "Invalid array size"; + + } + + this.length = byteLength >> 2; + + if ((this.length << 2) != byteLength) { + + throw "Invalid length multiple"; + + } + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + + for (i in 0...ints.length) { + + setInt32 ((i + offset) << 2, ints[i]); + + } + + } else if (Std.is (bufferOrArray, Int32Array)) { + + var ints:Int32Array = bufferOrArray; + + for (i in 0...ints.length) { + + setInt32 ((i + offset) << 2, ints[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):Int32Array { + + end = (end == null) ? length : end; + return new Int32Array (buffer, start << 2, end - start); + + } + + + @:noCompletion @:keep inline public function __get (index:Int):Int { return getInt32 (index << 2); } + @:noCompletion @:keep inline public function __set (index:Int, value:Int) { setInt32 (index << 2, value); } + + +} - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - - for (i in 0...ints.length) { - setInt32((i + offset) << 2, ints[i]); - } - - } else if (Std.is(bufferOrArray, Int32Array)) { - - var ints:Int32Array = bufferOrArray; - - for (i in 0...ints.length) { - setInt32((i + offset) << 2, ints[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } //set - - public function subarray( start:Int, end:Null = null ) : Int32Array { - - end = (end == null) ? length : end; - return new Int32Array(buffer, start << 2, end - start); - - } //subarray - - @:noCompletion @:keep inline public function __get( index:Int ):Int { return getInt32(index << 2); } - @:noCompletion @:keep inline public function __set( index:Int, value:Int ) { setInt32(index << 2, value); } - -} //Int32Array +#end \ No newline at end of file diff --git a/lime/utils/Int8Array.hx b/lime/utils/Int8Array.hx index 1db84e210..d3ac74807 100644 --- a/lime/utils/Int8Array.hx +++ b/lime/utils/Int8Array.hx @@ -1,106 +1,122 @@ package lime.utils; - +#if js +typedef Int8Array = js.html.Int8Array; +#else class Int8Array extends ArrayBufferView implements ArrayAccess { - + + + public var BYTES_PER_ELEMENT (default, null) : Int; + public var length (default, null) : Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 1; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray)); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_byte (bytes, i, ints[i + start]); + #else + buffer.writeByte (ints[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, Int8Array)) { + + var ints:Int8Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_byte (bytes, i, ints[i + start]); + #else + buffer.writeByte (ints[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, length); + this.length = byteLength; + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is(bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + + for (i in 0...ints.length) { + + setInt8 (i + offset, ints[i]); + + } + + } else if (Std.is (bufferOrArray, Int8Array)) { + + var ints:Int8Array = bufferOrArray; + + for (i in 0...ints.length) { + + setInt8 (i + offset, ints[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):Int8Array { + + end = (end == null) ? length : end; + return new Int8Array (buffer, start, end - start); + + } + + + @:noCompletion @:keep inline public function __get (index:Int):Int { return getInt8 (index); } + @:noCompletion @:keep inline public function __set (index:Int, value:Int) { setInt8 (index, value); } + + +} - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 1; - - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray)); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_byte(bytes, i, ints[i + start]); - #else - buffer.writeByte(ints[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, Int8Array)) { - - var ints:Int8Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_byte(bytes, i, ints[i + start]); - #else - buffer.writeByte(ints[i + start]); - #end - - } - - } else { - - super(bufferOrArray, start, length); - this.length = byteLength; - - } - - } //new - - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - - if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - - for (i in 0...ints.length) { - setInt8(i + offset, ints[i]); - } - - } else if (Std.is(bufferOrArray, Int8Array)) { - - var ints:Int8Array = bufferOrArray; - - for (i in 0...ints.length) { - setInt8(i + offset, ints[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } //set - - public function subarray( start:Int, end:Null = null ) : Int8Array { - - end = (end == null) ? length : end; - return new Int8Array(buffer, start, end - start); - - } //subarray - - @:noCompletion @:keep inline public function __get( index:Int ):Int { return getInt8(index); } - @:noCompletion @:keep inline public function __set( index:Int, value:Int ) { setInt8(index, value); } - -} //Int8Array +#end \ No newline at end of file diff --git a/lime/utils/UInt16Array.hx b/lime/utils/UInt16Array.hx index 5fa4feaae..4697c23e6 100644 --- a/lime/utils/UInt16Array.hx +++ b/lime/utils/UInt16Array.hx @@ -1,115 +1,135 @@ package lime.utils; - +#if js +typedef UInt16Array = js.html.UInt16Array; +#else class UInt16Array extends ArrayBufferView implements ArrayAccess { - + + + public var BYTES_PER_ELEMENT (default, null) : Int; + public var length (default, null) : Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 2; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray) << 1); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 1); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_ui16 (bytes, (i << 1), ints[i + start]); + #else + buffer.writeShort (ints[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, UInt16Array)) { + + var ints:UInt16Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 1); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_i16 (bytes, (i << 1), ints[i + start]); + #else + buffer.writeShort (ints[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, (length != null) ? length << 1 : null); + + if ((byteLength & 0x01) > 0) { + + throw "Invalid array size"; + + } + + this.length = byteLength >> 1; + + if ((this.length << 1) != byteLength) { + + throw "Invalid length multiple"; + + } + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + + for (i in 0...ints.length) { + + setUInt16 ((i + offset) << 1, ints[i]); + + } + + } else if (Std.is (bufferOrArray, UInt16Array)) { - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - + var ints:UInt16Array = bufferOrArray; - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 2; - - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray) << 1); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 1); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_ui16(bytes, (i << 1), ints[i + start]); - #else - buffer.writeShort(ints[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, UInt16Array)) { - - var ints:UInt16Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 1); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_i16(bytes, (i << 1), ints[i + start]); - #else - buffer.writeShort(ints[i + start]); - #end - - } - - } else { - - super(bufferOrArray, start, (length != null) ? length << 1 : null); - - if ((byteLength & 0x01) > 0) { - throw "Invalid array size"; - } - - this.length = byteLength >> 1; - - if ((this.length << 1) != byteLength) { - throw "Invalid length multiple"; - } + for (i in 0...ints.length) { + + setUInt16 ((i + offset) << 1, ints[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):UInt16Array { + + end = (end == null) ? length : end; + return new UInt16Array (buffer, start << 1, end - start); + + } + + + @:noCompletion @:keep inline public function __get (index:Int):Int { return getUInt16 (index << 1); } + @:noCompletion @:keep inline public function __set (index:Int, value:Int) { setUInt16 (index << 1, value); } + + +} - } - } //new - - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - - if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - - for (i in 0...ints.length) { - setUInt16((i + offset) << 1, ints[i]); - } - - } else if (Std.is(bufferOrArray, UInt16Array)) { - - var ints:UInt16Array = bufferOrArray; - - for (i in 0...ints.length) { - setUInt16((i + offset) << 1, ints[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } //set - - public function subarray( start:Int, end:Null = null ) : UInt16Array { - - end = (end == null) ? length : end; - return new UInt16Array(buffer, start << 1, end - start); - - } //subarray - - @:noCompletion @:keep inline public function __get( index:Int ):Int { return getUInt16(index << 1); } - @:noCompletion @:keep inline public function __set( index:Int, value:Int ) { setUInt16(index << 1, value); } - -} //UInt16Array +#end \ No newline at end of file diff --git a/lime/utils/UInt32Array.hx b/lime/utils/UInt32Array.hx index c0a9a61ec..762b56286 100644 --- a/lime/utils/UInt32Array.hx +++ b/lime/utils/UInt32Array.hx @@ -1,114 +1,135 @@ package lime.utils; +#if js +typedef UInt32Array = js.html.UInt32Array; +#else class UInt32Array extends ArrayBufferView implements ArrayAccess { - + + + public var BYTES_PER_ELEMENT (default, null) : Int; + public var length (default, null) : Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 4; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray) << 2); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 2); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_ui32 (bytes, (i << 2), ints[i + start]); + #else + buffer.writeInt (ints[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, UInt32Array)) { + + var ints:UInt32Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length << 2); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_ui32 (bytes, (i << 2), ints[i + start]); + #else + buffer.writeInt (ints[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, (length != null) ? length << 2 : null); + + if ((byteLength & 0x03) > 0) { + + throw "Invalid array size"; + + } + + this.length = byteLength >> 2; + + if ((this.length << 2) != byteLength) { + + throw "Invalid length multiple"; + + } + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + + for (i in 0...ints.length) { + + setUInt32 ((i + offset) << 2, ints[i]); + + } + + } else if (Std.is (bufferOrArray, UInt32Array)) { + + var ints:UInt32Array = bufferOrArray; + + for (i in 0...ints.length) { + + setUInt32 ((i + offset) << 2, ints[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):UInt32Array { + + end = (end == null) ? length : end; + return new UInt32Array (buffer, start << 2, end - start); + + } + + + @:noCompletion @:keep inline public function __get (index:Int):Int { return getUInt32 (index << 2); } + @:noCompletion @:keep inline public function __set (index:Int, value:Int) { setUInt32 (index << 2, value); } + + +} - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 4; - - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray) << 2); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 2); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_ui32(bytes, (i << 2), ints[i + start]); - #else - buffer.writeInt(ints[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, UInt32Array)) { - - var ints:UInt32Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length << 2); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_ui32(bytes, (i << 2), ints[i + start]); - #else - buffer.writeInt(ints[i + start]); - #end - - } - - } else { - - super(bufferOrArray, start, (length != null) ? length << 2 : null); - - if ((byteLength & 0x03) > 0) { - throw "Invalid array size"; - } - - this.length = byteLength >> 2; - - if ((this.length << 2) != byteLength) { - throw "Invalid length multiple"; - } - - } - - } //new - - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - - if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - - for (i in 0...ints.length) { - setUInt32((i + offset) << 2, ints[i]); - } - - } else if (Std.is(bufferOrArray, UInt32Array)) { - - var ints:UInt32Array = bufferOrArray; - - for (i in 0...ints.length) { - setUInt32((i + offset) << 2, ints[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } //set - - public function subarray( start:Int, end:Null = null ) : UInt32Array { - - end = (end == null) ? length : end; - return new UInt32Array(buffer, start << 2, end - start); - - } //subarray - - @:noCompletion @:keep inline public function __get( index:Int ):Int { return getUInt32(index << 2); } - @:noCompletion @:keep inline public function __set( index:Int, value:Int ) { setUInt32(index << 2, value); } - -} //UInt32Array +#end \ No newline at end of file diff --git a/lime/utils/UInt8Array.hx b/lime/utils/UInt8Array.hx index dd004ab36..b71c7fe49 100644 --- a/lime/utils/UInt8Array.hx +++ b/lime/utils/UInt8Array.hx @@ -1,106 +1,123 @@ package lime.utils; - +#if js +typedef UInt8Array = js.html.UInt8Array; +#else class UInt8Array extends ArrayBufferView implements ArrayAccess { - - - public var BYTES_PER_ELEMENT (default, null) : Int; - public var length (default, null) : Int; - - - public function new( bufferOrArray:Dynamic, start:Int = 0, length:Null = null ) { - - BYTES_PER_ELEMENT = 1; - - if (Std.is(bufferOrArray, Int)) { - - super(Std.int(bufferOrArray)); - this.length = bufferOrArray; - - } else if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_byte(bytes, i, ints[i + start]); - #else - buffer.writeByte(ints[i + start]); - #end - - } - - } else if (Std.is(bufferOrArray, UInt8Array)) { + + + public var BYTES_PER_ELEMENT (default, null) : Int; + public var length (default, null) : Int; + + + public function new (bufferOrArray:Dynamic, start:Int = 0, length:Null = null) { + + BYTES_PER_ELEMENT = 1; + + if (Std.is (bufferOrArray, Int)) { + + super (Std.int (bufferOrArray)); + + this.length = bufferOrArray; + + } else if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_byte (bytes, i, ints[i + start]); + #else + buffer.writeByte (ints[i + start]); + #end + + } + + } else if (Std.is (bufferOrArray, UInt8Array)) { + + var ints:UInt8Array = bufferOrArray; + this.length = (length != null) ? length : ints.length - start; + + super (this.length); + + #if !cpp + buffer.position = 0; + #end + + for (i in 0...this.length) { + + #if cpp + untyped __global__.__hxcpp_memory_set_byte (bytes, i, ints[i + start]); + #else + buffer.writeByte (ints[i + start]); + #end + + } + + } else { + + super (bufferOrArray, start, length); + + this.length = byteLength; + + } + + } + + + public function set (bufferOrArray:Dynamic, offset:Int = 0) { + + if (Std.is (bufferOrArray, Array)) { + + var ints:Array = bufferOrArray; + + for (i in 0...ints.length) { + + setUInt8 (i + offset, ints[i]); + + } + + } else if (Std.is (bufferOrArray, UInt8Array)) { + + var ints:UInt8Array = bufferOrArray; + + for (i in 0...ints.length) { + + setUInt8 (i + offset, ints[i]); + + } + + } else { + + throw "Invalid input buffer"; + + } + + } + + + public function subarray (start:Int, end:Null = null):UInt8Array { + + end = (end == null) ? length : end; + return new UInt8Array (buffer, start, end - start); + + } + + + @:noCompletion @:keep inline public function __get (index:Int):Int { return getUInt8 (index); } + @:noCompletion @:keep inline public function __set (index:Int, value:Int) { setUInt8 (index, value); } + + +} - var ints:UInt8Array = bufferOrArray; - this.length = (length != null) ? length : ints.length - start; - super(this.length); - - #if !cpp - buffer.position = 0; - #end - - for (i in 0...this.length) { - - #if cpp - untyped __global__.__hxcpp_memory_set_byte(bytes, i, ints[i + start]); - #else - buffer.writeByte(ints[i + start]); - #end - - } - } else { - - super(bufferOrArray, start, length); - this.length = byteLength; - - } - - } //new - - public function set( bufferOrArray:Dynamic, offset:Int = 0 ) { - - if (Std.is(bufferOrArray, Array)) { - - var ints:Array = bufferOrArray; - - for (i in 0...ints.length) { - setUInt8(i + offset, ints[i]); - } - - } else if (Std.is(bufferOrArray, UInt8Array)) { - - var ints:UInt8Array = bufferOrArray; - - for (i in 0...ints.length) { - setUInt8(i + offset, ints[i]); - } - - } else { - - throw "Invalid input buffer"; - - } - - } //set - - public function subarray( start:Int, end:Null = null ) : UInt8Array { - - end = (end == null) ? length : end; - return new UInt8Array(buffer, start, end - start); - - } //subarray - - @:noCompletion @:keep inline public function __get( index:Int ):Int { return getUInt8(index); } - @:noCompletion @:keep inline public function __set( index:Int, value:Int ) { setUInt8(index, value); } - -} //UInt8Array +#end \ No newline at end of file diff --git a/templates/html5/haxe/ApplicationMain.hx b/templates/html5/haxe/ApplicationMain.hx old mode 100755 new mode 100644 index 7088df2b8..9a78e2ae5 --- a/templates/html5/haxe/ApplicationMain.hx +++ b/templates/html5/haxe/ApplicationMain.hx @@ -1,39 +1,119 @@ -#if lime_html5 - - import ::APP_MAIN_PACKAGE::::APP_MAIN_CLASS::; - import lime.Lime; - - class ApplicationMain { - - public static function main () { - - //Create the game class, give it the runtime - var _main_ = Type.createInstance (::APP_MAIN::, []); - //Create an instance of lime - var _lime = new Lime(); - - //Create the config from the project.nmml info - var config : LimeConfig = { - host : _main_, - fullscreen : ::WIN_FULLSCREEN::, - resizable : ::WIN_RESIZABLE::, - borderless : ::WIN_BORDERLESS::, - antialiasing : Std.int(::WIN_ANTIALIASING::), - stencil_buffer : ::WIN_STENCIL_BUFFER::, - depth_buffer : ::WIN_DEPTH_BUFFER::, - vsync : ::WIN_VSYNC::, - fps : Std.int(::WIN_FPS::), - width : Std.int(::WIN_WIDTH::), - height : Std.int(::WIN_HEIGHT::), - orientation : "::WIN_ORIENTATION::", - title : "::APP_TITLE::", - }; - - //Start up - _lime.init( _main_, config ); - - } //main - } //ApplicationMain +import ::APP_MAIN::; -#end //lime_html5 +class ApplicationMain { + + + private var app:lime.app.Application; + + + @:keep @:expose("lime.embed") + public static function embed (elementName:String, width:Null = null, height:Null = null, background:String = null) { + + var element:js.html.HtmlElement = null; + + if (elementName != null) { + + element = cast js.Browser.document.getElementById (elementName); + + } + + var color = null; + + if (background != null) { + + background = StringTools.replace (background, "#", ""); + + if (background.indexOf ("0x") > -1) { + + color = Std.parseInt (background); + + } else { + + color = Std.parseInt ("0x" + background); + + } + + } + + if (width == null) { + + width = 0; + + } + + if (height == null) { + + height = 0; + + } + + untyped __js__ (" + var lastTime = 0; + var vendors = ['ms', 'moz', 'webkit', 'o']; + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] + || window[vendors[x]+'CancelRequestAnimationFrame']; + } + + if (!window.requestAnimationFrame) + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; + + if (!window.cancelAnimationFrame) + window.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; + + window.requestAnimFrame = window.requestAnimationFrame; + "); + + var app = new ::APP_MAIN:: (); + + var config:lime.app.Config = { + + antialiasing: Std.int (::WIN_ANTIALIASING::), + background: color, + borderless: ::WIN_BORDERLESS::, + depthBuffer: ::WIN_DEPTH_BUFFER::, + element: element, + fps: Std.int (::WIN_FPS::), + fullscreen: ::WIN_FULLSCREEN::, + height: height, + orientation: "::WIN_ORIENTATION::", + resizable: ::WIN_RESIZABLE::, + stencilBuffer: ::WIN_STENCIL_BUFFER::, + title: "::APP_TITLE::", + vsync: ::WIN_VSYNC::, + width: width, + + } + + app.create (config); + + var result = app.exec (); + + //#if sys + //Sys.exit (result); + //#end + + } + + + public static function main () { + + #if munit + embed (null, ::WIN_WIDTH::, ::WIN_HEIGHT::, "::WIN_FLASHBACKGROUND::"); + #end + + } + + +} \ No newline at end of file diff --git a/templates/html5/haxe/NMEPreloader.hx b/templates/html5/haxe/NMEPreloader.hx deleted file mode 100644 index e1bab587f..000000000 --- a/templates/html5/haxe/NMEPreloader.hx +++ /dev/null @@ -1,113 +0,0 @@ -// import flash.display.Sprite; -// import flash.events.Event; - - -class NMEPreloader // extends Sprite -{ - // private var outline:Sprite; - // private var progress:Sprite; - - public function new() - { - // super(); - - // var backgroundColor = getBackgroundColor (); - // var r = backgroundColor >> 16 & 0xFF; - // var g = backgroundColor >> 8 & 0xFF; - // var b = backgroundColor & 0xFF; - // var perceivedLuminosity = (0.299 * r + 0.587 * g + 0.114 * b); - // var color = 0x000000; - - // if (perceivedLuminosity < 70) { - - // color = 0xFFFFFF; - - // } - - // var x = 30; - // var height = 9; - // var y = getHeight () / 2 - height / 2; - // var width = getWidth () - x * 2; - - // var padding = 3; - - // outline = new Sprite (); - // outline.graphics.lineStyle (1, color, 0.15, true); - // outline.graphics.drawRoundRect (0, 0, width, height, padding * 2, padding * 2); - // outline.x = x; - // outline.y = y; - // addChild (outline); - - // progress = new Sprite (); - // progress.graphics.beginFill (color, 0.35); - // progress.graphics.drawRect (0, 0, width - padding * 2, height - padding * 2); - // progress.x = x + padding; - // progress.y = y + padding; - // progress.scaleX = 0; - // addChild (progress); - } - - - public function getBackgroundColor():Int - { - return ::WIN_BACKGROUND::; - } - - - public function getHeight():Float - { - var height = ::WIN_HEIGHT::; - - if (height > 0) { - - return height; - - } else { - - return 640;// flash.Lib.current.stage.stageHeight; - - } - } - - - public function getWidth():Float - { - var width = ::WIN_WIDTH::; - - if (width > 0) { - - return width; - - } else { - - return 960;// todo flash.Lib.current.stage.stageWidth; - - } - } - - - public function onInit() - { - - } - - - public function onLoaded() { - // dispatchEvent (new Event (Event.COMPLETE)); - } - - - public function onUpdate(bytesLoaded:Int, bytesTotal:Int) { - - var percentLoaded = bytesLoaded / bytesTotal; - - if (percentLoaded > 1) - { - percentLoaded == 1; - } - - progress.scaleX = percentLoaded; - } - - -} \ No newline at end of file diff --git a/templates/html5/haxe/lime/AssetData.hx b/templates/html5/haxe/lime/AssetData.hx deleted file mode 100644 index 3f88c8e81..000000000 --- a/templates/html5/haxe/lime/AssetData.hx +++ /dev/null @@ -1,36 +0,0 @@ -package lime; - - -import lime.utils.Assets; - - -class AssetData { - - private static var initialized:Bool = false; - - public static var className = new Map (); - public static var library = new Map (); - public static var path = new Map (); - public static var type = new Map (); - - public static function initialize():Void { - - if (!initialized) { - - ::if (assets != null)::::foreach assets::::if (type == "font")::className.set ("::id::", nme.lime_::flatName::);::else::path.set ("::id::", "::resourceName::");::end:: - type.set ("::id::", Reflect.field (AssetType, "::type::".toUpperCase ())); - ::end::::end:: - ::if (libraries != null)::::foreach libraries::library.set ("::name::", Reflect.field (LibraryType, "::type::".toUpperCase ())); - ::end::::end:: - initialized = true; - - } //initialized - - } //initialize - - -} //AssetData - - -::foreach assets::::if (type == "font")::class lime_::flatName:: extends flash.text.Font { }::end:: -::end:: \ No newline at end of file diff --git a/templates/html5/hxml/debug.hxml b/templates/html5/hxml/debug.hxml index 75decfb4f..122945e1f 100755 --- a/templates/html5/hxml/debug.hxml +++ b/templates/html5/hxml/debug.hxml @@ -3,5 +3,4 @@ -cp ::OUTPUT_DIR::/haxe -D html5 -D html ---remap flash:lime -debug \ No newline at end of file diff --git a/templates/html5/hxml/final.hxml b/templates/html5/hxml/final.hxml index f1006e814..26efad104 100644 --- a/templates/html5/hxml/final.hxml +++ b/templates/html5/hxml/final.hxml @@ -3,5 +3,4 @@ -cp ::OUTPUT_DIR::/haxe -D html5 -D html ---remap flash:lime -D final \ No newline at end of file diff --git a/templates/html5/hxml/release.hxml b/templates/html5/hxml/release.hxml index eadc13f32..35c7cec78 100755 --- a/templates/html5/hxml/release.hxml +++ b/templates/html5/hxml/release.hxml @@ -2,5 +2,4 @@ -js ::OUTPUT_FILE:: -cp ::OUTPUT_DIR::/haxe -D html5 --D html ---remap flash:lime \ No newline at end of file +-D html \ No newline at end of file diff --git a/templates/html5/template/index.html b/templates/html5/template/index.html index 688d016c5..4a6dcfeb4 100755 --- a/templates/html5/template/index.html +++ b/templates/html5/template/index.html @@ -1,38 +1,53 @@ - - - - - - - ::APP_TITLE:: - - - - - - - - - - - ::if linkedLibraries::::foreach (linkedLibraries):: - ::end::::end:: - - - - - - - + + + + + + + + ::APP_TITLE:: + + + + + ::if linkedLibraries::::foreach (linkedLibraries):: + ::end::::end:: + + + + + + + + + ::foreach assets::::if (type == "font"):: + ::end::::end:: + +
+ + + + + \ No newline at end of file diff --git a/templates/html5/template/lib/modernizr.js b/templates/html5/template/lib/modernizr.js deleted file mode 100644 index f645852f1..000000000 --- a/templates/html5/template/lib/modernizr.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Modernizr 2.7.1 (Custom Build) | MIT & BSD - * Build: http://modernizr.com/download/#-audio-video-localstorage-sessionstorage-websockets-webworkers-geolocation-touch-webgl-shiv-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-gamepad-load - */ -;window.Modernizr=function(a,b,c){function z(a){i.cssText=a}function A(a,b){return z(l.join(a+";")+(b||""))}function B(a,b){return typeof a===b}function C(a,b){return!!~(""+a).indexOf(b)}function D(a,b){for(var d in a){var e=a[d];if(!C(e,"-")&&i[e]!==c)return b=="pfx"?e:!0}return!1}function E(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:B(f,"function")?f.bind(d||b):f}return!1}function F(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+n.join(d+" ")+d).split(" ");return B(b,"string")||B(b,"undefined")?D(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),E(e,b,c))}var d="2.7.1",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l=" -webkit- -moz- -o- -ms- ".split(" "),m="Webkit Moz O ms",n=m.split(" "),o=m.toLowerCase().split(" "),p={},q={},r={},s=[],t=s.slice,u,v=function(a,c,d,e){var h,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:g+(d+1),l.appendChild(j);return h=["­",'"].join(""),l.id=g,(m?l:n).innerHTML+=h,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=f.style.overflow,f.style.overflow="hidden",f.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),f.style.overflow=k),!!i},w=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=B(e[d],"function"),B(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),x={}.hasOwnProperty,y;!B(x,"undefined")&&!B(x.call,"undefined")?y=function(a,b){return x.call(a,b)}:y=function(a,b){return b in a&&B(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=t.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(t.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(t.call(arguments)))};return e}),p.webgl=function(){return!!a.WebGLRenderingContext},p.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:v(["@media (",l.join("touch-enabled),("),g,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},p.geolocation=function(){return"geolocation"in navigator},p.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},p.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},p.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},p.localstorage=function(){try{return localStorage.setItem(g,g),localStorage.removeItem(g),!0}catch(a){return!1}},p.sessionstorage=function(){try{return sessionStorage.setItem(g,g),sessionStorage.removeItem(g),!0}catch(a){return!1}},p.webworkers=function(){return!!a.Worker};for(var G in p)y(p,G)&&(u=G.toLowerCase(),e[u]=p[G](),s.push((e[u]?"":"no-")+u));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)y(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof enableClasses!="undefined"&&enableClasses&&(f.className+=" "+(b?"":"no-")+a),e[a]=b}return e},z(""),h=j=null,function(a,b){function l(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function m(){var a=s.elements;return typeof a=="string"?a.split(" "):a}function n(a){var b=j[a[h]];return b||(b={},i++,a[h]=i,j[i]=b),b}function o(a,c,d){c||(c=b);if(k)return c.createElement(a);d||(d=n(c));var g;return d.cache[a]?g=d.cache[a].cloneNode():f.test(a)?g=(d.cache[a]=d.createElem(a)).cloneNode():g=d.createElem(a),g.canHaveChildren&&!e.test(a)&&!g.tagUrn?d.frag.appendChild(g):g}function p(a,c){a||(a=b);if(k)return a.createDocumentFragment();c=c||n(a);var d=c.frag.cloneNode(),e=0,f=m(),g=f.length;for(;e",g="hidden"in a,k=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){g=!0,k=!0}})();var s={elements:d.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:c,shivCSS:d.shivCSS!==!1,supportsUnknownElements:k,shivMethods:d.shivMethods!==!1,type:"default",shivDocument:r,createElement:o,createDocumentFragment:p};a.html5=s,r(b)}(this,b),e._version=d,e._prefixes=l,e._domPrefixes=o,e._cssomPrefixes=n,e.hasEvent=w,e.testProp=function(a){return D([a])},e.testAllProps=F,e.testStyles=v,e.prefixed=function(a,b,c){return b?F(a,b,c):F(a,"pfx")},e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;fopera.version()?new Audio(null):new Audio).canPlayType!==k}catch(ib){Ia=!1}this.hasHTML5=Ia;this.setup=function(b){var e=!c.url;b!==k&&p&&u&&c.ok();oa(b);b&& -(e&&(N&&b.url!==k)&&c.beginDelayedInit(),!N&&(b.url!==k&&"complete"===n.readyState)&&setTimeout(G,1));return c};this.supported=this.ok=function(){return u?p&&!y:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(b){return W(b)||n[b]||g[b]};this.createSound=function(b,e){function d(){a=aa(a);c.sounds[a.id]=new Ja(a);c.soundIDs.push(a.id);return c.sounds[a.id]}var a,f=null;if(!p||!c.ok())return!1;e!==k&&(b={id:b,url:e});a=w(b);a.url=da(a.url);void 0===a.id&&(a.id=c.setupOptions.idPrefix+Ya++);if(r(a.id, -!0))return c.sounds[a.id];if(ea(a))f=d(),f._setup_html5(a);else{if(c.html5Only||c.html5.usingFlash&&a.url&&a.url.match(/data\:/i))return d();8a.instanceCount?(n(),f=a._setup_html5(),a.setPosition(a._iO.position),f.play()):(h=new Audio(a._iO.url),g=function(){t.remove(h,"ended",g);a._onfinish(a);fa(h);h=null},J=function(){t.remove(h,"canplay",J);try{h.currentTime=a._iO.position/1E3}catch(b){}h.play()},t.add(h,"ended",g),void 0!==a._iO.volume&&(h.volume=Math.max(0,Math.min(1,a._iO.volume/100))),a.muted&&(h.muted=!0),a._iO.position? -t.add(h,"canplay",J):h.play()):(f=l._start(a.id,a._iO.loops||1,9===m?a.position:a.position/1E3,a._iO.multiShot||!1),9===m&&!f&&a._iO.onplayerror&&a._iO.onplayerror.apply(a))}return a};this.stop=function(b){var c=a._iO;1===a.playState&&(a._onbufferchange(0),a._resetOnPosition(0),a.paused=!1,a.isHTML5||(a.playState=0),x(),c.to&&a.clearOnPosition(c.to),a.isHTML5?a._a&&(b=a.position,a.setPosition(0),a.position=b,a._a.pause(),a.playState=0,a._onTimer(),g()):(l._stop(a.id,b),c.serverURL&&a.unload()),a.instanceCount= -0,a._iO={},c.onstop&&c.onstop.apply(a));return a};this.setAutoPlay=function(b){a._iO.autoPlay=b;a.isHTML5||(l._setAutoPlay(a.id,b),b&&!a.instanceCount&&1===a.readyState&&a.instanceCount++)};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){b===k&&(b=0);var c=a.isHTML5?Math.max(b,0):Math.min(a.duration||a._iO.duration,Math.max(b,0));a.position=c;b=a.position/1E3;a._resetOnPosition(a.position);a._iO.position=c;if(a.isHTML5){if(a._a){if(a._html5_canplay){if(a._a.currentTime!== -b)try{a._a.currentTime=b,(0===a.playState||a.paused)&&a._a.pause()}catch(e){}}else if(b)return a;a.paused&&a._onTimer(!0)}}else b=9===m?a.position:b,a.readyState&&2!==a.readyState&&l._setPosition(a.id,b,a.paused||!a.playState,a._iO.multiShot);return a};this.pause=function(b){if(a.paused||0===a.playState&&1!==a.readyState)return a;a.paused=!0;a.isHTML5?(a._setup_html5().pause(),g()):(b||b===k)&&l._pause(a.id,a._iO.multiShot);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){var b= -a._iO;if(!a.paused)return a;a.paused=!1;a.playState=1;a.isHTML5?(a._setup_html5().play(),n()):(b.isMovieStar&&!b.serverURL&&a.setPosition(a.position),l._pause(a.id,b.multiShot));!s&&b.onplay?(b.onplay.apply(a),s=!0):b.onresume&&b.onresume.apply(a);return a};this.togglePause=function(){if(0===a.playState)return a.play({position:9===m&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,c){b===k&&(b=0);c===k&&(c=!1);a.isHTML5||l._setPan(a.id,b);a._iO.pan= -b;c||(a.pan=b,a.options.pan=b);return a};this.setVolume=function(b,e){b===k&&(b=100);e===k&&(e=!1);a.isHTML5?a._a&&(c.muted&&!a.muted&&(a.muted=!0,a._a.muted=!0),a._a.volume=Math.max(0,Math.min(1,b/100))):l._setVolume(a.id,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;e||(a.volume=b,a.options.volume=b);return a};this.mute=function(){a.muted=!0;a.isHTML5?a._a&&(a._a.muted=!0):l._setVolume(a.id,0);return a};this.unmute=function(){a.muted=!1;var b=a._iO.volume!==k;a.isHTML5?a._a&&(a._a.muted=!1):l._setVolume(a.id, -b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=this.onPosition=function(b,c,e){p.push({position:parseInt(b,10),method:c,scope:e!==k?e:a,fired:!1});return a};this.clearOnPosition=function(a,b){var c;a=parseInt(a,10);if(isNaN(a))return!1;for(c=0;c=b)return!1;for(b-= -1;0<=b;b--)c=p[b],!c.fired&&a.position>=c.position&&(c.fired=!0,u++,c.method.apply(c.scope,[c.position]));return!0};this._resetOnPosition=function(a){var b,c;b=p.length;if(!b)return!1;for(b-=1;0<=b;b--)c=p[b],c.fired&&a<=c.position&&(c.fired=!1,u--);return!0};y=function(){var b=a._iO,c=b.from,e=b.to,d,f;f=function(){a.clearOnPosition(e,f);a.stop()};d=function(){if(null!==e&&!isNaN(e))a.onPosition(e,f)};null!==c&&!isNaN(c)&&(b.position=c,b.multiShot=!1,d());return b};q=function(){var b,c=a._iO.onposition; -if(c)for(b in c)if(c.hasOwnProperty(b))a.onPosition(parseInt(b,10),c[b])};x=function(){var b,c=a._iO.onposition;if(c)for(b in c)c.hasOwnProperty(b)&&a.clearOnPosition(parseInt(b,10))};n=function(){a.isHTML5&&Ra(a)};g=function(){a.isHTML5&&Sa(a)};f=function(b){b||(p=[],u=0);s=!1;a._hasTimer=null;a._a=null;a._html5_canplay=!1;a.bytesLoaded=null;a.bytesTotal=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.buffered=[];a.eqData=[];a.eqData.left=[];a.eqData.right=[]; -a.failures=0;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.loaded=!1;a.metadata={};a.readyState=0;a.muted=!1;a.paused=!1;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.playState=0;a.position=null;a.id3={}};f();this._onTimer=function(b){var c,f=!1,h={};if(a._hasTimer||b){if(a._a&&(b||(0opera.version()?new Audio(null):new Audio,c=a._a,c._called_load=!1,A&&(Ka=c);a.isHTML5=!0;a._a=c;c._s=a;h();a._apply_loop(c,b.loops);b.autoLoad||b.autoPlay?a.load():(c.autobuffer=!1,c.preload="auto");return c};h=function(){if(a._a._added_events)return!1;var b;a._a._added_events=!0;for(b in B)B.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,B[b],!1);return!0};J=function(){var b;a._a._added_events= -!1;for(b in B)B.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,B[b],!1)};this._onload=function(b){var c=!!b||!a.isHTML5&&8===m&&a.duration;a.loaded=c;a.readyState=c?3:2;a._onbufferchange(0);a._iO.onload&&ga(a,function(){a._iO.onload.apply(a,[c])});return!0};this._onbufferchange=function(b){if(0===a.playState||b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=1===b;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return!0};this._onsuspend=function(){a._iO.onsuspend&&a._iO.onsuspend.apply(a); -return!0};this._onfailure=function(b,c,e){a.failures++;if(a._iO.onfailure&&1===a.failures)a._iO.onfailure(a,b,c,e)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a._resetOnPosition(0);a.instanceCount&&(a.instanceCount--,a.instanceCount||(x(),a.playState=0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},g(),a.isHTML5&&(a.position=0)),(!a.instanceCount||a._iO.multiShotEvents)&&b&&ga(a,function(){b.apply(a)}))};this._whileloading=function(b,c,e,d){var f=a._iO;a.bytesLoaded= -b;a.bytesTotal=c;a.duration=Math.floor(e);a.bufferLength=d;a.durationEstimate=!a.isHTML5&&!f.isMovieStar?f.duration?a.duration>f.duration?a.duration:f.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10):a.duration;a.isHTML5||(a.buffered=[{start:0,end:a.duration}]);(3!==a.readyState||a.isHTML5)&&f.whileloading&&f.whileloading.apply(a)};this._whileplaying=function(b,c,e,d,f){var h=a._iO;if(isNaN(b)||null===b)return!1;a.position=Math.max(0,b);a._processOnPosition();!a.isHTML5&&8opera.version()?new Audio(null):new Audio:null,d,a,f={},h,g;h=c.audioFormats;for(d in h)if(h.hasOwnProperty(d)&&(a="audio/"+d,f[d]=b(h[d].type),f[a]=f[d],d.match(bb)?(c.flash[d]=!0,c.flash[a]=!0):(c.flash[d]=!1,c.flash[a]=!1),h[d]&&h[d].related))for(g=h[d].related.length-1;0<=g;g--)f["audio/"+h[d].related[g]]=f[d],c.html5[h[d].related[g]]=f[d],c.flash[h[d].related[g]]=f[d];f.canPlayType=e?b:null;c.html5=w(c.html5,f);c.html5.usingFlash= -Va();u=c.html5.usingFlash;return!0};sa={};P=function(){};aa=function(b){8===m&&(1m)&&(c.flashVersion=m=9);c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===m?" (AS3/Flash 9)": -" (AS2/Flash 8)");8b&&(e=!0));setTimeout(function(){b=c.getMoviePercent();if(e)return Q=!1,g.setTimeout(F,1),!1;!p&&ab&&(null===b?c.useFlashBlock||0===c.flashLoadTimeout?c.useFlashBlock&&za():!c.useFlashBlock&&S?qa():D({type:"ontimeout",ignoreInit:!0,error:{type:"INIT_FLASHBLOCK"}}):0!==c.flashLoadTimeout&&(!c.useFlashBlock&&S?qa():xa(!0)))},c.flashLoadTimeout)};Y=function(){if(Ga||!ja)return t.remove(g,"focus", -Y),!0;Ga=ab=!0;Q=!1;F();t.remove(g,"focus",Y);return!0};M=function(b){if(p)return!1;if(c.html5Only)return p=!0,E(),!0;var e=!0,d;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())p=!0;d={type:!v&&u?"NO_FLASH":"INIT_TIMEOUT"};if(y||b)c.useFlashBlock&&c.oMC&&(c.oMC.className=I()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error")),D({type:"ontimeout",error:d,ignoreInit:!0}),H(d),e=!1;y||(c.waitForWindowLoad&&!na?t.add(g,"load",E):E());return e};Ma=function(){var b,e=c.setupOptions; -for(b in e)e.hasOwnProperty(b)&&(c[b]===k?c[b]=e[b]:c[b]!==e[b]&&(c.setupOptions[b]=c[b]))};ma=function(){if(p)return!1;if(c.html5Only)return p||(t.remove(g,"load",c.beginDelayedInit),c.enabled=!0,M()),!0;Z();try{l._externalInterfaceTest(!1),Oa(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||l._disableDebug(),c.enabled=!0,c.html5Only||t.add(g,"unload",la)}catch(b){return H({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),xa(!0),M(),!1}M();t.remove(g,"load",c.beginDelayedInit);return!0}; -G=function(){if(N)return!1;N=!0;Ma();wa();!v&&c.hasHTML5&&c.setup({useHTML5Audio:!0,preferFlash:!1});Wa();!v&&u&&(Ua.push(sa.needFlash),c.setup({flashLoadTimeout:1}));n.removeEventListener&&n.removeEventListener("DOMContentLoaded",G,!1);Z();return!0};Ba=function(){"complete"===n.readyState&&(G(),n.detachEvent("onreadystatechange",Ba));return!0};ua=function(){na=!0;t.remove(g,"load",ua)};ta=function(){if(Fa&&(c.setupOptions.useHTML5Audio=!0,c.setupOptions.preferFlash=!1,ha||Za&&!s.match(/android\s2\.3/i)))ha&& -(c.ignoreFlash=!0),A=!0};ta();Da();t.add(g,"focus",Y);t.add(g,"load",F);t.add(g,"load",ua);n.addEventListener?n.addEventListener("DOMContentLoaded",G,!1):n.attachEvent?n.attachEvent("onreadystatechange",Ba):H({type:"NO_DOM2_EVENTS",fatal:!0})}var ka=null;if(void 0===g.SM2_DEFER||!SM2_DEFER)ka=new U;g.SoundManager=U;g.soundManager=ka})(window); \ No newline at end of file diff --git a/templates/html5/template/lib/soundmanager/swf/soundmanager2.swf b/templates/html5/template/lib/soundmanager/swf/soundmanager2.swf deleted file mode 100755 index e900766a8..000000000 Binary files a/templates/html5/template/lib/soundmanager/swf/soundmanager2.swf and /dev/null differ diff --git a/templates/html5/template/lib/soundmanager/swf/soundmanager2_debug.swf b/templates/html5/template/lib/soundmanager/swf/soundmanager2_debug.swf deleted file mode 100755 index a6809121f..000000000 Binary files a/templates/html5/template/lib/soundmanager/swf/soundmanager2_debug.swf and /dev/null differ diff --git a/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash9.swf b/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash9.swf deleted file mode 100755 index 3d4222a34..000000000 Binary files a/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash9.swf and /dev/null differ diff --git a/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash9_debug.swf b/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash9_debug.swf deleted file mode 100755 index c1a129d88..000000000 Binary files a/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash9_debug.swf and /dev/null differ diff --git a/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash_xdomain.zip b/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash_xdomain.zip deleted file mode 100755 index 5661d2130..000000000 Binary files a/templates/html5/template/lib/soundmanager/swf/soundmanager2_flash_xdomain.zip and /dev/null differ