From 081dd94565f8d19c55fe8e385c09aa7d7071a8a0 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 20 Jan 2015 10:51:12 -0800 Subject: [PATCH] Improve console context, add support in 'Hello World' --- lime/graphics/ConsoleRenderContext.hx | 90 +++++++++++++++++++-------- samples/HelloWorld/Source/Main.hx | 5 ++ 2 files changed, 70 insertions(+), 25 deletions(-) diff --git a/lime/graphics/ConsoleRenderContext.hx b/lime/graphics/ConsoleRenderContext.hx index c87ce3627..6d74b267f 100644 --- a/lime/graphics/ConsoleRenderContext.hx +++ b/lime/graphics/ConsoleRenderContext.hx @@ -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 \ No newline at end of file diff --git a/samples/HelloWorld/Source/Main.hx b/samples/HelloWorld/Source/Main.hx index ffb616044..4ccb5502a 100644 --- a/samples/HelloWorld/Source/Main.hx +++ b/samples/HelloWorld/Source/Main.hx @@ -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: }