first pass of adding flags for sdl (stencil and depthbuffer)

This commit is contained in:
Michael Bickel
2014-06-17 04:56:52 +02:00
committed by Joshua Granick
parent e84731a9fb
commit c45b5f52e4
7 changed files with 43 additions and 15 deletions

View File

@@ -7,8 +7,7 @@ import lime.ui.*;
class Application implements IKeyEventListener implements IMouseEventListener implements ITouchEventListener implements IWindowEventListener {
public var handle:Dynamic;
private var config:Config;
@@ -52,7 +51,7 @@ class Application implements IKeyEventListener implements IMouseEventListener im
TouchEventManager.addEventListener (this);
WindowEventManager.addEventListener (this);
var window = new Window (this);
var window = new Window (this, config);
var renderer = new Renderer (window);
window.width = config.width;

View File

@@ -16,6 +16,8 @@ import flash.Lib;
@:access(lime.graphics.opengl.GL)
class Renderer {
public inline static var DEPTH_BUFFER = 0x0200;
public inline static var STENCIL_BUFFER = 0x0400;
public var context:RenderContext;
public var handle:Dynamic;

View File

@@ -19,8 +19,11 @@ import js.Browser;
class Window {
public inline static var DEPTH_BUFFER = 0x0200;
public inline static var STENCIL_BUFFER = 0x0400;
public var currentRenderer:Renderer;
public var config:Config;
public var fullscreen:Bool;
public var height:Int;
public var width:Int;
@@ -39,9 +42,10 @@ class Window {
#end
public function new (application:Application) {
public function new (application:Application, config:Config) {
this.application = application;
this.config = config;
}
@@ -151,7 +155,16 @@ class Window {
#end
#elseif (cpp || neko)
handle = lime_window_create (application.handle);
// forward flags
var flags:Int = 0;
if (config.depthBuffer)
flags |= DEPTH_BUFFER;
if (config.stencilBuffer)
flags |= STENCIL_BUFFER;
handle = lime_window_create (application.handle, flags);
#end
KeyEventManager.registerWindow (this);
@@ -171,7 +184,7 @@ class Window {
#if (cpp || neko)
private static var lime_window_create = System.load ("lime", "lime_window_create", 1);
private static var lime_window_create = System.load ("lime", "lime_window_create", 2);
#end

View File

@@ -23,7 +23,7 @@ namespace lime {
};
Window* CreateWindow (Application* application);
Window* CreateWindow (Application* application, int flags);
}

View File

@@ -159,9 +159,9 @@ namespace lime {
}
value lime_window_create (value application) {
value lime_window_create (value application, value flags) {
Window* window = CreateWindow ((Application*)(intptr_t)val_float (application));
Window* window = CreateWindow ((Application*)(intptr_t)val_float (application), val_int(flags));
return alloc_float ((intptr_t)window);
}
@@ -191,7 +191,7 @@ namespace lime {
DEFINE_PRIM (lime_system_get_timestamp, 0);
DEFINE_PRIM (lime_touch_event_manager_register, 2);
DEFINE_PRIM (lime_update_event_manager_register, 2);
DEFINE_PRIM (lime_window_create, 1);
DEFINE_PRIM (lime_window_create, 2);
DEFINE_PRIM (lime_window_event_manager_register, 2);

View File

@@ -4,9 +4,18 @@
namespace lime {
SDLWindow::SDLWindow (Application* application) {
SDLWindow::SDLWindow (Application* application, int flags) {
currentApplication = application;
// config the window
if (flags & DEPTH_BUFFER)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32 - (flags & STENCIL_BUFFER) ? 8 : 0);
if (flags & STENCIL_BUFFER)
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
sdlWindow = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_OPENGL);
}
@@ -19,9 +28,9 @@ namespace lime {
}
Window* CreateWindow (Application* application) {
Window* CreateWindow (Application* application, int flags) {
return new SDLWindow (application);
return new SDLWindow (application, flags);
}

View File

@@ -8,12 +8,17 @@
namespace lime {
enum SDLWindowFlags
{
DEPTH_BUFFER = 0x00000200,
STENCIL_BUFFER = 0x00000400,
};
class SDLWindow : public Window {
public:
SDLWindow (Application* application);
SDLWindow (Application* application, int flags);
~SDLWindow ();
SDL_Window* sdlWindow;