Drawable * createDrawable(const Visual *visual, int width, int height, bool pbuffer) { struct waffle_window *window; const WaffleVisual *waffleVisual = static_cast<const WaffleVisual *>(visual); window = waffle_window_create(waffleVisual->config, width, height); return new WaffleDrawable(visual, width, height, pbuffer, window); }
void make_context() { /* Generate a context */ struct waffle_display *dpy; struct waffle_config *config; struct waffle_window *window; struct waffle_context *ctx; const int32_t init_attrs[] = { WAFFLE_PLATFORM, WAFFLE_PLATFORM_X11_EGL, 0, }; const int32_t config_attrs[] = { WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL_ES2, WAFFLE_RED_SIZE, 8, WAFFLE_BLUE_SIZE, 8, WAFFLE_GREEN_SIZE, 8, 0, }; const int32_t window_width = 320; const int32_t window_height = 240; waffle_init(init_attrs); dpy = waffle_display_connect(NULL); // Exit if OpenGL ES2 is unsupported. if (!waffle_display_supports_context_api(dpy, WAFFLE_CONTEXT_OPENGL_ES2) || !waffle_dl_can_open(WAFFLE_DL_OPENGL_ES2)) { exit(EXIT_FAILURE); } config = waffle_config_choose(dpy, config_attrs); window = waffle_window_create(config, window_width, window_height); ctx = waffle_context_create(config, NULL); waffle_make_current(dpy, window, ctx); }