A few changes concerning wxGTK.
For one, I added a new member gs_window for future use. The member is "display" which represents our connection to X11. Ideally, we should use this specific connection to deal with our Window. For now, it's disabled. Read comment for more information. Secondly, wxGTK apparently doesn't map our window in some cases. This causes the window ID passed to be bad and will stop (or segfault) our program. This might be related to the first commit above. For now, all this commit does is realize the window manually.master
parent
350c34881a
commit
d283f24cbb
|
@ -26,8 +26,6 @@ static const GLenum ctx_attribs[] = {
|
||||||
None,
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ERROR_TEXT_LEN 1024
|
|
||||||
|
|
||||||
struct gl_windowinfo {
|
struct gl_windowinfo {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
Display *display;
|
Display *display;
|
||||||
|
@ -38,16 +36,6 @@ struct gl_platform {
|
||||||
struct gs_swap_chain swap;
|
struct gs_swap_chain swap;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int GLXErrorHandler(Display *disp, XErrorEvent *error)
|
|
||||||
{
|
|
||||||
char error_buf[ERROR_TEXT_LEN];
|
|
||||||
|
|
||||||
XGetErrorText(disp, error->error_code, error_buf, ERROR_TEXT_LEN);
|
|
||||||
blog(LOG_ERROR, "GLX error: %s\n", error_buf);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern struct gs_swap_chain *gl_platform_getswap(struct gl_platform *platform)
|
extern struct gs_swap_chain *gl_platform_getswap(struct gl_platform *platform)
|
||||||
{
|
{
|
||||||
return &platform->swap;
|
return &platform->swap;
|
||||||
|
@ -59,6 +47,7 @@ extern struct gl_windowinfo *gl_windowinfo_create(struct gs_init_data *info)
|
||||||
memset(wi, 0, sizeof(struct gl_windowinfo));
|
memset(wi, 0, sizeof(struct gl_windowinfo));
|
||||||
|
|
||||||
wi->id = info->window.id;
|
wi->id = info->window.id;
|
||||||
|
/* wi->display = info->window.display; */
|
||||||
|
|
||||||
return wi;
|
return wi;
|
||||||
}
|
}
|
||||||
|
@ -118,8 +107,6 @@ struct gl_platform *gl_platform_create(device_t device,
|
||||||
goto fail0;
|
goto fail0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetErrorHandler(GLXErrorHandler);
|
|
||||||
|
|
||||||
/* We require glX version 1.4 */
|
/* We require glX version 1.4 */
|
||||||
{
|
{
|
||||||
int major = 0, minor = 0;
|
int major = 0, minor = 0;
|
||||||
|
|
|
@ -415,7 +415,9 @@ struct gs_window {
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
__unsafe_unretained id view;
|
__unsafe_unretained id view;
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
|
/* I'm not sure how portable defining id to uint32_t is. */
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
void* display;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,15 @@ gs_window WxToGSWindow(wxWindow *wxwin)
|
||||||
window.hwnd = wxwin->GetHandle();
|
window.hwnd = wxwin->GetHandle();
|
||||||
#else
|
#else
|
||||||
GtkWidget* hndl = wxwin->GetHandle();
|
GtkWidget* hndl = wxwin->GetHandle();
|
||||||
gtk_widget_realize(hndl);
|
|
||||||
GdkWindow* gdkwin = gtk_widget_get_window(hndl);
|
|
||||||
|
|
||||||
if (gdkwin)
|
/* I don't really understand why wxWidgets doesn't do this during Show() */
|
||||||
window.id = GDK_DRAWABLE_XID(gdkwin);
|
gtk_widget_realize(hndl);
|
||||||
else {
|
|
||||||
window.id = 0;
|
GdkWindow* gdkwin = gtk_widget_get_window(hndl);
|
||||||
blog(LOG_ERROR, "Window is not realized...?");
|
window.id = GDK_DRAWABLE_XID(gdkwin);
|
||||||
}
|
window.display = GDK_DRAWABLE_XDISPLAY(gdkwin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue