diff options
author | Robert Bragg <robert@linux.intel.com> | 2011-07-13 16:33:25 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2011-07-13 19:06:19 +0100 |
commit | 3ed8c8d0ba91143219673899c59d0e22834212e2 (patch) | |
tree | 1b26234fcb84442798e0ff61a59ed0a0018538bf /cogl/cogl-framebuffer.c | |
parent | ee4adeff4a2a3c2e4c2987e3b6252df45946913e (diff) | |
download | cogl-3ed8c8d0ba91143219673899c59d0e22834212e2.tar.gz |
framebuffer: Add dither_enabled getter/setters
This adds a getter and setter for requesting dithering to be enabled.
Dithering is a hardware dependent technique to increase the visible
color resolution beyond what the underlying hardware supports by playing
tricks with the colors placed into the framebuffer to give the illusion
of other colors. (For example this can be compared to half-toning used
by some news papers to show varying levels of grey even though their may
only be black and white are available).
The results of enabling dithering are platform dependent and may have no
effect.
Signed-off-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/cogl-framebuffer.c')
-rw-r--r-- | cogl/cogl-framebuffer.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index 0d718832..af8cc9a2 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -148,6 +148,7 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer, framebuffer->viewport_y = 0; framebuffer->viewport_width = width; framebuffer->viewport_height = height; + framebuffer->dither_enabled = TRUE; framebuffer->modelview_stack = _cogl_matrix_stack_new (); framebuffer->projection_stack = _cogl_matrix_stack_new (); @@ -1436,6 +1437,15 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer, _cogl_framebuffer_init_bits (draw_buffer); _cogl_framebuffer_init_bits (read_buffer); + if (ctx->current_gl_dither_enabled != draw_buffer->dither_enabled) + { + if (draw_buffer->dither_enabled) + GE (ctx, glEnable (GL_DITHER)); + else + GE (ctx, glDisable (GL_DITHER)); + ctx->current_gl_dither_enabled = draw_buffer->dither_enabled; + } + /* XXX: Flushing clip state may trash the modelview and projection * matrices so we must do it before flushing the matrices... */ @@ -1483,6 +1493,23 @@ cogl_framebuffer_get_alpha_bits (CoglFramebuffer *framebuffer) } gboolean +cogl_framebuffer_get_dither_enabled (CoglFramebuffer *framebuffer) +{ + return framebuffer->dither_enabled; +} + +void +cogl_framebuffer_set_dither_enabled (CoglFramebuffer *framebuffer, + gboolean dither_enabled) +{ + if (framebuffer->dither_enabled == dither_enabled) + return; + + cogl_flush (); /* Currently dithering changes aren't tracked in the journal */ + framebuffer->dither_enabled = dither_enabled; +} + +gboolean _cogl_framebuffer_try_fast_read_pixel (CoglFramebuffer *framebuffer, int x, int y, |