diff --git a/src/lime/_internal/backend/flash/FlashApplication.hx b/src/lime/_internal/backend/flash/FlashApplication.hx index 70a834704..4b02d421f 100644 --- a/src/lime/_internal/backend/flash/FlashApplication.hx +++ b/src/lime/_internal/backend/flash/FlashApplication.hx @@ -6,6 +6,7 @@ import flash.ui.Multitouch; import lime.app.Application; import lime.app.Config; import lime.media.AudioManager; +import lime.ui.Window; @:access(lime.app.Application) @@ -22,12 +23,10 @@ class FlashApplication { AudioManager.init (); - } - - - public function create (config:Config):Void { - - + #if (flash && !air) + var window = new Window (); + parent.addWindow (window); + #end } diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 854c24358..912c3fd5c 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -33,7 +33,7 @@ import lime.ui.Window; @:access(lime._internal.backend.html5.HTML5Application) -@:access(lime._internal.backend.html5.HTML5OpenGLRenderContext) +@:access(lime._internal.backend.html5.HTML5WebGL2RenderContext) @:access(lime.app.Application) @:access(lime.graphics.opengl.GL) @:access(lime.graphics.OpenGLRenderContext) @@ -282,7 +282,7 @@ class HTML5Window { } else if (canvas != null) { - var webgl:RenderingContext = null; + var webgl:HTML5WebGL2RenderContext = null; var forceCanvas = #if (canvas || munit) true #else (renderType == "canvas") #end; var forceWebGL = #if webgl true #else (renderType == "opengl" || renderType == "webgl" || renderType == "webgl1" || renderType == "webgl2") #end; diff --git a/src/lime/app/Application.hx b/src/lime/app/Application.hx index 9c4739c36..d9a0eee6b 100644 --- a/src/lime/app/Application.hx +++ b/src/lime/app/Application.hx @@ -36,9 +36,9 @@ class Application extends Module { /** - * Configuration values for the application, such as window options or a package name + * Meta-data values for the application, such as a version or a package name **/ - public var config (default, null):Config; + public var metaData:MetaData; /** * A list of currently attached Module instances @@ -104,6 +104,37 @@ class Application extends Module { registerModule (this); + // if (config != null) { + + // if (Reflect.hasField (config, "windows")) { + + // for (windowConfig in config.windows) { + + // var window = new Window (windowConfig); + // createWindow (window); + + // #if ((flash && !air) || html5) + // break; + // #end + + // } + + // } + + // if (__preloader == null || __preloader.complete) { + + // setPreloader (__preloader); + + // for (module in modules) { + + // setPreloader (__preloader); + + // } + + // } + + // } + } @@ -167,59 +198,31 @@ class Application extends Module { window.onTextInput.add (onTextInput); window.onUpdate.add (update); - if (window.id > -1) { - - onWindowCreate (); - - } - } if (__windows.indexOf (window) == -1) { __windows.push (window); - } - - } - - - /** - * Initializes the Application, using the settings defined in - * the config instance. By default, this is called automatically - * when building the project using Lime's command-line tools - * @param config A Config object - */ - public function create (config:Config):Void { - - this.config = config; - - __backend.create (config); - - if (config != null) { - - if (Reflect.hasField (config, "windows")) { + for (module in modules) { - for (windowConfig in config.windows) { - - var window = new Window (windowConfig); - createWindow (window); - - #if ((flash && !air) || html5) - break; - #end - - } + module.addWindow (window); } - if (__preloader == null || __preloader.complete) { + if (window.id == -1) { - setPreloader (__preloader); + window.create (this); + //__windows.push (window); + __windowByID.set (window.id, window); - for (module in modules) { + window.onCreate.dispatch (); + + } else { + + if (window == __window) { - setPreloader (__preloader); + onWindowCreate (); } @@ -230,30 +233,6 @@ class Application extends Module { } - /** - * Adds a new Window to the Application. By default, this is - * called automatically by create() - * @param window A Window object to add - */ - public function createWindow (window:Window):Void { - - addWindow (window); - - for (module in modules) { - - module.addWindow (window); - - } - - window.create (this); - //__windows.push (window); - __windowByID.set (window.id, window); - - window.onCreate.dispatch (); - - } - - /** * Execute the Application. On native platforms, this method * blocks until the application is finished running. On other diff --git a/src/lime/app/MetaData.hx b/src/lime/app/MetaData.hx new file mode 100644 index 000000000..79f8eaba2 --- /dev/null +++ b/src/lime/app/MetaData.hx @@ -0,0 +1,65 @@ +package lime.app; + + +typedef MetaData = { + + /** + * A build number + * + * The build number is a unique, integer-based value which increases + * upon each build or release of an application. This is distinct from + * the version number. + * + * In the default generated config for Lime applications, this is often + * updated automatically, or can be overriden in XML project files using + * the `` attribute + **/ + @:optional var build:String; + + /** + * A company name + * + * In the default generated config for Lime applications, this value + * corresponds to the `` attribute in XML + **/ + @:optional var company:String; + + /** + * An application file name, without a file extension + * + * In the default generated config for Lime applications, this value + * corresponds to the `` attribute in XML + **/ + @:optional var file:String; + + /** + * An application name, used as the default Window title + * + * In the default generated config for Lime applications, this value + * corresponds to the `` attribute in XML + **/ + @:optional var name:String; + + /** + * A package name, this usually corresponds to the unique ID used + * in application stores to identify the current application + * + * In the default generated config for Lime applications, this value + * corresponds to the `` attribute in XML + **/ + @:optional var packageName:String; + + /** + * A version number + * + * The version number is what normally corresponds to the user-facing + * version for an application, such as "1.0.0" or "12.2.5". This is + * distinct from the build number. Many application stores expect the + * version number to include three segments. + * + * In the default generated config for Lime applications, this value + * corresponds to the `` attribute in XML + **/ + @:optional var version:String; + +} \ No newline at end of file diff --git a/src/lime/graphics/WebGL2RenderContext.hx b/src/lime/graphics/WebGL2RenderContext.hx index f25a24665..153f5befe 100644 --- a/src/lime/graphics/WebGL2RenderContext.hx +++ b/src/lime/graphics/WebGL2RenderContext.hx @@ -3183,9 +3183,9 @@ abstract WebGL2RenderContext(OpenGLRenderContext) from OpenGLRenderContext to Op } - @:from private static function fromGL (gl:Class):WebGL2RenderContext { + @:from private static function fromRenderContext (context:RenderContext):WebGL2RenderContext { - return cast GL.context; + return context.webgl2; } @@ -3197,16 +3197,9 @@ abstract WebGL2RenderContext(OpenGLRenderContext) from OpenGLRenderContext to Op } - @:from private static function fromRenderContext (context:RenderContext):WebGL2RenderContext { + @:from private static function fromGL (gl:Class):WebGL2RenderContext { - return context.webgl2; - - } - - - @:from private static function toWebGLRenderContext (gl:WebGLRenderContext):WebGL2RenderContext { - - return cast gl; + return cast GL.context; } diff --git a/src/lime/graphics/WebGLRenderContext.hx b/src/lime/graphics/WebGLRenderContext.hx index d5d1f9eb0..88eda5655 100644 --- a/src/lime/graphics/WebGLRenderContext.hx +++ b/src/lime/graphics/WebGLRenderContext.hx @@ -8,7 +8,7 @@ import lime.utils.Float32Array; @:forward(DEPTH_BUFFER_BIT, STENCIL_BUFFER_BIT, COLOR_BUFFER_BIT, POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN, ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, DST_COLOR, ONE_MINUS_DST_COLOR, SRC_ALPHA_SATURATE, FUNC_ADD, BLEND_EQUATION, BLEND_EQUATION_RGB, BLEND_EQUATION_ALPHA, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, BLEND_DST_RGB, BLEND_SRC_RGB, BLEND_DST_ALPHA, BLEND_SRC_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, CONSTANT_ALPHA, ONE_MINUS_CONSTANT_ALPHA, BLEND_COLOR, ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, ARRAY_BUFFER_BINDING, ELEMENT_ARRAY_BUFFER_BINDING, STREAM_DRAW, STATIC_DRAW, DYNAMIC_DRAW, BUFFER_SIZE, BUFFER_USAGE, CURRENT_VERTEX_ATTRIB, FRONT, BACK, FRONT_AND_BACK, CULL_FACE, BLEND, DITHER, STENCIL_TEST, DEPTH_TEST, SCISSOR_TEST, POLYGON_OFFSET_FILL, SAMPLE_ALPHA_TO_COVERAGE, SAMPLE_COVERAGE, NO_ERROR, INVALID_ENUM, INVALID_VALUE, INVALID_OPERATION, OUT_OF_MEMORY, CW , CCW, LINE_WIDTH, ALIASED_POINT_SIZE_RANGE, ALIASED_LINE_WIDTH_RANGE, CULL_FACE_MODE, FRONT_FACE, DEPTH_RANGE, DEPTH_WRITEMASK, DEPTH_CLEAR_VALUE, DEPTH_FUNC, STENCIL_CLEAR_VALUE, STENCIL_FUNC, STENCIL_FAIL, STENCIL_PASS_DEPTH_FAIL, STENCIL_PASS_DEPTH_PASS, STENCIL_REF, STENCIL_VALUE_MASK, STENCIL_WRITEMASK, STENCIL_BACK_FUNC, STENCIL_BACK_FAIL, STENCIL_BACK_PASS_DEPTH_FAIL, STENCIL_BACK_PASS_DEPTH_PASS, STENCIL_BACK_REF, STENCIL_BACK_VALUE_MASK, STENCIL_BACK_WRITEMASK, VIEWPORT, SCISSOR_BOX, COLOR_CLEAR_VALUE, COLOR_WRITEMASK, UNPACK_ALIGNMENT, PACK_ALIGNMENT, MAX_TEXTURE_SIZE, MAX_VIEWPORT_DIMS, SUBPIXEL_BITS, RED_BITS, GREEN_BITS, BLUE_BITS, ALPHA_BITS, DEPTH_BITS, STENCIL_BITS, POLYGON_OFFSET_UNITS, POLYGON_OFFSET_FACTOR, TEXTURE_BINDING_2D, SAMPLE_BUFFERS, SAMPLES, SAMPLE_COVERAGE_VALUE, SAMPLE_COVERAGE_INVERT, COMPRESSED_TEXTURE_FORMATS, DONT_CARE, FASTEST, NICEST, GENERATE_MIPMAP_HINT, BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, UNSIGNED_INT, FLOAT, DEPTH_COMPONENT, ALPHA, RGB, RGBA, LUMINANCE, LUMINANCE_ALPHA, UNSIGNED_SHORT_4_4_4_4, UNSIGNED_SHORT_5_5_5_1, UNSIGNED_SHORT_5_6_5, FRAGMENT_SHADER, VERTEX_SHADER, MAX_VERTEX_ATTRIBS, MAX_VERTEX_UNIFORM_VECTORS, MAX_VARYING_VECTORS, MAX_COMBINED_TEXTURE_IMAGE_UNITS, MAX_VERTEX_TEXTURE_IMAGE_UNITS, MAX_TEXTURE_IMAGE_UNITS, MAX_FRAGMENT_UNIFORM_VECTORS, SHADER_TYPE, DELETE_STATUS, LINK_STATUS, VALIDATE_STATUS, ATTACHED_SHADERS, ACTIVE_UNIFORMS, ACTIVE_ATTRIBUTES, SHADING_LANGUAGE_VERSION, CURRENT_PROGRAM, NEVER, LESS, EQUAL, LEQUAL, GREATER, NOTEQUAL, GEQUAL, ALWAYS, KEEP, REPLACE, INCR, DECR, INVERT, INCR_WRAP, DECR_WRAP, VENDOR, RENDERER, VERSION, NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR, TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER, TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_2D, TEXTURE, TEXTURE_CUBE_MAP, TEXTURE_BINDING_CUBE_MAP, TEXTURE_CUBE_MAP_POSITIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_NEGATIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z, TEXTURE_CUBE_MAP_NEGATIVE_Z, MAX_CUBE_MAP_TEXTURE_SIZE, TEXTURE0, TEXTURE1, TEXTURE2, TEXTURE3, TEXTURE4, TEXTURE5, TEXTURE6, TEXTURE7, TEXTURE8, TEXTURE9, TEXTURE10, TEXTURE11, TEXTURE12, TEXTURE13, TEXTURE14, TEXTURE15, TEXTURE16, TEXTURE17, TEXTURE18, TEXTURE19, TEXTURE20, TEXTURE21, TEXTURE22, TEXTURE23, TEXTURE24, TEXTURE25, TEXTURE26, TEXTURE27, TEXTURE28, TEXTURE29, TEXTURE30, TEXTURE31, ACTIVE_TEXTURE, REPEAT, CLAMP_TO_EDGE, MIRRORED_REPEAT, FLOAT_VEC2, FLOAT_VEC3, FLOAT_VEC4, INT_VEC2, INT_VEC3, INT_VEC4, BOOL, BOOL_VEC2, BOOL_VEC3, BOOL_VEC4, FLOAT_MAT2, FLOAT_MAT3, FLOAT_MAT4, SAMPLER_2D, SAMPLER_CUBE, VERTEX_ATTRIB_ARRAY_ENABLED, VERTEX_ATTRIB_ARRAY_SIZE, VERTEX_ATTRIB_ARRAY_STRIDE, VERTEX_ATTRIB_ARRAY_TYPE, VERTEX_ATTRIB_ARRAY_NORMALIZED, VERTEX_ATTRIB_ARRAY_POINTER, VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, COMPILE_STATUS, LOW_FLOAT, MEDIUM_FLOAT, HIGH_FLOAT, LOW_INT, MEDIUM_INT, HIGH_INT, FRAMEBUFFER, RENDERBUFFER, RGBA4, RGB5_A1, RGB565, DEPTH_COMPONENT16, STENCIL_INDEX, STENCIL_INDEX8, DEPTH_STENCIL, RENDERBUFFER_WIDTH, RENDERBUFFER_HEIGHT, RENDERBUFFER_INTERNAL_FORMAT, RENDERBUFFER_RED_SIZE, RENDERBUFFER_GREEN_SIZE, RENDERBUFFER_BLUE_SIZE, RENDERBUFFER_ALPHA_SIZE, RENDERBUFFER_DEPTH_SIZE, RENDERBUFFER_STENCIL_SIZE, FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, COLOR_ATTACHMENT0, DEPTH_ATTACHMENT, STENCIL_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT, NONE, FRAMEBUFFER_COMPLETE, FRAMEBUFFER_INCOMPLETE_ATTACHMENT, FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT, FRAMEBUFFER_INCOMPLETE_DIMENSIONS, FRAMEBUFFER_UNSUPPORTED, FRAMEBUFFER_BINDING, RENDERBUFFER_BINDING, MAX_RENDERBUFFER_SIZE, INVALID_FRAMEBUFFER_OPERATION, UNPACK_FLIP_Y_WEBGL, UNPACK_PREMULTIPLY_ALPHA_WEBGL, CONTEXT_LOST_WEBGL, UNPACK_COLORSPACE_CONVERSION_WEBGL, BROWSER_DEFAULT_WEBGL, type, version, activeTexture, attachShader, bindAttribLocation, bindBuffer, bindFramebuffer, bindRenderbuffer, bindTexture, blendColor, blendEquation, blendEquationSeparate, blendFunc, blendFuncSeparate, checkFramebufferStatus, clear, clearColor, clearDepth, clearStencil, colorMask, compileShader, copyTexImage2D, copyTexSubImage2D, createBuffer, createFramebuffer, createProgram, createRenderbuffer, createShader, createTexture, cullFace, cullFace, deleteBuffer, deleteFramebuffer, deleteProgram, deleteRenderbuffer, deleteShader, deleteTexture, depthFunc, depthMask, depthRange, detachShader, disable, disableVertexAttribArray, drawArrays, drawElements, enable, enableVertexAttribArray, finish, flush, framebufferRenderbuffer, framebufferTexture2D, frontFace, generateMipmap, getActiveAttrib, getActiveUniform, getAttachedShaders, getAttribLocation, getBufferParameter, getContextAttributes, getError, getExtension, getFramebufferAttachmentParameter, getParameter, getProgramInfoLog, getProgramParameter, getRenderbufferParameter, getShaderInfoLog, getShaderParameter, getShaderPrecisionFormat, getShaderSource, getSupportedExtensions, getTexParameter, getUniform, getUniformLocation, getVertexAttrib, getVertexAttribOffset, hint, isBuffer, isContextLost, isEnabled, isFramebuffer, isProgram, isRenderbuffer, isShader, isTexture, lineWidth, linkProgram, pixelStorei, polygonOffset, renderbufferStorage, sampleCoverage, scissor, shaderSource, stencilFunc, stencilFuncSeparate, stencilMask, stencilMaskSeparate, stencilOp, stencilOpSeparate, texParameterf, texParameteri, uniform1f, uniform1fv, uniform1i, uniform1iv, uniform2f, uniform2fv, uniform2i, uniform2iv, uniform3f, uniform3fv, uniform3i, uniform3iv, uniform4f, uniform4fv, uniform4i, uniform4iv, useProgram, validateProgram, vertexAttrib1f, vertexAttrib1fv, vertexAttrib2f, vertexAttrib2fv, vertexAttrib3f, vertexAttrib3fv, vertexAttrib4f, vertexAttrib4fv, vertexAttribPointer, viewport) -abstract WebGLRenderContext(WebGL2RenderContext) from WebGL2RenderContext from WebGL2RenderContext { +abstract WebGLRenderContext(WebGL2RenderContext) { @@ -110,10 +110,31 @@ abstract WebGLRenderContext(WebGL2RenderContext) from WebGL2RenderContext from W } - @:from private static function fromGL (gl:#if lime_opengl Class #else Dynamic #end):WebGLRenderContext { + @:from private static function fromWebGL2RenderContext (gl:WebGL2RenderContext):WebGLRenderContext { + + return cast gl; + + } + + + @:from private static function fromRenderContext (context:RenderContext):WebGLRenderContext { + + return context.webgl; + + } + + + @:from private static function fromGL (gl:Class):WebGLRenderContext { - #if (sys && lime_opengl) return cast GL.context; + + } + + + @:from private static function fromOpenGLContext (gl:OpenGLRenderContext):WebGLRenderContext { + + #if (sys && lime_cffi && lime_opengl) + return cast gl; #else return null; #end @@ -121,16 +142,24 @@ abstract WebGLRenderContext(WebGL2RenderContext) from WebGL2RenderContext from W } - @:from private static function fromGLES2Context (gl:OpenGLES2RenderContext):WebGLRenderContext { + @:from private static function fromOpenGLES2Context (gl:OpenGLES2RenderContext):WebGLRenderContext { - return #if lime_opengl cast gl #else null #end; + #if (sys && lime_cffi && lime_opengl) + return cast gl; + #else + return null; + #end } - @:from private static function fromGLES3Context (gl:OpenGLES3RenderContext):WebGLRenderContext { + @:from private static function fromOpenGLES3Context (gl:OpenGLES3RenderContext):WebGLRenderContext { - return #if lime_opengl cast gl #else null #end; + #if (sys && lime_cffi && lime_opengl) + return cast gl; + #else + return null; + #end }