Work in progress, refactor Application create and GL fixes

This commit is contained in:
Joshua Granick
2018-06-29 16:09:15 -07:00
parent 5229a70764
commit 01afb34e42
6 changed files with 157 additions and 92 deletions

View File

@@ -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
}

View File

@@ -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;

View File

@@ -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

65
src/lime/app/MetaData.hx Normal file
View File

@@ -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 `<app build="" />` attribute
**/
@:optional var build:String;
/**
* A company name
*
* In the default generated config for Lime applications, this value
* corresponds to the `<meta company="" />` 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 `<app file="" />` 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 `<meta title="" />` 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 `<meta package="" />` 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 `<meta title="" />` attribute in XML
**/
@:optional var version:String;
}

View File

@@ -3183,9 +3183,9 @@ abstract WebGL2RenderContext(OpenGLRenderContext) from OpenGLRenderContext to Op
}
@:from private static function fromGL (gl:Class<GL>):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<GL>):WebGL2RenderContext {
return context.webgl2;
}
@:from private static function toWebGLRenderContext (gl:WebGLRenderContext):WebGL2RenderContext {
return cast gl;
return cast GL.context;
}

File diff suppressed because one or more lines are too long