add ConsoleRenderContext
This commit is contained in:
@@ -3,6 +3,7 @@ package lime._backend.native;
|
||||
|
||||
import lime.app.Application;
|
||||
import lime.graphics.opengl.GL;
|
||||
import lime.graphics.ConsoleRenderContext;
|
||||
import lime.graphics.GLRenderContext;
|
||||
import lime.graphics.RenderContext;
|
||||
import lime.graphics.Renderer;
|
||||
@@ -36,7 +37,11 @@ class NativeRenderer {
|
||||
|
||||
handle = lime_renderer_create (parent.window.backend.handle);
|
||||
|
||||
parent.context = OPENGL (new GLRenderContext ());
|
||||
#if lime_console
|
||||
parent.context = CONSOLE (new ConsoleRenderContext ());
|
||||
#else
|
||||
parent.context = OPENGL (new GLRenderContext ());
|
||||
#end
|
||||
|
||||
if (!registered) {
|
||||
|
||||
@@ -75,7 +80,11 @@ class NativeRenderer {
|
||||
|
||||
case RENDER_CONTEXT_RESTORED:
|
||||
|
||||
parent.context = OPENGL (new GLRenderContext ());
|
||||
#if lime_console
|
||||
parent.context = CONSOLE (new ConsoleRenderContext ());
|
||||
#else
|
||||
parent.context = OPENGL (new GLRenderContext ());
|
||||
#end
|
||||
|
||||
Renderer.onRenderContextRestored.dispatch (parent.context);
|
||||
|
||||
@@ -154,4 +163,4 @@ private class RenderEventInfo {
|
||||
var RENDER_CONTEXT_LOST = 1;
|
||||
var RENDER_CONTEXT_RESTORED = 2;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
50
lime/graphics/ConsoleRenderContext.hx
Normal file
50
lime/graphics/ConsoleRenderContext.hx
Normal file
@@ -0,0 +1,50 @@
|
||||
package lime.graphics;
|
||||
|
||||
|
||||
import lime.system.System;
|
||||
|
||||
|
||||
class ConsoleRenderContext {
|
||||
#if lime_console
|
||||
|
||||
|
||||
public function new () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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 ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -2,17 +2,18 @@ package lime.graphics;
|
||||
|
||||
|
||||
import lime.graphics.CanvasRenderContext;
|
||||
import lime.graphics.ConsoleRenderContext;
|
||||
import lime.graphics.DOMRenderContext;
|
||||
import lime.graphics.FlashRenderContext;
|
||||
import lime.graphics.GLRenderContext;
|
||||
|
||||
|
||||
enum RenderContext {
|
||||
|
||||
OPENGL (gl:GLRenderContext);
|
||||
CANVAS (context:CanvasRenderContext);
|
||||
DOM (element:DOMRenderContext);
|
||||
FLASH (stage:FlashRenderContext);
|
||||
CONSOLE (context:ConsoleRenderContext);
|
||||
CUSTOM (data:Dynamic);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user