Handle title and window flags
This commit is contained in:
@@ -23,10 +23,7 @@ import flash.Lib;
|
||||
class Window {
|
||||
|
||||
|
||||
public inline static var DEPTH_BUFFER = 0x0200;
|
||||
public inline static var STENCIL_BUFFER = 0x0400;
|
||||
|
||||
public static var onWindowActivate = new Event<Void->Void> ();
|
||||
public static var onWindowActivate = new Event<Void->Void> ();
|
||||
public static var onWindowDeactivate = new Event<Void->Void> ();
|
||||
|
||||
private static var eventInfo = new WindowEventInfo ();
|
||||
@@ -172,16 +169,28 @@ class Window {
|
||||
#end
|
||||
|
||||
#elseif (cpp || neko)
|
||||
// forward flags
|
||||
var flags:Int = 0;
|
||||
|
||||
if (config.depthBuffer)
|
||||
flags |= DEPTH_BUFFER;
|
||||
|
||||
if (config.stencilBuffer)
|
||||
flags |= STENCIL_BUFFER;
|
||||
var flags = 0;
|
||||
|
||||
if (config.antialiasing >= 4) {
|
||||
|
||||
flags |= cast WindowFlags.WINDOW_FLAG_HW_AA_HIRES;
|
||||
|
||||
} else if (config.antialiasing >= 2) {
|
||||
|
||||
flags |= cast WindowFlags.WINDOW_FLAG_HW_AA;
|
||||
|
||||
}
|
||||
|
||||
if (config.borderless) flags |= cast WindowFlags.WINDOW_FLAG_BORDERLESS;
|
||||
if (config.depthBuffer) flags |= cast WindowFlags.WINDOW_FLAG_DEPTH_BUFFER;
|
||||
if (config.fullscreen) flags |= cast WindowFlags.WINDOW_FLAG_FULLSCREEN;
|
||||
if (config.resizable) flags |= cast WindowFlags.WINDOW_FLAG_RESIZABLE;
|
||||
if (config.stencilBuffer) flags |= cast WindowFlags.WINDOW_FLAG_STENCIL_BUFFER;
|
||||
if (config.vsync) flags |= cast WindowFlags.WINDOW_FLAG_VSYNC;
|
||||
|
||||
handle = lime_window_create (application.__handle, width, height, flags, config.title);
|
||||
|
||||
handle = lime_window_create (application.__handle, width, height, flags);
|
||||
#end
|
||||
|
||||
MouseEventManager.registerWindow (this);
|
||||
@@ -242,7 +251,7 @@ class Window {
|
||||
|
||||
|
||||
#if (cpp || neko)
|
||||
private static var lime_window_create = System.load ("lime", "lime_window_create", 4);
|
||||
private static var lime_window_create = System.load ("lime", "lime_window_create", 5);
|
||||
private static var lime_window_event_manager_register = System.load ("lime", "lime_window_event_manager_register", 2);
|
||||
#end
|
||||
|
||||
@@ -273,6 +282,23 @@ private class WindowEventInfo {
|
||||
}
|
||||
|
||||
|
||||
@:enum private abstract WindowFlags(Int) {
|
||||
|
||||
var WINDOW_FLAG_FULLSCREEN = 0x00000001;
|
||||
var WINDOW_FLAG_BORDERLESS = 0x00000002;
|
||||
var WINDOW_FLAG_RESIZABLE = 0x00000004;
|
||||
var WINDOW_FLAG_HARDWARE = 0x00000008;
|
||||
var WINDOW_FLAG_VSYNC = 0x00000010;
|
||||
var WINDOW_FLAG_HW_AA = 0x00000020;
|
||||
var WINDOW_FLAG_HW_AA_HIRES = 0x00000060;
|
||||
var WINDOW_FLAG_ALLOW_SHADERS = 0x00000080;
|
||||
var WINDOW_FLAG_REQUIRE_SHADERS = 0x00000100;
|
||||
var WINDOW_FLAG_DEPTH_BUFFER = 0x00000200;
|
||||
var WINDOW_FLAG_STENCIL_BUFFER = 0x00000400;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@:enum private abstract WindowEventType(Int) {
|
||||
|
||||
var WINDOW_ACTIVATE = 0;
|
||||
|
||||
@@ -18,14 +18,32 @@ namespace lime {
|
||||
public:
|
||||
|
||||
Application* currentApplication;
|
||||
|
||||
int flags;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Window* CreateWindow (Application* application, int width, int height, int flags);
|
||||
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title);
|
||||
|
||||
|
||||
enum WindowFlags {
|
||||
|
||||
WINDOW_FLAG_FULLSCREEN = 0x00000001,
|
||||
WINDOW_FLAG_BORDERLESS = 0x00000002,
|
||||
WINDOW_FLAG_RESIZABLE = 0x00000004,
|
||||
WINDOW_FLAG_HARDWARE = 0x00000008,
|
||||
WINDOW_FLAG_VSYNC = 0x00000010,
|
||||
WINDOW_FLAG_HW_AA = 0x00000020,
|
||||
WINDOW_FLAG_HW_AA_HIRES = 0x00000060,
|
||||
WINDOW_FLAG_ALLOW_SHADERS = 0x00000080,
|
||||
WINDOW_FLAG_REQUIRE_SHADERS = 0x00000100,
|
||||
WINDOW_FLAG_DEPTH_BUFFER = 0x00000200,
|
||||
WINDOW_FLAG_STENCIL_BUFFER = 0x00000400
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -177,9 +177,9 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_window_create (value application, value width, value height, value flags) {
|
||||
value lime_window_create (value application, value width, value height, value flags, value title) {
|
||||
|
||||
Window* window = CreateWindow ((Application*)(intptr_t)val_float (application), val_int (width), val_int (height), val_int(flags));
|
||||
Window* window = CreateWindow ((Application*)(intptr_t)val_float (application), val_int (width), val_int (height), val_int (flags), val_string (title));
|
||||
return alloc_float ((intptr_t)window);
|
||||
|
||||
}
|
||||
@@ -209,7 +209,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, 4);
|
||||
DEFINE_PRIM (lime_window_create, 5);
|
||||
DEFINE_PRIM (lime_window_event_manager_register, 2);
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,28 @@ namespace lime {
|
||||
|
||||
if (context) {
|
||||
|
||||
SDL_GL_SetSwapInterval (0);
|
||||
if (window->flags & WINDOW_FLAG_VSYNC) {
|
||||
|
||||
SDL_GL_SetSwapInterval (1);
|
||||
|
||||
} else {
|
||||
|
||||
SDL_GL_SetSwapInterval (0);
|
||||
|
||||
}
|
||||
|
||||
if (window->flags & WINDOW_FLAG_DEPTH_BUFFER) {
|
||||
|
||||
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 32 - (window->flags & WINDOW_FLAG_STENCIL_BUFFER) ? 8 : 0);
|
||||
|
||||
}
|
||||
|
||||
if (window->flags & WINDOW_FLAG_STENCIL_BUFFER) {
|
||||
|
||||
SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 8);
|
||||
|
||||
}
|
||||
|
||||
SDL_GL_MakeCurrent (sdlWindow, context);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
SDLWindow::SDLWindow (Application* application, int width, int height, int flags) {
|
||||
SDLWindow::SDLWindow (Application* application, int width, int height, int flags, const char* title) {
|
||||
|
||||
currentApplication = application;
|
||||
this->flags = flags;
|
||||
|
||||
// config the window
|
||||
if (flags & DEPTH_BUFFER)
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32 - (flags & STENCIL_BUFFER) ? 8 : 0);
|
||||
int sdlFlags = SDL_WINDOW_OPENGL;
|
||||
|
||||
if (flags & STENCIL_BUFFER)
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
if (flags & WINDOW_FLAG_FULLSCREEN) sdlFlags |= SDL_WINDOW_FULLSCREEN;
|
||||
if (flags & WINDOW_FLAG_RESIZABLE) sdlFlags |= SDL_WINDOW_RESIZABLE;
|
||||
if (flags & WINDOW_FLAG_BORDERLESS) sdlFlags |= SDL_WINDOW_BORDERLESS;
|
||||
|
||||
sdlWindow = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL);
|
||||
sdlWindow = SDL_CreateWindow (title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, sdlFlags);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
Window* CreateWindow (Application* application, int width, int height, int flags) {
|
||||
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) {
|
||||
|
||||
return new SDLWindow (application, width, height, flags);
|
||||
return new SDLWindow (application, width, height, flags, title);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,12 @@
|
||||
|
||||
namespace lime {
|
||||
|
||||
enum SDLWindowFlags
|
||||
{
|
||||
DEPTH_BUFFER = 0x00000200,
|
||||
STENCIL_BUFFER = 0x00000400,
|
||||
};
|
||||
|
||||
class SDLWindow : public Window {
|
||||
|
||||
public:
|
||||
|
||||
SDLWindow (Application* application, int width, int height, int flags);
|
||||
SDLWindow (Application* application, int width, int height, int flags, const char* title);
|
||||
~SDLWindow ();
|
||||
|
||||
SDL_Window* sdlWindow;
|
||||
|
||||
Reference in New Issue
Block a user