Improve console context, add support in 'Hello World'
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package lime.graphics;
|
||||
package lime.graphics; #if lime_console
|
||||
|
||||
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
class ConsoleRenderContext {
|
||||
#if lime_console
|
||||
|
||||
|
||||
private var depth = 0.0;
|
||||
private var stencil = 0;
|
||||
|
||||
|
||||
public function new () {
|
||||
@@ -13,38 +16,75 @@ class ConsoleRenderContext {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// setClearRGBA sets the RGBA color of a subsequent clear() call.
|
||||
public inline function setClearRGBA (red:Float, green:Float, blue:Float, alpha:Float):Void {
|
||||
|
||||
lime_console_render_set_clear_color (red, green, blue, alpha);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// setClearDepthStencil sets the depth and stencil values for a subsequent clear() call.
|
||||
public inline function setClearDepthStencil (depth:Float, stencil:Int):Void {
|
||||
|
||||
lime_console_render_set_clear_depth_stencil (depth, stencil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// clear fills the current color and/or depth-stencil values of the buffer,
|
||||
// specified by the preceding setClear calls.
|
||||
|
||||
|
||||
public inline function clear ():Void {
|
||||
|
||||
lime_console_render_clear ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public inline function clearColor (r:Float, g:Float, b:Float, a:Float):Void {
|
||||
|
||||
lime_console_render_set_clear_color (r, g, b, a);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public inline function clearDepth (depth:Float):Void {
|
||||
|
||||
this.depth = depth;
|
||||
|
||||
lime_console_render_set_clear_depth_stencil (depth, stencil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public inline function clearStencil (stencil:Int):Void {
|
||||
|
||||
this.stencil = stencil;
|
||||
|
||||
lime_console_render_set_clear_depth_stencil (depth, stencil);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Native Methods
|
||||
|
||||
|
||||
|
||||
|
||||
private static var lime_console_render_set_clear_color = System.load ("lime", "lime_console_render_set_clear_color", 4);
|
||||
private static var lime_console_render_set_clear_depth_stencil = System.load ("lime", "lime_console_render_set_clear_depth_stencil", 2);
|
||||
private static var lime_console_render_clear = System.load ("lime", "lime_console_render_clear", 0);
|
||||
|
||||
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
class ConsoleRenderContext {
|
||||
|
||||
|
||||
public function new () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function clear ():Void {}
|
||||
public function clearColor (r:Float, g:Float, b:Float, a:Float):Void {}
|
||||
public function clearDepth (depth:Float):Void {}
|
||||
public function clearStencil (stencil:Int):Void {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#end
|
||||
@@ -39,7 +39,12 @@ class Main extends Application {
|
||||
|
||||
gl.clearColor (0.75, 1, 0, 1);
|
||||
gl.clear (gl.COLOR_BUFFER_BIT);
|
||||
|
||||
case CONSOLE (context):
|
||||
|
||||
context.clearColor (0.75, 1, 0, 1);
|
||||
context.clear ();
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user