Hello everyone,
I am really happy because I have goal with --width --height like any games with passing parameters
package;
import lime.graphics.opengl.*;
import openfl.display.*;
import openfl.geom.Rectangle;
import openfl.events.*;
import openfl.Lib;
class Main extends Sprite {
private var view:OpenGLView;
private var Rect:Rectangle;
private var IsWindowed = false;
public function new () {
super ();
if (OpenGLView.isSupported)
{
view = new OpenGLView ();
Lib.application.window.title = "OpenGL Version: " + GL.getString(GL.VERSION);
Lib.application.window.fullscreen = true;
var args = Sys.args();
for (i in 0...args.length)
{
switch(args[i])
{
// width of game
case "--width", "-w":
Lib.application.window.width = Std.parseInt(args[i+1]);
// height of game
case "--height", "-h":
Lib.application.window.height = Std.parseInt(args[i+1]);
// switch windowed or fullscreen
case "-windowed":
IsWindowed = true;
}
}
view.render = renderView;
addChild (view);
}
}
private function renderView (rect:Rectangle):Void
{
Rect = rect;
GL.viewport (Std.int (rect.x), Std.int (rect.y), Std.int (rect.width), Std.int (rect.height));
if(IsWindowed)
Lib.application.window.fullscreen = false;
else
Lib.application.window.fullscreen = true;
Lib.current.stage.align = StageAlign.TOP_LEFT;
Lib.current.stage.scaleMode = StageScaleMode.NO_SCALE;
Lib.current.stage.addEventListener (Event.RESIZE, onResizeHandler);
GL.clearColor(0.39, 0.58, 0.93, 1.0);
GL.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT);
}
private function onResizeHandler(ev:Event):Void
{
Lib.application.window.resize(Std.int(Rect.width), Std.int(Rect.height));
}
static function Main()
{
new Main();
}
}
But I have problem with common black background if I use passing width and height example haxegame --width 1200 --height 660 than it happens like this:
Why does Viewport can’t resize sketch mode via passing command line arguments?
And I see haxegame can’t open in center of desktop screen.
Where are method for native screen width and native screen height?
// EDIT It looks Capabilities of Flash but it is not in Flash Player - just “native” like Lime?
// Updated my code. you can check fullscreen and windowed like any games have same arguments
Thank you for answer if you have idea.