summaryrefslogtreecommitdiff
path: root/tests/conform/test-framebuffer-get-bits.c
blob: c4a1dc405b32dd2680dd46a84f4a6c74a32fcb1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <cogl/cogl.h>

#include "test-utils.h"

void
test_framebuffer_get_bits (void)
{
  CoglTexture2D *tex_a =
    cogl_texture_2d_new_with_size (test_ctx,
                                   16, 16, /* width/height */
                                   COGL_PIXEL_FORMAT_A_8);
  CoglOffscreen *offscreen_a =
    cogl_offscreen_new_with_texture (tex_a);
  CoglFramebuffer *fb_a = offscreen_a;
  CoglTexture2D *tex_rgba =
    cogl_texture_2d_new_with_size (test_ctx,
                                   16, 16, /* width/height */
                                   COGL_PIXEL_FORMAT_RGBA_8888);
  CoglOffscreen *offscreen_rgba =
    cogl_offscreen_new_with_texture (tex_rgba);
  CoglFramebuffer *fb_rgba = offscreen_rgba;

  cogl_framebuffer_allocate (fb_a, NULL);
  cogl_framebuffer_allocate (fb_rgba, NULL);

  g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_a), ==, 0);
  g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_a), ==, 0);
  g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_a), ==, 0);
  g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_a), >=, 1);

  g_assert_cmpint (cogl_framebuffer_get_red_bits (fb_rgba), >=, 1);
  g_assert_cmpint (cogl_framebuffer_get_green_bits (fb_rgba), >=, 1);
  g_assert_cmpint (cogl_framebuffer_get_blue_bits (fb_rgba), >=, 1);
  g_assert_cmpint (cogl_framebuffer_get_alpha_bits (fb_rgba), >=, 1);

  cogl_object_unref (fb_rgba);
  cogl_object_unref (tex_rgba);
  cogl_object_unref (fb_a);
  cogl_object_unref (tex_a);
}