mirror of https://github.com/buggins/dlangui.git
support SDL2 under Windows
This commit is contained in:
parent
7c0e3006bf
commit
ce71e7dc1a
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>Unicode USE_OPENGL</versionids>
|
<versionids>Unicode USE_OPENGL USE_SDL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>1</createImplib>
|
<createImplib>1</createImplib>
|
||||||
|
@ -225,6 +225,15 @@
|
||||||
<File path="..\DerelictUtil\source\derelict\util\wintypes.d" />
|
<File path="..\DerelictUtil\source\derelict\util\wintypes.d" />
|
||||||
<File path="..\DerelictUtil\source\derelict\util\xtypes.d" />
|
<File path="..\DerelictUtil\source\derelict\util\xtypes.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
|
<Folder name="DerelictSDL2">
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\functions.d" />
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\image.d" />
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\mixer.d" />
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\net.d" />
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\sdl.d" />
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\ttf.d" />
|
||||||
|
<File path="..\DerelictSDL2\source\derelict\sdl2\types.d" />
|
||||||
|
</Folder>
|
||||||
<Folder name="gl3n">
|
<Folder name="gl3n">
|
||||||
<File path="..\gl3n\gl3n\aabb.d" />
|
<File path="..\gl3n\gl3n\aabb.d" />
|
||||||
<File path="..\gl3n\gl3n\frustum.d" />
|
<File path="..\gl3n\gl3n\frustum.d" />
|
||||||
|
@ -320,12 +329,14 @@
|
||||||
<Folder name="common">
|
<Folder name="common">
|
||||||
<File path="src\dlangui\platforms\common\platform.d" />
|
<File path="src\dlangui\platforms\common\platform.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
|
<Folder name="sdl">
|
||||||
|
<File path="src\dlangui\platforms\sdl\sdlapp.d" />
|
||||||
|
</Folder>
|
||||||
<Folder name="windows">
|
<Folder name="windows">
|
||||||
<File path="src\dlangui\platforms\windows\win32drawbuf.d" />
|
<File path="src\dlangui\platforms\windows\win32drawbuf.d" />
|
||||||
<File path="src\dlangui\platforms\windows\win32fonts.d" />
|
<File path="src\dlangui\platforms\windows\win32fonts.d" />
|
||||||
<File path="src\dlangui\platforms\windows\winapp.d" />
|
<File path="src\dlangui\platforms\windows\winapp.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<File path="src\dlangui\platforms\sdl\sdlapp.d" />
|
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder name="widgets">
|
<Folder name="widgets">
|
||||||
<File path="src\dlangui\widgets\controls.d" />
|
<File path="src\dlangui\widgets\controls.d" />
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<compiler>0</compiler>
|
<compiler>0</compiler>
|
||||||
<otherDMD>0</otherDMD>
|
<otherDMD>0</otherDMD>
|
||||||
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
||||||
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../gl3n</imppath>
|
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source </imppath>
|
||||||
<fileImppath />
|
<fileImppath />
|
||||||
<outdir>$(ConfigurationName)</outdir>
|
<outdir>$(ConfigurationName)</outdir>
|
||||||
<objdir>$(OutDir)</objdir>
|
<objdir>$(OutDir)</objdir>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>Unicode USE_OPENGL</versionids>
|
<versionids>Unicode USE_OPENGL USE_SDL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>3</mapverbosity>
|
<mapverbosity>3</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<compiler>0</compiler>
|
<compiler>0</compiler>
|
||||||
<otherDMD>0</otherDMD>
|
<otherDMD>0</otherDMD>
|
||||||
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
|
||||||
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../gl3n</imppath>
|
<imppath>$(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source</imppath>
|
||||||
<fileImppath />
|
<fileImppath />
|
||||||
<outdir>$(ConfigurationName)</outdir>
|
<outdir>$(ConfigurationName)</outdir>
|
||||||
<objdir>$(OutDir)</objdir>
|
<objdir>$(OutDir)</objdir>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>Unicode USE_OPENGL</versionids>
|
<versionids>Unicode USE_OPENGL USE_SDL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>3</mapverbosity>
|
<mapverbosity>3</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
|
|
@ -525,7 +525,9 @@ mixin template APP_ENTRY_POINT() {
|
||||||
/// workaround for link issue when WinMain is located in library
|
/// workaround for link issue when WinMain is located in library
|
||||||
version(Windows) {
|
version(Windows) {
|
||||||
private import win32.windows;
|
private import win32.windows;
|
||||||
|
private import dlangui.platforms.sdl.sdlapp;
|
||||||
private import dlangui.platforms.windows.winapp;
|
private import dlangui.platforms.windows.winapp;
|
||||||
|
|
||||||
extern (Windows)
|
extern (Windows)
|
||||||
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
LPSTR lpCmdLine, int nCmdShow)
|
LPSTR lpCmdLine, int nCmdShow)
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
module src.dlangui.platforms.sdl.sdlapp;
|
module src.dlangui.platforms.sdl.sdlapp;
|
||||||
|
|
||||||
version(USE_SDL) {
|
version(USE_SDL) {
|
||||||
|
import core.runtime;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
|
import std.string;
|
||||||
|
import std.utf;
|
||||||
|
import std.stdio;
|
||||||
|
import std.algorithm;
|
||||||
|
import std.file;
|
||||||
|
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import dlangui.core.events;
|
import dlangui.core.events;
|
||||||
|
@ -244,6 +250,87 @@ version(USE_SDL) {
|
||||||
// entry point
|
// entry point
|
||||||
extern(C) int UIAppMain(string[] args);
|
extern(C) int UIAppMain(string[] args);
|
||||||
|
|
||||||
|
version (Windows) {
|
||||||
|
import win32.windows;
|
||||||
|
import dlangui.platforms.windows.win32fonts;
|
||||||
|
pragma(lib, "gdi32.lib");
|
||||||
|
pragma(lib, "user32.lib");
|
||||||
|
extern(Windows)
|
||||||
|
int DLANGUIWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
|
LPSTR lpCmdLine, int nCmdShow) {
|
||||||
|
int result;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Runtime.initialize();
|
||||||
|
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||||
|
Runtime.terminate();
|
||||||
|
}
|
||||||
|
catch (Throwable e) // catch any uncaught exceptions
|
||||||
|
{
|
||||||
|
MessageBox(null, toUTF16z(e.toString()), "Error",
|
||||||
|
MB_OK | MB_ICONEXCLAMATION);
|
||||||
|
result = 0; // failed
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] splitCmdLine(string line) {
|
||||||
|
string[] res;
|
||||||
|
int start = 0;
|
||||||
|
bool insideQuotes = false;
|
||||||
|
for (int i = 0; i <= line.length; i++) {
|
||||||
|
char ch = i < line.length ? line[i] : 0;
|
||||||
|
if (ch == '\"') {
|
||||||
|
if (insideQuotes) {
|
||||||
|
if (i > start)
|
||||||
|
res ~= line[start .. i];
|
||||||
|
start = i + 1;
|
||||||
|
insideQuotes = false;
|
||||||
|
} else {
|
||||||
|
insideQuotes = true;
|
||||||
|
start = i + 1;
|
||||||
|
}
|
||||||
|
} else if (!insideQuotes && (ch == ' ' || ch == '\t' || ch == 0)) {
|
||||||
|
if (i > start) {
|
||||||
|
res ~= line[start .. i];
|
||||||
|
}
|
||||||
|
start = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
|
||||||
|
{
|
||||||
|
setFileLogger(std.stdio.File("ui.log", "w"));
|
||||||
|
setLogLevel(LogLevel.Trace);
|
||||||
|
Log.d("myWinMain()");
|
||||||
|
string basePath = exePath();
|
||||||
|
Log.i("Current executable: ", exePath());
|
||||||
|
string cmdline = fromStringz(lpCmdLine);
|
||||||
|
Log.i("Command line: ", cmdline);
|
||||||
|
string[] args = splitCmdLine(cmdline);
|
||||||
|
Log.i("Command line params: ", args);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Load the SDL 2 library.
|
||||||
|
DerelictSDL2.load();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Cannot load SDL2 library", e);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//_cmdShow = iCmdShow;
|
||||||
|
//_hInstance = hInstance;
|
||||||
|
|
||||||
|
FontManager.instance = new Win32FontManager();
|
||||||
|
|
||||||
|
return sdlmain(args);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
int main(string[] args)
|
int main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -272,6 +359,11 @@ version(USE_SDL) {
|
||||||
ft.registerFont("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FontFamily.SansSerif, "DejaVu", false, FontWeight.Normal);
|
ft.registerFont("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FontFamily.SansSerif, "DejaVu", false, FontWeight.Normal);
|
||||||
FontManager.instance = ft;
|
FontManager.instance = ft;
|
||||||
|
|
||||||
|
return sdlmain(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int sdlmain(string[] args) {
|
||||||
currentTheme = createDefaultTheme();
|
currentTheme = createDefaultTheme();
|
||||||
|
|
||||||
SDLPlatform sdl = new SDLPlatform();
|
SDLPlatform sdl = new SDLPlatform();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
module dlangui.platforms.windows.win32drawbuf;
|
module dlangui.platforms.windows.win32drawbuf;
|
||||||
|
|
||||||
version (USE_SDL) { }
|
version (Windows) {
|
||||||
else version (Windows) {
|
|
||||||
|
|
||||||
import win32.windows;
|
import win32.windows;
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
|
|
Loading…
Reference in New Issue