Context * createContext(const Visual *visual, Context *shareContext, bool debug) { struct waffle_context *context; const WaffleVisual *waffleVisual = static_cast<const WaffleVisual *>(visual); struct waffle_context * share_context = NULL; if (shareContext) { share_context = static_cast<WaffleContext*>(shareContext)->context; } context = waffle_context_create(waffleVisual->config, share_context); if (!context) { std::cerr << "error: waffle_context_create failed\n"; exit(1); return NULL; } return new WaffleContext(visual, context); }
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); }
Context * createContext(const Visual *visual, Context *shareContext, bool debug) { struct waffle_context *context; const WaffleVisual *waffleVisual = static_cast<const WaffleVisual *>(visual); struct waffle_context * share_context = NULL; if (shareContext) { share_context = static_cast<WaffleContext*>(shareContext)->context; } context = waffle_context_create(waffleVisual->config, share_context); if (!context) { os::log("Error in %s waffle_context_create()\n", __FILE__); os::abort(); return NULL; } return new WaffleContext(visual, context); }
static bool make_context_current_singlepass(struct piglit_wfl_framework *wfl_fw, const struct piglit_gl_test_config *test_config, enum context_flavor flavor, const int32_t partial_config_attrib_list[]) { bool ok; int32_t *attrib_list = NULL; char ctx_desc[1024]; assert(wfl_fw->config == NULL); assert(wfl_fw->context == NULL); assert(wfl_fw->window == NULL); parse_test_config(test_config, flavor, ctx_desc, sizeof(ctx_desc), partial_config_attrib_list, &attrib_list); assert(attrib_list); wfl_fw->config = waffle_config_choose(wfl_fw->display, attrib_list); free(attrib_list); if (!wfl_fw->config) { wfl_log_error("waffle_config_choose"); fprintf(stderr, "piglit: error: Failed to create " "waffle_config for %s\n", ctx_desc); goto fail; } wfl_fw->context = waffle_context_create(wfl_fw->config, NULL); if (!wfl_fw->context) { wfl_log_error("waffle_context_create"); fprintf(stderr, "piglit: error: Failed to create " "waffle_context for %s\n", ctx_desc); goto fail; } wfl_fw->window = wfl_checked_window_create(wfl_fw->config, test_config->window_width, test_config->window_height); wfl_checked_make_current(wfl_fw->display, wfl_fw->window, wfl_fw->context); #ifdef PIGLIT_USE_OPENGL piglit_dispatch_default_init(PIGLIT_DISPATCH_GL); #elif defined(PIGLIT_USE_OPENGL_ES1) piglit_dispatch_default_init(PIGLIT_DISPATCH_ES1); #elif defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3) piglit_dispatch_default_init(PIGLIT_DISPATCH_ES2); #else # error #endif ok = check_gl_version(test_config, flavor, ctx_desc); if (!ok) goto fail; ok = special_case_gl31(wfl_fw, test_config, flavor, ctx_desc, partial_config_attrib_list); if (!ok) goto fail; return true; fail: waffle_make_current(wfl_fw->display, NULL, NULL); waffle_window_destroy(wfl_fw->window); waffle_context_destroy(wfl_fw->context); waffle_config_destroy(wfl_fw->config); wfl_fw->window = NULL; wfl_fw->context = NULL; wfl_fw->config = NULL; piglit_gl_reinitialize_extensions(); return false; }