void test_fence (void) { GSource *cogl_source; int fb_width = cogl_framebuffer_get_width (test_fb); int fb_height = cogl_framebuffer_get_height (test_fb); CoglFenceClosure *closure; cogl_source = cogl_glib_source_new (test_ctx, G_PRIORITY_DEFAULT); g_source_attach (cogl_source, NULL); loop = g_main_loop_new (NULL, TRUE); cogl_framebuffer_orthographic (test_fb, 0, 0, fb_width, fb_height, -1, 100); cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0.0f, 1.0f, 0.0f, 0.0f); closure = cogl_framebuffer_add_fence_callback (test_fb, callback, MAGIC_CHUNK_O_DATA); g_assert (closure != NULL); g_timeout_add_seconds (5, timeout, NULL); g_main_loop_run (loop); if (cogl_test_verbose ()) g_print ("OK\n"); }
static void create_gles2_context (CoglTexture **offscreen_texture, CoglOffscreen **offscreen, CoglPipeline **pipeline, CoglGLES2Context **gles2_ctx, const CoglGLES2Vtable **gles2) { GError *error = NULL; *offscreen_texture = COGL_TEXTURE ( cogl_texture_2d_new_with_size (test_ctx, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), COGL_PIXEL_FORMAT_ANY, NULL)); *offscreen = cogl_offscreen_new_to_texture (*offscreen_texture); *pipeline = cogl_pipeline_new (test_ctx); cogl_pipeline_set_layer_texture (*pipeline, 0, *offscreen_texture); *gles2_ctx = cogl_gles2_context_new (test_ctx, NULL); if (!*gles2_ctx) g_error ("Failed to create GLES2 context: %s\n", error->message); *gles2 = cogl_gles2_context_get_vtable (*gles2_ctx); }
void test_cogl_backface_culling (TestUtilsGTestFixture *fixture, void *data) { TestUtilsSharedState *shared_state = data; TestState state; CoglHandle tex; state.fb = shared_state->fb; state.width = cogl_framebuffer_get_width (shared_state->fb); state.height = cogl_framebuffer_get_height (shared_state->fb); state.offscreen = COGL_INVALID_HANDLE; state.texture = make_texture (); tex = cogl_texture_new_with_size (state.width, state.height, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY); /* internal fmt */ state.offscreen = cogl_offscreen_new_to_texture (tex); state.offscreen_tex = tex; paint (&state); cogl_object_unref (state.offscreen); cogl_handle_unref (state.offscreen_tex); cogl_handle_unref (state.texture); if (g_test_verbose ()) g_print ("OK\n"); }
void test_path_clip (void) { CoglPath *path; CoglPipeline *pipeline; int fb_width, fb_height; fb_width = cogl_framebuffer_get_width (test_fb); fb_height = cogl_framebuffer_get_height (test_fb); cogl_framebuffer_orthographic (test_fb, 0, 0, fb_width, fb_height, -1, 100); path = cogl_path_new (); cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 1.0f, 0.0f, 0.0f, 1.0f); /* Make an L-shape with the top right corner left untouched */ cogl_path_move_to (path, 0, fb_height); cogl_path_line_to (path, fb_width, fb_height); cogl_path_line_to (path, fb_width, fb_height / 2); cogl_path_line_to (path, fb_width / 2, fb_height / 2); cogl_path_line_to (path, fb_width / 2, 0); cogl_path_line_to (path, 0, 0); cogl_path_close (path); cogl_framebuffer_push_path_clip (test_fb, path); /* Try to fill the framebuffer with a blue rectangle. This should be * clipped to leave the top right quadrant as is */ pipeline = cogl_pipeline_new (test_ctx); cogl_pipeline_set_color4ub (pipeline, 0, 0, 255, 255); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, fb_width, fb_height); cogl_framebuffer_pop_clip (test_fb); cogl_object_unref (pipeline); cogl_object_unref (path); /* Check each of the four quadrants */ test_utils_check_pixel (test_fb, fb_width / 4, fb_height / 4, 0x0000ffff); test_utils_check_pixel (test_fb, fb_width * 3 / 4, fb_height / 4, 0xff0000ff); test_utils_check_pixel (test_fb, fb_width / 4, fb_height * 3 / 4, 0x0000ffff); test_utils_check_pixel (test_fb, fb_width * 3 / 4, fb_height * 3 / 4, 0x0000ffff); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_just_vertex_shader (void) { TestState state; cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); /* XXX: we have to push/pop a framebuffer since this test currently * uses the legacy cogl_rectangle() api. */ cogl_push_framebuffer (test_fb); paint_legacy (&state); validate_result (test_fb); paint (&state); validate_result (test_fb); cogl_pop_framebuffer (); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_custom_attributes (void) { CoglSnippet *snippet; TestState state; cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); state.pipeline = cogl_pipeline_new (test_ctx); snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX, "attribute vec4 color;", "cogl_color_out = color;"); cogl_pipeline_add_snippet (state.pipeline, snippet); paint (&state); cogl_object_unref (state.pipeline); cogl_object_unref (snippet); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_backface_culling (void) { TestState state; CoglTexture *tex; state.width = cogl_framebuffer_get_width (test_fb); state.height = cogl_framebuffer_get_height (test_fb); state.offscreen = NULL; state.texture = make_texture (); tex = cogl_texture_new_with_size (state.width, state.height, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY); /* internal fmt */ state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (tex)); state.offscreen_tex = tex; paint (&state); cogl_object_unref (state.offscreen); cogl_object_unref (state.offscreen_tex); cogl_object_unref (state.texture); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_custom_attributes (void) { /* If shaders aren't supported then we can't run the test */ if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLSL)) { CoglSnippet *snippet; TestState state; cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); state.pipeline = cogl_pipeline_new (test_ctx); snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX, "attribute vec4 color;", "cogl_color_out = color;"); cogl_pipeline_add_snippet (state.pipeline, snippet); paint (&state); cogl_object_unref (state.pipeline); cogl_object_unref (snippet); if (cogl_test_verbose ()) g_print ("OK\n"); } else if (cogl_test_verbose ()) g_print ("Skipping\n"); }
void cogl_wayland_onscreen_resize (CoglOnscreen *onscreen, int width, int height, int offset_x, int offset_y) { CoglFramebuffer *fb; fb = COGL_FRAMEBUFFER (onscreen); if (fb->allocated) { CoglOnscreenEGL *egl_onscreen = onscreen->winsys; CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform; if (cogl_framebuffer_get_width (fb) != width || cogl_framebuffer_get_height (fb) != height || offset_x || offset_y) { wayland_onscreen->pending_width = width; wayland_onscreen->pending_height = height; wayland_onscreen->pending_dx += offset_x; wayland_onscreen->pending_dy += offset_y; wayland_onscreen->has_pending = TRUE; } } else _cogl_framebuffer_winsys_update_size (fb, width, height); }
void test_pipeline_uniforms (void) { TestState state; init_state (&state); cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); paint (&state); validate_result (); /* Try the test again after querying the location of a large number of uniforms. This should verify that the bitmasks still work even if they have to allocate a separate array to store the bits */ init_long_pipeline_state (&state); paint (&state); paint_long_pipeline (&state); validate_result (); validate_long_pipeline_result (); destroy_state (&state); if (cogl_test_verbose ()) g_print ("OK\n"); }
static void handle_event (Data *data, SDL_Event *event) { switch (event->type) { case SDL_VIDEOEXPOSE: data->redraw_queued = TRUE; break; case SDL_MOUSEMOTION: { int width = cogl_framebuffer_get_width (COGL_FRAMEBUFFER (data->fb)); int height = cogl_framebuffer_get_height (COGL_FRAMEBUFFER (data->fb)); data->center_x = event->motion.x * 2.0f / width - 1.0f; data->center_y = event->motion.y * 2.0f / height - 1.0f; data->redraw_queued = TRUE; } break; case SDL_QUIT: data->quit = TRUE; break; } }
void test_color_mask (void) { TestState state; int i; state.width = cogl_framebuffer_get_width (test_fb); state.height = cogl_framebuffer_get_height (test_fb); for (i = 0; i < NUM_FBOS; i++) { state.tex[i] = test_utils_texture_new_with_size (test_ctx, 128, 128, TEST_UTILS_TEXTURE_NO_ATLAS, COGL_PIXEL_FORMAT_RGB_888); state.fbo[i] = COGL_FRAMEBUFFER ( cogl_offscreen_new_to_texture (state.tex[i])); /* Clear the texture color bits */ cogl_framebuffer_clear4f (state.fbo[i], COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1); cogl_framebuffer_set_color_mask (state.fbo[i], i == 0 ? COGL_COLOR_MASK_RED : i == 1 ? COGL_COLOR_MASK_GREEN : COGL_COLOR_MASK_BLUE); } paint (&state); if (cogl_test_verbose ()) g_print ("OK\n"); }
RutCamera * rut_camera_new (RutContext *ctx, CoglFramebuffer *framebuffer) { RutCamera *camera = g_slice_new0 (RutCamera); camera->ctx = rut_refable_ref (ctx); rut_object_init (&camera->_parent, &rut_camera_type); camera->ref_count = 1; camera->component.type = RUT_COMPONENT_TYPE_CAMERA; rut_camera_set_background_color4f (camera, 0, 0, 0, 1); camera->clear_fb = TRUE; //rut_graphable_init (RUT_OBJECT (camera)); camera->orthographic = TRUE; camera->x1 = 0; camera->y1 = 0; camera->x2 = 100; camera->y2 = 100; camera->near = -1; camera->far = 100; camera->zoom = 1; camera->focal_distance = 30; camera->depth_of_field = 3; camera->projection_cache_age = -1; camera->inverse_projection_age = -1; cogl_matrix_init_identity (&camera->view); camera->inverse_view_age = -1; camera->transform_age = 0; cogl_matrix_init_identity (&camera->input_transform); if (framebuffer) { int width = cogl_framebuffer_get_width (framebuffer); int height = cogl_framebuffer_get_height (framebuffer); camera->fb = cogl_object_ref (framebuffer); camera->viewport[2] = width; camera->viewport[3] = height; camera->x2 = width; camera->y2 = height; } rut_simple_introspectable_init (camera, _rut_camera_prop_specs, camera->properties); return camera; }
static CoglBool _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen, EGLConfig egl_config, CoglError **error) { CoglOnscreenEGL *egl_onscreen = onscreen->winsys; CoglOnscreenWayland *wayland_onscreen; CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglContext *context = framebuffer->context; CoglRenderer *renderer = context->display->renderer; CoglRendererEGL *egl_renderer = renderer->winsys; CoglRendererWayland *wayland_renderer = egl_renderer->platform; wayland_onscreen = g_slice_new0 (CoglOnscreenWayland); egl_onscreen->platform = wayland_onscreen; _cogl_list_init (&wayland_onscreen->frame_callbacks); if (onscreen->foreign_surface) wayland_onscreen->wayland_surface = onscreen->foreign_surface; else wayland_onscreen->wayland_surface = wl_compositor_create_surface (wayland_renderer->wayland_compositor); if (!wayland_onscreen->wayland_surface) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_ONSCREEN, "Error while creating wayland surface for CoglOnscreen"); return FALSE; } wayland_onscreen->wayland_egl_native_window = wl_egl_window_create (wayland_onscreen->wayland_surface, cogl_framebuffer_get_width (framebuffer), cogl_framebuffer_get_height (framebuffer)); if (!wayland_onscreen->wayland_egl_native_window) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_ONSCREEN, "Error while creating wayland egl native window " "for CoglOnscreen"); return FALSE; } egl_onscreen->egl_surface = eglCreateWindowSurface (egl_renderer->edpy, egl_config, (EGLNativeWindowType) wayland_onscreen->wayland_egl_native_window, NULL); if (!onscreen->foreign_surface) wayland_onscreen->wayland_shell_surface = wl_shell_get_shell_surface (wayland_renderer->wayland_shell, wayland_onscreen->wayland_surface); return TRUE; }
void test_wrap_rectangle_textures (void) { float fb_width = cogl_framebuffer_get_width (test_fb); float fb_height = cogl_framebuffer_get_height (test_fb); CoglPipeline *base_pipeline; CoglPipeline *clamp_pipeline; CoglPipeline *repeat_pipeline; /* The textures are drawn with the texture coordinates from * -0.5→1.5. That means we get one complete copy of the texture and * an extra half of the texture surrounding it. The drawing is * tested against a 4x4 grid of colors. The center 2x2 colours * specify the normal texture colors and the other colours specify * what the wrap mode should generate */ static const uint8_t clamp_colors[] = { 0x44, 0x44, 0x88, 0x88, 0x44, 0x44, 0x88, 0x88, 0xcc, 0xcc, 0xff, 0xff, 0xcc, 0xcc, 0xff, 0xff }; static const uint8_t repeat_colors[] = { 0xff, 0xcc, 0xff, 0xcc, 0x88, 0x44, 0x88, 0x44, 0xff, 0xcc, 0xff, 0xcc, 0x88, 0x44, 0x88, 0x44 }; cogl_framebuffer_orthographic (test_fb, 0, 0, /* x_1, y_1 */ fb_width, /* x_2 */ fb_height /* y_2 */, -1, 100 /* near/far */); base_pipeline = create_base_pipeline (); clamp_pipeline = cogl_pipeline_copy (base_pipeline); cogl_pipeline_set_layer_wrap_mode (clamp_pipeline, 0, /* layer */ COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE); repeat_pipeline = cogl_pipeline_copy (base_pipeline); cogl_pipeline_set_layer_wrap_mode (repeat_pipeline, 0, /* layer */ COGL_PIPELINE_WRAP_MODE_REPEAT); test_pipeline (clamp_pipeline, 0, 0, /* x/y offset */ clamp_colors); test_pipeline (repeat_pipeline, 0, DRAW_SIZE * 2, /* x/y offset */ repeat_colors); cogl_object_unref (repeat_pipeline); cogl_object_unref (clamp_pipeline); cogl_object_unref (base_pipeline); }
void test_point_size (void) { int fb_width = cogl_framebuffer_get_width (test_fb); int fb_height = cogl_framebuffer_get_height (test_fb); int point_size; int x_pos; cogl_framebuffer_orthographic (test_fb, 0, 0, /* x_1, y_1 */ fb_width, /* x_2 */ fb_height /* y_2 */, -1, 100 /* near/far */); cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 1.0f, 0.0f, 0.0f, 1.0f); /* Try a rendering a single point with a few different point sizes */ for (x_pos = 0, point_size = MAX_POINT_SIZE; point_size >= 4; x_pos += POINT_BOX_SIZE, point_size /= 2) { CoglPipeline *pipeline = cogl_pipeline_new (test_ctx); CoglVertexP2 point = { x_pos + POINT_BOX_SIZE / 2, POINT_BOX_SIZE / 2 }; CoglPrimitive *prim = cogl_primitive_new_p2 (test_ctx, COGL_VERTICES_MODE_POINTS, 1, /* n_vertices */ &point); cogl_pipeline_set_point_size (pipeline, point_size); cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255); cogl_framebuffer_draw_primitive (test_fb, pipeline, prim); cogl_object_unref (prim); cogl_object_unref (pipeline); } /* Verify all of the points where drawn at the right size */ for (x_pos = 0, point_size = MAX_POINT_SIZE; point_size >= 4; x_pos += POINT_BOX_SIZE, point_size /= 2) verify_point_size (test_fb, x_pos + POINT_BOX_SIZE / 2, POINT_BOX_SIZE / 2, point_size); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_blend (void) { cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); paint (); }
void callback (CoglFence *fence, void *user_data) { int fb_width = cogl_framebuffer_get_width (test_fb); int fb_height = cogl_framebuffer_get_height (test_fb); test_utils_check_pixel (test_fb, fb_width - 1, fb_height - 1, 0x00ff0000); g_assert (user_data == MAGIC_CHUNK_O_DATA && "callback data not mangled"); g_main_loop_quit (loop); }
void test_alpha_test (void) { CoglTexture *tex = COGL_TEXTURE (create_texture (test_ctx)); CoglPipeline *pipeline = cogl_pipeline_new (test_ctx); int fb_width = cogl_framebuffer_get_width (test_fb); int fb_height = cogl_framebuffer_get_height (test_fb); CoglColor clear_color; cogl_pipeline_set_layer_texture (pipeline, 0, tex); cogl_pipeline_set_layer_filters (pipeline, 0, COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST); cogl_pipeline_set_alpha_test_function (pipeline, COGL_PIPELINE_ALPHA_FUNC_GEQUAL, 254 / 255.0f /* alpha reference */); cogl_color_init_from_4ub (&clear_color, 0x00, 0x00, 0xff, 0xff); cogl_framebuffer_clear (test_fb, COGL_BUFFER_BIT_COLOR, &clear_color); cogl_framebuffer_draw_rectangle (test_fb, pipeline, -1, -1, 1, 1); cogl_object_unref (pipeline); cogl_object_unref (tex); /* The left side of the framebuffer should use the first pixel from * the texture which is red */ test_utils_check_region (test_fb, 2, 2, fb_width / 2 - 4, fb_height - 4, 0xff0000ff); /* The right side of the framebuffer should use the clear color * because the second pixel from the texture is clipped from the * alpha test */ test_utils_check_region (test_fb, fb_width / 2 + 2, 2, fb_width / 2 - 4, fb_height - 4, 0x0000ffff); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_blend_strings (void) { TestState state; cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); paint (&state); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_cogl_depth_test (TestUtilsGTestFixture *fixture, void *data) { TestUtilsSharedState *shared_state = data; TestState state; cogl_ortho (0, cogl_framebuffer_get_width (shared_state->fb), /* left, right */ cogl_framebuffer_get_height (shared_state->fb), 0, /* bottom, top */ -1, 100 /* z near, far */); paint (&state); if (g_test_verbose ()) g_print ("OK\n"); }
static void paint (void) { CoglPipeline *pipeline = cogl_pipeline_new (test_ctx); int width = cogl_framebuffer_get_width (test_fb); int half_width = width / 2; int height = cogl_framebuffer_get_height (test_fb); CoglVertexP2 tri0_vertices[] = { { 0, 0 }, { 0, height }, { half_width, height }, }; CoglVertexP2C4 tri1_vertices[] = { { half_width, 0, 0x80, 0x80, 0x80, 0x80 }, { half_width, height, 0x80, 0x80, 0x80, 0x80 }, { width, height, 0x80, 0x80, 0x80, 0x80 }, }; CoglPrimitive *tri0; CoglPrimitive *tri1; cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0); tri0 = cogl_primitive_new_p2 (test_ctx, COGL_VERTICES_MODE_TRIANGLES, 3, tri0_vertices); tri1 = cogl_primitive_new_p2c4 (test_ctx, COGL_VERTICES_MODE_TRIANGLES, 3, tri1_vertices); /* Check that cogl correctly handles the case where we draw * different primitives same pipeline and switch from using the * opaque color associated with the pipeline and using a colour * attribute with an alpha component which implies blending is * required. * * If Cogl gets this wrong then then in all likelyhood the second * primitive will be drawn with blending still disabled. */ cogl_primitive_draw (tri0, test_fb, pipeline); cogl_primitive_draw (tri1, test_fb, pipeline); test_utils_check_pixel_and_alpha (test_fb, half_width + 5, height - 5, 0x80808080); }
void test_just_vertex_shader (void) { TestState state; cogl_framebuffer_orthographic (test_fb, 0, 0, cogl_framebuffer_get_width (test_fb), cogl_framebuffer_get_height (test_fb), -1, 100); paint (&state); validate_result (test_fb); if (cogl_test_verbose ()) g_print ("OK\n"); }
void test_texture_rg (void) { CoglPipeline *pipeline; CoglTexture2D *tex; int fb_width, fb_height; int x, y; fb_width = cogl_framebuffer_get_width (test_fb); fb_height = cogl_framebuffer_get_height (test_fb); tex = make_texture (); g_assert (cogl_texture_get_components (tex) == COGL_TEXTURE_COMPONENTS_RG); pipeline = cogl_pipeline_new (test_ctx); cogl_pipeline_set_layer_texture (pipeline, 0, tex); cogl_pipeline_set_layer_filters (pipeline, 0, COGL_PIPELINE_FILTER_NEAREST, COGL_PIPELINE_FILTER_NEAREST); cogl_framebuffer_draw_rectangle (test_fb, pipeline, -1.0f, 1.0f, 1.0f, -1.0f); for (y = 0; y < TEX_HEIGHT; y++) for (x = 0; x < TEX_WIDTH; x++) { test_utils_check_pixel_rgb (test_fb, x * fb_width / TEX_WIDTH + fb_width / (TEX_WIDTH * 2), y * fb_height / TEX_HEIGHT + fb_height / (TEX_HEIGHT * 2), x * 256 / TEX_WIDTH, y * 256 / TEX_HEIGHT, 0); } cogl_object_unref (pipeline); cogl_object_unref (tex); }
static CoglBool _cogl_winsys_onscreen_init (CoglOnscreen *onscreen, CoglError **error) { CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglOnscreenSdl2 *sdl_onscreen; SDL_Window *window; int width, height; SDL_WindowFlags flags; width = cogl_framebuffer_get_width (framebuffer); height = cogl_framebuffer_get_height (framebuffer); flags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN; /* The resizable property on SDL window apparently can only be set * on creation */ if (onscreen->resizable) flags |= SDL_WINDOW_RESIZABLE; window = SDL_CreateWindow ("" /* title */, 0, 0, /* x/y */ width, height, flags); if (window == NULL) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_ONSCREEN, "SDL_CreateWindow failed: %s", SDL_GetError ()); return FALSE; } SDL_SetWindowData (window, COGL_SDL_WINDOW_DATA_KEY, onscreen); onscreen->winsys = g_slice_new (CoglOnscreenSdl2); sdl_onscreen = onscreen->winsys; sdl_onscreen->window = window; return TRUE; }
void test_cogl_pipeline_uniforms (TestUtilsGTestFixture *fixture, void *user_data) { TestUtilsSharedState *shared_state = user_data; /* If shaders aren't supported then we can't run the test */ if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL)) { TestState state; init_state (&state); cogl_ortho (/* left, right */ 0, cogl_framebuffer_get_width (shared_state->fb), /* bottom, top */ cogl_framebuffer_get_height (shared_state->fb), 0, /* z near, far */ -1, 100); paint (&state); validate_result (); /* Try the test again after querying the location of a large number of uniforms. This should verify that the bitmasks still work even if they have to allocate a separate array to store the bits */ init_long_pipeline_state (&state); paint (&state); paint_long_pipeline (&state); validate_result (); validate_long_pipeline_result (); destroy_state (&state); if (g_test_verbose ()) g_print ("OK\n"); } else if (g_test_verbose ()) g_print ("Skipping\n"); }
void cogl_wayland_onscreen_resize (CoglOnscreen *onscreen, int width, int height, int offset_x, int offset_y) { CoglFramebuffer *fb; fb = COGL_FRAMEBUFFER (onscreen); if (fb->allocated) { CoglOnscreenEGL *egl_onscreen = onscreen->winsys; CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform; if (cogl_framebuffer_get_width (fb) != width || cogl_framebuffer_get_height (fb) != height || offset_x || offset_y) { wayland_onscreen->pending_width = width; wayland_onscreen->pending_height = height; wayland_onscreen->pending_dx += offset_x; wayland_onscreen->pending_dy += offset_y; wayland_onscreen->has_pending = TRUE; /* If nothing has been drawn to the framebuffer since the * last swap then wl_egl_window_resize will take effect * immediately. Otherwise it might not take effect until the * next swap, depending on the version of Mesa. To keep * consistent behaviour we'll delay the resize until the * next swap unless we're sure nothing has been drawn */ if (!fb->mid_scene) flush_pending_resize (onscreen); } } else _cogl_framebuffer_winsys_update_size (fb, width, height); }
void test_cogl_color_mask (TestUtilsGTestFixture *fixture, void *data) { TestUtilsSharedState *shared_state = data; TestState state; CoglColor bg; int i; state.width = cogl_framebuffer_get_width (shared_state->fb); state.height = cogl_framebuffer_get_height (shared_state->fb); cogl_color_init_from_4ub (&bg, 0, 0, 0, 255); for (i = 0; i < NUM_FBOS; i++) { state.tex[i] = cogl_texture_new_with_size (128, 128, COGL_TEXTURE_NO_ATLAS, COGL_PIXEL_FORMAT_RGB_888); state.fbo[i] = cogl_offscreen_new_to_texture (state.tex[i]); /* Clear the texture color bits */ cogl_push_framebuffer (state.fbo[i]); cogl_clear (&bg, COGL_BUFFER_BIT_COLOR); cogl_pop_framebuffer (); cogl_framebuffer_set_color_mask (state.fbo[i], i == 0 ? COGL_COLOR_MASK_RED : i == 1 ? COGL_COLOR_MASK_GREEN : COGL_COLOR_MASK_BLUE); } paint (&state); if (g_test_verbose ()) g_print ("OK\n"); }
static void handle_configure (void *data, struct wl_shell_surface *shell_surface, uint32_t edges, int32_t width, int32_t height) { ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL(data); CoglFramebuffer *fb = COGL_FRAMEBUFFER (stage_cogl->onscreen); if (cogl_framebuffer_get_width (fb) != width || cogl_framebuffer_get_height (fb) != height) clutter_actor_queue_relayout (CLUTTER_ACTOR (stage_cogl->wrapper)); clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper), width, height); /* the resize process is complete, so we can ask the stage * to set up the GL viewport with the new size */ clutter_stage_ensure_viewport (stage_cogl->wrapper); }
void test_texture_3d (void) { TestState state; state.fb_width = cogl_framebuffer_get_width (test_fb); state.fb_height = cogl_framebuffer_get_height (test_fb); cogl_framebuffer_orthographic (test_fb, 0, 0, /* x_1, y_1 */ state.fb_width, /* x_2 */ state.fb_height /* y_2 */, -1, 100 /* near/far */); draw_frame (&state); validate_result (); test_multi_texture (&state); if (cogl_test_verbose ()) g_print ("OK\n"); }