fix linux+dub build

This commit is contained in:
Vadim Lopatin 2014-04-24 23:19:27 +04:00
parent e9ecc3b26c
commit cbc647a60b
5 changed files with 1522 additions and 1458 deletions

View File

@ -159,6 +159,7 @@ xcb_image_create_native (xcb_connection_t * c,
if (depth != 1)
return null;
/* fall through */
goto case;
case XCB_IMAGE_FORMAT_XY_PIXMAP:
if (depth > 1) {
fmt = find_format_by_depth(setup, depth);

View File

@ -21,6 +21,35 @@
"targetPath": "lib",
"targetType": "staticLibrary",
"sourceFiles-posix": [
"3rdparty/X11/xcb/bigreq.d",
"3rdparty/X11/xcb/composite.d",
"3rdparty/X11/xcb/damage.d",
"3rdparty/X11/xcb/dpms.d",
"3rdparty/X11/xcb/glx.d",
"3rdparty/X11/xcb/randr.d",
"3rdparty/X11/xcb/record.d",
"3rdparty/X11/xcb/render.d",
"3rdparty/X11/xcb/res.d",
"3rdparty/X11/xcb/screensaver.d",
"3rdparty/X11/xcb/shape.d",
"3rdparty/X11/xcb/shm.d",
"3rdparty/X11/xcb/xcb.d",
"3rdparty/X11/xcb/xc_misc.d",
"3rdparty/X11/xcb/xevie.d",
"3rdparty/X11/xcb/xf86dri.d",
"3rdparty/X11/xcb/xfixes.d",
"3rdparty/X11/xcb/xinerama.d",
"3rdparty/X11/xcb/xprint.d",
"3rdparty/X11/xcb/xproto.d",
"3rdparty/X11/xcb/xtest.d",
"3rdparty/X11/xcb/xv.d",
"3rdparty/X11/xcb/xvmc.d",
"3rdparty/X11/xcb/image.d",
"3rdparty/X11/keysymdef.d",
"3rdparty/X11/X.d",
"3rdparty/X11/Xlib.d"
],
"sourceFiles-windows": [
"3rdparty/win32/basetsd.d",
"3rdparty/win32/basetyps.d",

View File

@ -11,6 +11,36 @@
"sourcePaths": ["../../src"],
"sourceFiles-posix": [
"../../3rdparty/X11/xcb/bigreq.d",
"../../3rdparty/X11/xcb/composite.d",
"../../3rdparty/X11/xcb/damage.d",
"../../3rdparty/X11/xcb/dpms.d",
"../../3rdparty/X11/xcb/glx.d",
"../../3rdparty/X11/xcb/randr.d",
"../../3rdparty/X11/xcb/record.d",
"../../3rdparty/X11/xcb/render.d",
"../../3rdparty/X11/xcb/res.d",
"../../3rdparty/X11/xcb/screensaver.d",
"../../3rdparty/X11/xcb/shape.d",
"../../3rdparty/X11/xcb/shm.d",
"../../3rdparty/X11/xcb/xcb.d",
"../../3rdparty/X11/xcb/xc_misc.d",
"../../3rdparty/X11/xcb/xevie.d",
"../../3rdparty/X11/xcb/xf86dri.d",
"../../3rdparty/X11/xcb/xfixes.d",
"../../3rdparty/X11/xcb/xinerama.d",
"../../3rdparty/X11/xcb/xprint.d",
"../../3rdparty/X11/xcb/xproto.d",
"../../3rdparty/X11/xcb/xtest.d",
"../../3rdparty/X11/xcb/xv.d",
"../../3rdparty/X11/xcb/xvmc.d",
"../../3rdparty/X11/xcb/image.d",
"../../3rdparty/X11/keysymdef.d",
"../../3rdparty/X11/X.d",
"../../3rdparty/X11/Xlib.d"
],
"sourceFiles-windows": [
"../../3rdparty/win32/basetsd.d",
"../../3rdparty/win32/basetyps.d",
@ -81,6 +111,8 @@
"libs-windows": ["dlanguilib", "phobos", "ole32", "kernel32", "user32", "comctl32", "comdlg32"],
"libs-posix": ["xcb", "xcb-util", "xcb-shm", "xcb-image", "xcb-keysyms", "X11-xcb", "X11"],
"versions-windows": ["USE_OPENGL", "Unicode"],

View File

@ -70,14 +70,16 @@ version(linux) {
xcb_gcontext_t _g;
xcb_image_t * _image;
xcb_shm_segment_info_t shminfo;
/* Create GLX Window */
GLXDrawable _drawable;
GLXWindow _glxwindow;
private GLXContext _context;
version(USE_OPENGL) {
/* Create GLX Window */
private GLXDrawable _drawable;
private GLXWindow _glxwindow;
private GLXContext _context;
private GLXFBConfig _fb_config;
}
private int _visualID = 0;
private xcb_colormap_t _colormap;
private GLXFBConfig _fb_config;
@property xcb_window_t windowId() { return _w; }
this(string caption, Window parent) {
@ -112,46 +114,47 @@ version(linux) {
_w = xcb_generate_id(_xcbconnection);
Log.d("window=", _w, " gc=", _g);
if (_enableOpengl) {
int visual_attribs[] = [
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, 1,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
std.c.linux.X11.Xlib.None];
version (USE_OPENGL) {
if (_enableOpengl) {
int visual_attribs[] = [
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_DOUBLEBUFFER, 1,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
std.c.linux.X11.Xlib.None];
Log.d("Getting framebuffer config");
int fbcount;
GLXFBConfig *fbc = glXChooseFBConfig(_display, DefaultScreen(_display), visual_attribs.ptr, &fbcount);
if (!fbc)
{
Log.d("Failed to retrieve a framebuffer config");
//return 1;
}
Log.d("Getting XVisualInfo");
_fb_config = fbc[0];
auto vi = glXGetVisualFromFBConfig(_display, _fb_config);
Log.d("Getting framebuffer config");
int fbcount;
GLXFBConfig *fbc = glXChooseFBConfig(_display, DefaultScreen(_display), visual_attribs.ptr, &fbcount);
if (!fbc)
{
Log.d("Failed to retrieve a framebuffer config");
//return 1;
}
Log.d("Getting XVisualInfo");
_fb_config = fbc[0];
auto vi = glXGetVisualFromFBConfig(_display, _fb_config);
//auto vi = glXChooseVisual(_display, std.c.linux.X11.Xlib.DefaultScreen(_display), attributeList.ptr);
_visualID = vi.visualid;
//swa.colormap = std.c.linux.X11.Xlib.XCreateColormap(_display, std.c.linux.X11.Xlib.RootWindow(_display, vi.screen), vi.visual, 0); // AllocNone
//auto vi = glXChooseVisual(_display, std.c.linux.X11.Xlib.DefaultScreen(_display), attributeList.ptr);
_visualID = vi.visualid;
//swa.colormap = std.c.linux.X11.Xlib.XCreateColormap(_display, std.c.linux.X11.Xlib.RootWindow(_display, vi.screen), vi.visual, 0); // AllocNone
Log.d("Creating color map");
_colormap = xcb_generate_id(_xcbconnection);
/* Create colormap */
xcb_create_colormap(
_xcbconnection,
XCB_COLORMAP_ALLOC_NONE,
_colormap,
_xcbscreen.root,
_visualID
);
depth = cast(ubyte)vi.depth;
}
Log.d("Creating color map");
_colormap = xcb_generate_id(_xcbconnection);
/* Create colormap */
xcb_create_colormap(
_xcbconnection,
XCB_COLORMAP_ALLOC_NONE,
_colormap,
_xcbscreen.root,
_visualID
);
depth = cast(ubyte)vi.depth;
}
}
//mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
//values[0] = _xcbscreen.white_pixel;
@ -181,7 +184,7 @@ version(linux) {
//XCB_COPY_FROM_PARENT,//_xcbscreen.root_depth,
_w,
_xcbscreen.root,
50, 50, 500, 400,
30, 30, 800, 650,
1,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
visualId,
@ -288,112 +291,117 @@ version(linux) {
xcb_map_window(_xcbconnection, _w);
xcb_flush(_xcbconnection);
//_enableOpengl = false; // test
if (_enableOpengl && !_glxwindow) {
Log.d("Calling glXCreateWindow display=", _display, " fbconfig=", _fb_config, " window=", _w);
_glxwindow = glXCreateWindow(
_display,
_fb_config,
_w,
null);
if (!_glxwindow) {
Log.e("Failed to create GLX window: disabling OpenGL");
_enableOpengl = false;
} else {
import derelict.opengl3.glxext;
import std.c.linux.X11.Xlib;
version (USE_OPENGL) {
if (_enableOpengl && !_glxwindow) {
Log.d("Calling glXCreateWindow display=", _display, " fbconfig=", _fb_config, " window=", _w);
_glxwindow = glXCreateWindow(
_display,
_fb_config,
_w,
null);
if (!_glxwindow) {
Log.e("Failed to create GLX window: disabling OpenGL");
_enableOpengl = false;
} else {
import derelict.opengl3.glxext;
import std.c.linux.X11.Xlib;
_drawable = _glxwindow;
_drawable = _glxwindow;
if (!_derelictgl3Reloaded) {
if (!_derelictgl3Reloaded) {
int count;
glGetIntegerv( GL_NUM_EXTENSIONS, &count );
Log.d("Number of extensions: ", count);
for( int i=0; i<count; ++i ) {
auto e = glGetStringi( GL_EXTENSIONS, i );
Log.d("Extension: ", fromStringz(e));
}
int count;
glGetIntegerv( GL_NUM_EXTENSIONS, &count );
Log.d("Number of extensions: ", count);
for( int i=0; i<count; ++i ) {
auto e = glGetStringi( GL_EXTENSIONS, i );
Log.d("Extension: ", fromStringz(e));
}
Log.e("Reloading DerelictGL3");
_derelictgl3Reloaded = true;
_context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
if (_context is null) {
Log.e("Cannot create temporary context");
}
//glXMakeContextCurrent(_display, _drawable, _drawable, _context);
glXMakeContextCurrent(_display, _glxwindow, _glxwindow, _context);
//glXMakeCurrent(_display, _w, _context);
DerelictGL3.reload();
Log.e("Reloaded DerelictGL3 - removing temporary context");
glXMakeCurrent(_display, 0, null);
Log.e("Destroying context");
glXDestroyContext(_display, _context);
Log.e("DerelictGL3 initialized");
_context = null;
}
Log.e("Reloading DerelictGL3");
_derelictgl3Reloaded = true;
_context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
if (_context is null) {
Log.e("Cannot create temporary context");
}
//glXMakeContextCurrent(_display, _drawable, _drawable, _context);
glXMakeContextCurrent(_display, _glxwindow, _glxwindow, _context);
//glXMakeCurrent(_display, _w, _context);
DerelictGL3.reload();
Log.e("Reloaded DerelictGL3 - removing temporary context");
glXMakeCurrent(_display, 0, null);
Log.e("Destroying context");
glXDestroyContext(_display, _context);
Log.e("DerelictGL3 initialized");
_context = null;
}
// Get the default screen's GLX extension list
const char *glxExts = glXQueryExtensionsString( _display,
DefaultScreen( _display ) );
Log.d("GLX Extensions: ", fromStringz(glxExts));
const char * exts = glGetString( GL_EXTENSIONS );
Log.d("Extensions: ", fromStringz(exts));
// Get the default screen's GLX extension list
const char *glxExts = glXQueryExtensionsString( _display,
DefaultScreen( _display ) );
Log.d("GLX Extensions: ", fromStringz(glxExts));
const char * exts = glGetString( GL_EXTENSIONS );
Log.d("Extensions: ", fromStringz(exts));
Log.d("GLX_ARB_get_proc_address=", GLX_ARB_get_proc_address);
Log.d("GLX_ARB_create_context=", GLX_ARB_create_context);
Log.d("GLX_ARB_get_proc_address=", GLX_ARB_get_proc_address);
Log.d("GLX_ARB_create_context=", GLX_ARB_create_context);
//da_glXCreateContextAttribsARB glXCreateContextAttribsARB;
//Log.d("getting address of glXCreateContextAttribsARB");
//glXCreateContextAttribsARB = cast(da_glXCreateContextAttribsARB)
// glXGetProcAddressARB( cast(const GLubyte *)("glXCreateContextAttribsARB".toStringz));
//da_glXCreateContextAttribsARB glXCreateContextAttribsARB;
//Log.d("getting address of glXCreateContextAttribsARB");
//glXCreateContextAttribsARB = cast(da_glXCreateContextAttribsARB)
// glXGetProcAddressARB( cast(const GLubyte *)("glXCreateContextAttribsARB".toStringz));
//Log.d("glXCreateContextAttribsARB = ", &glXCreateContextAttribsARB);
//Log.d("glXCreateContextAttribsARB = ", &glXCreateContextAttribsARB);
Log.d("Creating context");
//_context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
if (!GLX_ARB_create_context) {
Log.e("glXCreateContextAttribsARB function is not found");
_context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
} else {
int context_attribs[] =
[
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
None
];
Log.e("calling glXCreateContextAttribsARB");
_context = glXCreateContextAttribsARB(_display, _fb_config, null, true, context_attribs.ptr);
}
Log.d("Created context: ", _context);
Log.d("Creating context");
//_context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
if (!GLX_ARB_create_context) {
Log.e("glXCreateContextAttribsARB function is not found");
_context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
} else {
int context_attribs[] =
[
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
None
];
Log.e("calling glXCreateContextAttribsARB");
_context = glXCreateContextAttribsARB(_display, _fb_config, null, true, context_attribs.ptr);
}
Log.d("Created context: ", _context);
/* Create OpenGL context */
//auto context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
if (!_context) {
_enableOpengl = false;
Log.e("Failed to create OpenGL context");
} else {
/* Create OpenGL context */
//auto context = glXCreateNewContext(_display, _fb_config, GLX_RGBA_TYPE, null, true);
if (!_context) {
_enableOpengl = false;
Log.e("Failed to create OpenGL context");
} else {
}
}
/* make OpenGL context current */
if(!glXMakeContextCurrent(_display, _drawable, _drawable, _context) || !initShaders()) {
Log.e("Failed to make GL context current");
_enableOpengl = false;
glXDestroyContext(_display, _context);
_context = null;
} else {
/* make OpenGL context current */
if(!glXMakeContextCurrent(_display, _drawable, _drawable, _context) || !initShaders()) {
Log.e("Failed to make GL context current");
_enableOpengl = false;
glXDestroyContext(_display, _context);
_context = null;
} else {
}
}
}
}
}
}
}
}
string _caption;
protected string _caption;
override @property string windowCaption() {
return _caption;
}
override @property void windowCaption(string caption) {
_caption = caption;
const char * title = _caption.toStringz;
@ -410,33 +418,35 @@ version(linux) {
void redraw() {
if (_enableOpengl) {
import std.c.linux.X11.Xlib;
Log.d("Drawing using opengl ", _dx, "x", _dy, " context=", _context);
//glXMakeContextCurrent(_display, _drawable, _drawable, _context);
glXMakeContextCurrent(_display, _glxwindow, _glxwindow, _context);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0, 0, _dx, _dy);
Log.d("glClearColor");
glClearColor(0.2f, 0.4f, 0.9f, 1.0f);
Log.d("glClear");
glClear(GL_COLOR_BUFFER_BIT);
version(USE_OPENGL) {
import std.c.linux.X11.Xlib;
Log.d("Drawing using opengl ", _dx, "x", _dy, " context=", _context);
//glXMakeContextCurrent(_display, _drawable, _drawable, _context);
glXMakeContextCurrent(_display, _glxwindow, _glxwindow, _context);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0, 0, _dx, _dy);
Log.d("glClearColor");
glClearColor(0.2f, 0.4f, 0.9f, 1.0f);
Log.d("glClear");
glClear(GL_COLOR_BUFFER_BIT);
import dlangui.graphics.gldrawbuf;
GLDrawBuf buf = new GLDrawBuf(_dx, _dy);
buf.beforeDrawing();
onDraw(buf);
buf.fillRect(Rect(0, 0, 100, 100), 0x805010);
buf.afterDrawing();
destroy(buf);
Log.d("Calling glx swap buffers for drawable ", _drawable);
glXSwapBuffers(_display, _drawable);
//glXMakeContextCurrent(_display, _drawable, _drawable, null);
xcb_flush(_xcbconnection);
glXMakeContextCurrent (_display, None, None, null);
glXWaitGL();
import dlangui.graphics.gldrawbuf;
GLDrawBuf buf = new GLDrawBuf(_dx, _dy);
buf.beforeDrawing();
onDraw(buf);
buf.fillRect(Rect(0, 0, 100, 100), 0x805010);
buf.afterDrawing();
destroy(buf);
Log.d("Calling glx swap buffers for drawable ", _drawable);
glXSwapBuffers(_display, _drawable);
//glXMakeContextCurrent(_display, _drawable, _drawable, null);
xcb_flush(_xcbconnection);
glXMakeContextCurrent (_display, None, None, null);
glXWaitGL();
}
} else {
if (!_drawbuf)
_drawbuf = new ColorDrawBuf(_dx, _dy);
@ -573,9 +583,6 @@ version(linux) {
case XK_Linefeed:
case XK_Return:
return KeyCode.RETURN;
return KeyCode.SHIFT;
return KeyCode.CONTROL;
return KeyCode.ALT;
case XK_Shift_L:
return KeyCode.LSHIFT;
case XK_Shift_R:

File diff suppressed because it is too large Load Diff