mirror of https://github.com/buggins/dlangui.git
configuration definitions rework
This commit is contained in:
parent
d11f9428cc
commit
55c4b077da
|
@ -1,35 +1,89 @@
|
||||||
module dlangui.core.config;
|
module dlangui.core.config;
|
||||||
|
|
||||||
version (Windows) {
|
version (USE_FREETYPE) {
|
||||||
// force Unicode definition under Windows
|
immutable bool USE_FREETYPE = true;
|
||||||
version = Unicode;
|
|
||||||
} else {
|
} else {
|
||||||
version = USE_FREETYPE;
|
version (Windows) {
|
||||||
|
immutable bool ENABLE_FREETYPE = false;
|
||||||
|
} else {
|
||||||
|
immutable bool ENABLE_FREETYPE = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// provide default configuratino definitions
|
// provide default configuratino definitions
|
||||||
version (USE_SDL) {
|
version (USE_SDL) {
|
||||||
// SDL backend already selected
|
// SDL backend already selected using version identifier
|
||||||
|
version (USE_OPENGL) {
|
||||||
|
immutable bool ENABLE_OPENGL = true;
|
||||||
|
} else {
|
||||||
|
immutable bool ENABLE_OPENGL = false;
|
||||||
|
}
|
||||||
|
immutable bool BACKEND_SDL = true;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = false;
|
||||||
} else version (USE_X11) {
|
} else version (USE_X11) {
|
||||||
// X11 backend already selected
|
// X11 backend already selected using version identifier
|
||||||
|
version (USE_OPENGL) {
|
||||||
|
immutable bool ENABLE_OPENGL = true;
|
||||||
|
} else {
|
||||||
|
immutable bool ENABLE_OPENGL = false;
|
||||||
|
}
|
||||||
|
immutable bool BACKEND_SDL = false;
|
||||||
|
immutable bool BACKEND_X11 = true;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = false;
|
||||||
|
} else version (USE_WIN32) {
|
||||||
|
// Win32 backend already selected using version identifier
|
||||||
|
version (USE_OPENGL) {
|
||||||
|
immutable bool ENABLE_OPENGL = true;
|
||||||
|
} else {
|
||||||
|
immutable bool ENABLE_OPENGL = false;
|
||||||
|
}
|
||||||
|
immutable bool BACKEND_SDL = false;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = true;
|
||||||
} else version (USE_DSFML) {
|
} else version (USE_DSFML) {
|
||||||
// DSFML backend already selected
|
// DSFML backend already selected using version identifier
|
||||||
|
version (USE_OPENGL) {
|
||||||
|
immutable bool ENABLE_OPENGL = true;
|
||||||
|
} else {
|
||||||
|
immutable bool ENABLE_OPENGL = false;
|
||||||
|
}
|
||||||
|
immutable bool BACKEND_SDL = false;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = true;
|
||||||
|
immutable bool BACKEND_WIN32 = false;
|
||||||
} else {
|
} else {
|
||||||
|
// no backend selected: set default based on platform
|
||||||
version (Windows) {
|
version (Windows) {
|
||||||
// For Windows
|
// For Windows
|
||||||
// by default: no freetype
|
immutable bool ENABLE_OPENGL = true;
|
||||||
version = USE_OPENGL;
|
immutable bool BACKEND_SDL = false;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = true;
|
||||||
} else version(linux) {
|
} else version(linux) {
|
||||||
// Default for Linux: use SDL and OpenGL
|
// Default for Linux: use SDL and OpenGL
|
||||||
version = USE_SDL;
|
immutable bool ENABLE_OPENGL = true;
|
||||||
version = USE_OPENGL;
|
immutable bool BACKEND_SDL = true;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = false;
|
||||||
} else version(OSX) {
|
} else version(OSX) {
|
||||||
// Default: use SDL and OpenGL
|
// Default: use SDL and OpenGL
|
||||||
version = USE_SDL;
|
immutable bool ENABLE_OPENGL = true;
|
||||||
version = USE_OPENGL;
|
immutable bool BACKEND_SDL = true;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = false;
|
||||||
} else {
|
} else {
|
||||||
// Unknown platform: use SDL and OpenGL
|
// Unknown platform: use SDL and OpenGL
|
||||||
version = USE_SDL;
|
immutable bool ENABLE_OPENGL = true;
|
||||||
version = USE_OPENGL;
|
immutable bool BACKEND_SDL = true;
|
||||||
|
immutable bool BACKEND_X11 = false;
|
||||||
|
immutable bool BACKEND_DSFML = false;
|
||||||
|
immutable bool BACKEND_WIN32 = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,7 @@ struct Glyph
|
||||||
SubpixelRenderingMode subpixelMode;
|
SubpixelRenderingMode subpixelMode;
|
||||||
/// 7: usage flag, to handle cleanup of unused glyphs
|
/// 7: usage flag, to handle cleanup of unused glyphs
|
||||||
ubyte lastUsage;
|
ubyte lastUsage;
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
/// 8: unique id of glyph (for drawing in hardware accelerated scenes)
|
/// 8: unique id of glyph (for drawing in hardware accelerated scenes)
|
||||||
uint id;
|
uint id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct NinePatch {
|
||||||
Rect padding;
|
Rect padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
/// non thread safe
|
/// non thread safe
|
||||||
private __gshared uint drawBufIdGenerator = 0;
|
private __gshared uint drawBufIdGenerator = 0;
|
||||||
}
|
}
|
||||||
|
@ -71,14 +71,14 @@ class DrawBuf : RefCountedObject {
|
||||||
return (argb & 0xFFFFFF) | (a << 24);
|
return (argb & 0xFFFFFF) | (a << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
protected uint _id;
|
protected uint _id;
|
||||||
/// unique ID of drawbug instance, for using with hardware accelerated rendering for caching
|
/// unique ID of drawbug instance, for using with hardware accelerated rendering for caching
|
||||||
@property uint id() { return _id; }
|
@property uint id() { return _id; }
|
||||||
}
|
}
|
||||||
|
|
||||||
this() {
|
this() {
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
_id = drawBufIdGenerator++;
|
_id = drawBufIdGenerator++;
|
||||||
}
|
}
|
||||||
debug _instanceCount++;
|
debug _instanceCount++;
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct CustomCharProps {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
|
|
||||||
private __gshared void function(uint id) _glyphDestroyCallback;
|
private __gshared void function(uint id) _glyphDestroyCallback;
|
||||||
/**
|
/**
|
||||||
|
@ -802,7 +802,7 @@ struct GlyphCache
|
||||||
if (part !is null)
|
if (part !is null)
|
||||||
foreach(ref item; part) {
|
foreach(ref item; part) {
|
||||||
if (item && !item.lastUsage) {
|
if (item && !item.lastUsage) {
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
// notify about destroyed glyphs
|
// notify about destroyed glyphs
|
||||||
if (_glyphDestroyCallback !is null) {
|
if (_glyphDestroyCallback !is null) {
|
||||||
_glyphDestroyCallback(item.id);
|
_glyphDestroyCallback(item.id);
|
||||||
|
@ -832,7 +832,7 @@ struct GlyphCache
|
||||||
if (part !is null)
|
if (part !is null)
|
||||||
foreach(ref item; part) {
|
foreach(ref item; part) {
|
||||||
if (item) {
|
if (item) {
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
// notify about destroyed glyphs
|
// notify about destroyed glyphs
|
||||||
if (_glyphDestroyCallback !is null) {
|
if (_glyphDestroyCallback !is null) {
|
||||||
_glyphDestroyCallback(item.id);
|
_glyphDestroyCallback(item.id);
|
||||||
|
|
|
@ -10,7 +10,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
module dlangui.graphics.ftfonts;
|
module dlangui.graphics.ftfonts;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
version(USE_FREETYPE):
|
static if (ENABLE_FREETYPE):
|
||||||
|
|
||||||
import dlangui.graphics.fonts;
|
import dlangui.graphics.fonts;
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ class FreeTypeFontFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
glyph.id = nextGlyphId();
|
glyph.id = nextGlyphId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
module dlangui.graphics.gldrawbuf;
|
module dlangui.graphics.gldrawbuf;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
version (USE_OPENGL):
|
static if (ENABLE_OPENGL):
|
||||||
|
|
||||||
import dlangui.graphics.drawbuf;
|
import dlangui.graphics.drawbuf;
|
||||||
import dlangui.graphics.colors;
|
import dlangui.graphics.colors;
|
||||||
|
|
|
@ -19,7 +19,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
module dlangui.graphics.glsupport;
|
module dlangui.graphics.glsupport;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
version(USE_OPENGL):
|
static if (ENABLE_OPENGL):
|
||||||
|
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
|
|
|
@ -90,6 +90,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
|
|
||||||
module dlangui.graphics.resources;
|
module dlangui.graphics.resources;
|
||||||
|
|
||||||
|
import dlangui.core.config;
|
||||||
import dlangui.graphics.images;
|
import dlangui.graphics.images;
|
||||||
import dlangui.graphics.drawbuf;
|
import dlangui.graphics.drawbuf;
|
||||||
import dlangui.graphics.colors;
|
import dlangui.graphics.colors;
|
||||||
|
|
|
@ -1353,7 +1353,7 @@ class Platform {
|
||||||
return Platform.instance;
|
return Platform.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
private __gshared bool _OPENGL_ENABLED = false;
|
private __gshared bool _OPENGL_ENABLED = false;
|
||||||
/// check if hardware acceleration is enabled
|
/// check if hardware acceleration is enabled
|
||||||
@property bool openglEnabled() { return _OPENGL_ENABLED; }
|
@property bool openglEnabled() { return _OPENGL_ENABLED; }
|
||||||
|
@ -1378,12 +1378,6 @@ version (Windows) {
|
||||||
|
|
||||||
/// put "mixin APP_ENTRY_POINT;" to main module of your dlangui based app
|
/// put "mixin APP_ENTRY_POINT;" to main module of your dlangui based app
|
||||||
mixin template APP_ENTRY_POINT() {
|
mixin template APP_ENTRY_POINT() {
|
||||||
version (linux) {
|
|
||||||
version(USE_X11) {
|
|
||||||
pragma(lib, "X11");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// workaround for link issue when WinMain is located in library
|
/// workaround for link issue when WinMain is located in library
|
||||||
version(Windows) {
|
version(Windows) {
|
||||||
extern (Windows) int WinMain(void* hInstance, void* hPrevInstance,
|
extern (Windows) int WinMain(void* hInstance, void* hPrevInstance,
|
||||||
|
|
|
@ -7,7 +7,7 @@ public import dlangui.graphics.fonts;
|
||||||
public import dlangui.graphics.resources;
|
public import dlangui.graphics.resources;
|
||||||
public import dlangui.widgets.widget;
|
public import dlangui.widgets.widget;
|
||||||
|
|
||||||
version(USE_FREETYPE) {
|
static if (ENABLE_FREETYPE) {
|
||||||
public import dlangui.graphics.ftfonts;
|
public import dlangui.graphics.ftfonts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ version (Windows) {
|
||||||
import dlangui.platforms.windows.win32fonts;
|
import dlangui.platforms.windows.win32fonts;
|
||||||
try {
|
try {
|
||||||
/// testing freetype font manager
|
/// testing freetype font manager
|
||||||
version(USE_FREETYPE) {
|
static if (ENABLE_FREETYPE) {
|
||||||
Log.v("Trying to init FreeType font manager");
|
Log.v("Trying to init FreeType font manager");
|
||||||
|
|
||||||
import dlangui.graphics.ftfonts;
|
import dlangui.graphics.ftfonts;
|
||||||
|
@ -236,7 +236,7 @@ extern (C) void releaseResourcesOnAppExit() {
|
||||||
if (Drawable.instanceCount > 0) {
|
if (Drawable.instanceCount > 0) {
|
||||||
Log.e("Non-zero Drawable instance count when exiting: ", Drawable.instanceCount);
|
Log.e("Non-zero Drawable instance count when exiting: ", Drawable.instanceCount);
|
||||||
}
|
}
|
||||||
version (USE_FREETYPE) {
|
static if (ENABLE_FREETYPE) {
|
||||||
import dlangui.graphics.ftfonts;
|
import dlangui.graphics.ftfonts;
|
||||||
if (FreeTypeFontFile.instanceCount > 0) {
|
if (FreeTypeFontFile.instanceCount > 0) {
|
||||||
Log.e("Non-zero FreeTypeFontFile instance count when exiting: ", FreeTypeFontFile.instanceCount);
|
Log.e("Non-zero FreeTypeFontFile instance count when exiting: ", FreeTypeFontFile.instanceCount);
|
||||||
|
|
|
@ -2,7 +2,7 @@ module dlangui.platforms.dsfml.dsfmlapp;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
|
|
||||||
version(USE_DSFML):
|
static if (BACKEND_DSFML):
|
||||||
|
|
||||||
import dlangui.platforms.common.platform;
|
import dlangui.platforms.common.platform;
|
||||||
import dsfml.graphics;
|
import dsfml.graphics;
|
||||||
|
|
|
@ -18,7 +18,8 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
module dlangui.platforms.sdl.sdlapp;
|
module dlangui.platforms.sdl.sdlapp;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
version(USE_SDL):
|
static if (BACKEND_SDL):
|
||||||
|
|
||||||
import core.runtime;
|
import core.runtime;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.string;
|
import std.string;
|
||||||
|
@ -41,7 +42,7 @@ import dlangui.platforms.common.platform;
|
||||||
import derelict.sdl2.sdl;
|
import derelict.sdl2.sdl;
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
import dlangui.graphics.gldrawbuf;
|
import dlangui.graphics.gldrawbuf;
|
||||||
import dlangui.graphics.glsupport;
|
import dlangui.graphics.glsupport;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +90,7 @@ class SDLWindow : Window {
|
||||||
debug Log.d("Destroying SDL window");
|
debug Log.d("Destroying SDL window");
|
||||||
if (_renderer)
|
if (_renderer)
|
||||||
SDL_DestroyRenderer(_renderer);
|
SDL_DestroyRenderer(_renderer);
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_context)
|
if (_context)
|
||||||
SDL_GL_DeleteContext(_context);
|
SDL_GL_DeleteContext(_context);
|
||||||
}
|
}
|
||||||
|
@ -111,12 +112,12 @@ class SDLWindow : Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
static private bool _gl3Reloaded = false;
|
static private bool _gl3Reloaded = false;
|
||||||
private SDL_GLContext _context;
|
private SDL_GLContext _context;
|
||||||
}
|
}
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
protected bool createContext(int versionMajor, int versionMinor) {
|
protected bool createContext(int versionMajor, int versionMinor) {
|
||||||
Log.i("Trying to create OpenGL ", versionMajor, ".", versionMinor, " context");
|
Log.i("Trying to create OpenGL ", versionMajor, ".", versionMinor, " context");
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, versionMajor);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, versionMajor);
|
||||||
|
@ -146,7 +147,7 @@ class SDLWindow : Window {
|
||||||
//if (flags & WindowFlag.Modal)
|
//if (flags & WindowFlag.Modal)
|
||||||
// windowFlags |= SDL_WINDOW_INPUT_GRABBED;
|
// windowFlags |= SDL_WINDOW_INPUT_GRABBED;
|
||||||
windowFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
windowFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_enableOpengl)
|
if (_enableOpengl)
|
||||||
windowFlags |= SDL_WINDOW_OPENGL;
|
windowFlags |= SDL_WINDOW_OPENGL;
|
||||||
if (!_glSupport)
|
if (!_glSupport)
|
||||||
|
@ -155,7 +156,7 @@ class SDLWindow : Window {
|
||||||
_win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
_win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
_dx, _dy,
|
_dx, _dy,
|
||||||
windowFlags);
|
windowFlags);
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (!_win) {
|
if (!_win) {
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
Log.e("SDL_CreateWindow failed - cannot create OpenGL window: ", fromStringz(SDL_GetError()));
|
Log.e("SDL_CreateWindow failed - cannot create OpenGL window: ", fromStringz(SDL_GetError()));
|
||||||
|
@ -173,7 +174,7 @@ class SDLWindow : Window {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
Log.i("Trying to create OpenGL 3.2 context");
|
Log.i("Trying to create OpenGL 3.2 context");
|
||||||
createContext(3, 2);
|
createContext(3, 2);
|
||||||
|
@ -416,7 +417,7 @@ class SDLWindow : Window {
|
||||||
fixSize();
|
fixSize();
|
||||||
|
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
SDL_GL_MakeCurrent(_win, _context);
|
SDL_GL_MakeCurrent(_win, _context);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glViewport(0, 0, _dx, _dy);
|
glViewport(0, 0, _dx, _dy);
|
||||||
|
@ -1301,7 +1302,7 @@ int sdlmain(string[] args) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
try {
|
try {
|
||||||
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
||||||
DerelictGL3.load();
|
DerelictGL3.load();
|
||||||
|
@ -1323,7 +1324,7 @@ int sdlmain(string[] args) {
|
||||||
|
|
||||||
int request = SDL_GetDesktopDisplayMode(0,&displayMode);
|
int request = SDL_GetDesktopDisplayMode(0,&displayMode);
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
// we want OpenGL 3.2
|
// we want OpenGL 3.2
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION,3);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,2);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION,2);
|
||||||
|
|
|
@ -287,7 +287,7 @@ class Win32Font : Font {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Glyph * g = new Glyph;
|
Glyph * g = new Glyph;
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
g.id = nextGlyphId();
|
g.id = nextGlyphId();
|
||||||
}
|
}
|
||||||
//g.blackBoxX = cast(ushort)metrics.gmBlackBoxX;
|
//g.blackBoxX = cast(ushort)metrics.gmBlackBoxX;
|
||||||
|
|
|
@ -22,9 +22,8 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
module dlangui.platforms.windows.winapp;
|
module dlangui.platforms.windows.winapp;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
version (USE_SDL) { }
|
|
||||||
else version (USE_DSFML) { }
|
static if (BACKEND_WIN32):
|
||||||
else version (Windows) {
|
|
||||||
|
|
||||||
import core.runtime;
|
import core.runtime;
|
||||||
import win32.windows;
|
import win32.windows;
|
||||||
|
@ -44,7 +43,7 @@ import dlangui.graphics.fonts;
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import dlangui.core.files;
|
import dlangui.core.files;
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
import dlangui.graphics.glsupport;
|
import dlangui.graphics.glsupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ immutable WIN_CLASS_NAME = "DLANGUI_APP";
|
||||||
__gshared HINSTANCE _hInstance;
|
__gshared HINSTANCE _hInstance;
|
||||||
__gshared int _cmdShow;
|
__gshared int _cmdShow;
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
bool setupPixelFormat(HDC hDC)
|
bool setupPixelFormat(HDC hDC)
|
||||||
{
|
{
|
||||||
PIXELFORMATDESCRIPTOR pfd = {
|
PIXELFORMATDESCRIPTOR pfd = {
|
||||||
|
@ -161,7 +160,7 @@ class Win32Window : Window {
|
||||||
Win32Platform _platform;
|
Win32Platform _platform;
|
||||||
|
|
||||||
HWND _hwnd;
|
HWND _hwnd;
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
HGLRC _hGLRC; // opengl context
|
HGLRC _hGLRC; // opengl context
|
||||||
HPALETTE _hPalette;
|
HPALETTE _hPalette;
|
||||||
//GLSupport _gl;
|
//GLSupport _gl;
|
||||||
|
@ -200,7 +199,7 @@ class Win32Window : Window {
|
||||||
null, // window menu handle
|
null, // window menu handle
|
||||||
_hInstance, // program instance handle
|
_hInstance, // program instance handle
|
||||||
cast(void*)this); // creation parameters
|
cast(void*)this); // creation parameters
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
import derelict.opengl3.wgl;
|
import derelict.opengl3.wgl;
|
||||||
|
|
||||||
/* initialize OpenGL rendering */
|
/* initialize OpenGL rendering */
|
||||||
|
@ -222,7 +221,7 @@ class Win32Window : Window {
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
DerelictGL3.reload();
|
DerelictGL3.reload();
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
//_gl = new GLSupport();
|
//_gl = new GLSupport();
|
||||||
if (!_glSupport) {
|
if (!_glSupport) {
|
||||||
Log.v("Creating OpenGL support");
|
Log.v("Creating OpenGL support");
|
||||||
|
@ -264,7 +263,7 @@ class Win32Window : Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
private void paintUsingOpenGL() {
|
private void paintUsingOpenGL() {
|
||||||
// hack to stop infinite WM_PAINT loop
|
// hack to stop infinite WM_PAINT loop
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
|
@ -315,7 +314,7 @@ class Win32Window : Window {
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
debug Log.d("Window destructor");
|
debug Log.d("Window destructor");
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
import derelict.opengl3.wgl;
|
import derelict.opengl3.wgl;
|
||||||
if (_hGLRC) {
|
if (_hGLRC) {
|
||||||
//glSupport.uninitShaders();
|
//glSupport.uninitShaders();
|
||||||
|
@ -547,7 +546,7 @@ class Win32Window : Window {
|
||||||
void onPaint() {
|
void onPaint() {
|
||||||
debug(DebugRedraw) Log.d("onPaint()");
|
debug(DebugRedraw) Log.d("onPaint()");
|
||||||
long paintStart = currentTimeMillis;
|
long paintStart = currentTimeMillis;
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (useOpengl && _hGLRC) {
|
if (useOpengl && _hGLRC) {
|
||||||
paintUsingOpenGL();
|
paintUsingOpenGL();
|
||||||
} else {
|
} else {
|
||||||
|
@ -997,7 +996,7 @@ int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdSho
|
||||||
|
|
||||||
currentTheme = createDefaultTheme();
|
currentTheme = createDefaultTheme();
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
try {
|
try {
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
DerelictGL3.load();
|
DerelictGL3.load();
|
||||||
|
@ -1196,6 +1195,4 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
//===========================================
|
//===========================================
|
||||||
// end of version(Windows)
|
// end of version(Windows)
|
||||||
//===========================================
|
//===========================================
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module dlangui.platforms.x11.x11app;
|
module dlangui.platforms.x11.x11app;
|
||||||
|
|
||||||
public import dlangui.core.config;
|
public import dlangui.core.config;
|
||||||
version (USE_X11):
|
static if (BACKEND_X11):
|
||||||
|
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import dlangui.core.events;
|
import dlangui.core.events;
|
||||||
|
@ -23,7 +23,7 @@ import x11.Xutil;
|
||||||
import x11.Xtos;
|
import x11.Xtos;
|
||||||
import x11.X;
|
import x11.X;
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
import derelict.opengl3.gl;
|
import derelict.opengl3.gl;
|
||||||
import dlangui.graphics.gldrawbuf;
|
import dlangui.graphics.gldrawbuf;
|
||||||
|
@ -178,7 +178,7 @@ class X11Window : DWindow {
|
||||||
protected GC _gc;
|
protected GC _gc;
|
||||||
private __gshared XIC xic;
|
private __gshared XIC xic;
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
GLXContext _glc;
|
GLXContext _glc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ class X11Window : DWindow {
|
||||||
EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ExposureMask | VisibilityChangeMask |
|
EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | ExposureMask | VisibilityChangeMask |
|
||||||
FocusChangeMask | KeymapStateMask | StructureNotifyMask;
|
FocusChangeMask | KeymapStateMask | StructureNotifyMask;
|
||||||
Visual * visual = DefaultVisual(x11display, x11screen);
|
Visual * visual = DefaultVisual(x11display, x11screen);
|
||||||
version (USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
swamask |= CWColormap;
|
swamask |= CWColormap;
|
||||||
swa.colormap = x11cmap;
|
swa.colormap = x11cmap;
|
||||||
|
@ -296,7 +296,7 @@ class X11Window : DWindow {
|
||||||
if (timer) {
|
if (timer) {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
}
|
}
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_glc) {
|
if (_glc) {
|
||||||
glXDestroyContext(x11display, _glc);
|
glXDestroyContext(x11display, _glc);
|
||||||
_glc = null;
|
_glc = null;
|
||||||
|
@ -312,26 +312,12 @@ class X11Window : DWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// version(USE_OPENGL) {
|
|
||||||
// protected bool createContext(int versionMajor, int versionMinor) {
|
|
||||||
// Log.i("Trying to create OpenGL ", versionMajor, ".", versionMinor, " context");
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, versionMajor);
|
|
||||||
// SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, versionMinor);
|
|
||||||
// _glc = SDL_GL_CreateContext(_win); // Create the actual context and make it current
|
|
||||||
// if (!_context)
|
|
||||||
// Log.e("SDL_GL_CreateContext failed: ", fromStringz(SDL_GetError()));
|
|
||||||
// else
|
|
||||||
// Log.i("Created successfully");
|
|
||||||
// return _context !is null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// show window
|
/// show window
|
||||||
override void show() {
|
override void show() {
|
||||||
Log.d("X11Window.show");
|
Log.d("X11Window.show");
|
||||||
XMapRaised(x11display, _win);
|
XMapRaised(x11display, _win);
|
||||||
XFlush(x11display);
|
XFlush(x11display);
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
_glc = glXCreateContext(x11display, x11visual, null, GL_TRUE);
|
_glc = glXCreateContext(x11display, x11visual, null, GL_TRUE);
|
||||||
if (!_glc) {
|
if (!_glc) {
|
||||||
|
@ -448,7 +434,7 @@ class X11Window : DWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawUsingOpengl() {
|
protected void drawUsingOpengl() {
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
//Log.d("drawUsingOpengl()");
|
//Log.d("drawUsingOpengl()");
|
||||||
glXMakeCurrent(x11display, cast(uint)_win, _glc);
|
glXMakeCurrent(x11display, cast(uint)_win, _glc);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
@ -1385,7 +1371,7 @@ extern(C) int DLANGUImain(string[] args)
|
||||||
|
|
||||||
x11screen = DefaultScreen(x11display);
|
x11screen = DefaultScreen(x11display);
|
||||||
|
|
||||||
version(USE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
try {
|
try {
|
||||||
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
DerelictGL3.missingSymbolCallback = &gl3MissingSymFunc;
|
||||||
DerelictGL3.load();
|
DerelictGL3.load();
|
||||||
|
|
Loading…
Reference in New Issue