diff --git a/ChangeLog b/ChangeLog index e294f03f6..ed9a30e96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-14 Matthew Allum + + * README: + Make needed GL version 1.4, note GLES2 support, add some notes + for COGL. + 2008-06-13 Emmanuele Bassi * configure.ac: Post release bump to 0.7.1. diff --git a/README b/README index e1960f5e4..404b2dabd 100644 --- a/README +++ b/README @@ -9,7 +9,7 @@ Clutter currently requires: * GLib >= 2.14.0 * GdkPixbuf * Pango >= 1.18 - * OpenGL >= 1.2 or OpenGL ES 1.1 + * OpenGL >= 1.4, OpenGL ES 1.1 or OpenGL ES 2.0 * GLX, SDL, WGL or an EGL Implementation The official website is: @@ -165,6 +165,10 @@ wanting to port to newer releases (See NEWS for general new feature info). Release Notes for Clutter 0.8 ------------------------------- +* The COGL GL wrapper API has been overhauled and now contains many + new features including new texture abstractions, path based + primitive drawing, improved FBO support and is now fully documented. + * The size negotiation API has been completely changed in order to allow the creation of non-fixed layout managers. These functions have been removed: @@ -205,11 +209,16 @@ Release Notes for Clutter 0.8 * Clutter now features support for multiple stages assuming supported by the backend. See test-multistage.c for example of usage. This does not change the automatic creation of the default stage. + A single GL context is used across all stages meaning GL resources + are shared. -* There is now an experimental native iPod Touch/iPhone backend. +* There is now an experimental native iPod Touch/iPhone UIKit backend. * There is now an experimental native Win32 WGL backend. +* COGL (and therefor Clutter) now optionally features initial support for + OpenGL ES 2.0 + * Some more focused timeline unit tests have been added and some tweaks to timeline semantics were made; E.g. For a 10 frame timeline here are some points about the semantics: diff --git a/clutter/cogl/gl/cogl-defines.h.in b/clutter/cogl/gl/cogl-defines.h.in index a93f9f030..3beeddcaf 100644 --- a/clutter/cogl/gl/cogl-defines.h.in +++ b/clutter/cogl/gl/cogl-defines.h.in @@ -26,6 +26,8 @@ #ifndef __COGL_DEFINES_H__ #define __COGL_DEFINES_H__ +#define GL_GLEXT_PROTOTYPES 1 + #include <@CLUTTER_GL_HEADER@> G_BEGIN_DECLS diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 24f37b9b1..ae2e722a6 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -38,6 +38,9 @@ #include #include +// #define HAVE_PBOS 1 +#include + /* #define COGL_DEBUG 1 @@ -244,7 +247,39 @@ _cogl_texture_upload_to_gl (CoglTexture *tex) x_span->start, y_span->start, FALSE); + { +#if HAVE_PBOS + void *io_mem; + GLuint buf; + + buf = g_array_index (tex->slice_buf_handles, GLuint, + y * tex->slice_x_spans->len + x); + + glBindBuffer (GL_PIXEL_UNPACK_BUFFER_ARB, buf); + glBufferData (GL_PIXEL_UNPACK_BUFFER_ARB, + tex->bitmap.height * tex->bitmap.rowstride, + NULL, + GL_STREAM_DRAW); + + io_mem = glMapBuffer (GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY); + + g_assert (io_mem); + memcpy (io_mem, tex->bitmap.data, + tex->bitmap.height * tex->bitmap.rowstride); + + GE( glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB) ); + + GE( glBindTexture (tex->gl_target, gl_handle) ); + + GE( glTexSubImage2D (tex->gl_target, 0, 0, 0, + x_span->size - x_span->waste, + y_span->size - y_span->waste, + tex->gl_format, tex->gl_type, + (char *)NULL) ); + + GE( glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0) ); +#else /* Upload new image data */ GE( glBindTexture (tex->gl_target, gl_handle) ); @@ -253,6 +288,8 @@ _cogl_texture_upload_to_gl (CoglTexture *tex) y_span->size - y_span->waste, tex->gl_format, tex->gl_type, tex->bitmap.data) ); +#endif + } } } @@ -568,6 +605,9 @@ _cogl_texture_slices_create (CoglTexture *tex) gint max_width; gint max_height; GLuint *gl_handles; +#if HAVE_PBOS + GLuint *buf_handles; +#endif gint n_x_slices; gint n_y_slices; gint n_slices; @@ -703,7 +743,17 @@ _cogl_texture_slices_create (CoglTexture *tex) gl_handles = (GLuint*) tex->slice_gl_handles->data; GE( glGenTextures (n_slices, gl_handles) ); + +#if HAVE_PBOS + tex->slice_buf_handles = g_array_sized_new (FALSE, FALSE, + sizeof (GLuint), + n_slices); + g_array_set_size (tex->slice_buf_handles, n_slices); + buf_handles = (GLuint*) tex->slice_buf_handles->data; + + GE( glGenBuffers(n_slices, buf_handles) ); +#endif /* Init each GL texture object */ for (y = 0; y < n_y_slices; ++y) @@ -712,8 +762,11 @@ _cogl_texture_slices_create (CoglTexture *tex) for (x = 0; x < n_x_slices; ++x) { +#if HAVE_PBOS + glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0); +#endif x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x); - + #if COGL_DEBUG printf ("CREATE SLICE (%d,%d)\n", x,y); printf ("size: (%d x %d)\n", @@ -721,9 +774,12 @@ _cogl_texture_slices_create (CoglTexture *tex) y_span->size - y_span->waste); #endif /* Setup texture parameters */ - GE( glBindTexture (tex->gl_target, gl_handles[y * n_x_slices + x]) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, tex->mag_filter) ); - GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, tex->min_filter) ); + GE( glBindTexture (tex->gl_target, + gl_handles[y * n_x_slices + x]) ); + GE( glTexParameteri (tex->gl_target, + GL_TEXTURE_MAG_FILTER, tex->mag_filter) ); + GE( glTexParameteri (tex->gl_target, + GL_TEXTURE_MIN_FILTER, tex->min_filter) ); GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, tex->wrap_mode) ); @@ -768,6 +824,15 @@ _cogl_texture_slices_free (CoglTexture *tex) g_array_free (tex->slice_gl_handles, TRUE); } + +#if HAVE_PBOS + if (tex->slice_buf_handles != NULL) + { + glDeleteBuffers(tex->slice_buf_handles->len, + (GLuint*) tex->slice_buf_handles->data); + + } +#endif } static gboolean diff --git a/clutter/cogl/gl/cogl-texture.h b/clutter/cogl/gl/cogl-texture.h index 117437458..3dfed0993 100644 --- a/clutter/cogl/gl/cogl-texture.h +++ b/clutter/cogl/gl/cogl-texture.h @@ -51,6 +51,7 @@ struct _CoglTexture GArray *slice_x_spans; GArray *slice_y_spans; GArray *slice_gl_handles; + GArray *slice_buf_handles; gint max_waste; COGLenum min_filter; COGLenum mag_filter; diff --git a/tests/test-textures.c b/tests/test-textures.c index ea5dfa250..9528faca8 100644 --- a/tests/test-textures.c +++ b/tests/test-textures.c @@ -59,6 +59,8 @@ main (int argc, char *argv[]) ClutterActor *texture; ClutterActor *stage; gint i, j; + guchar *pixels; + int rowstride; clutter_init (&argc, &argv); @@ -67,23 +69,27 @@ main (int argc, char *argv[]) SPIN(); + pixels = make_rgba_data (1000, 1000, 4, TRUE, &rowstride); + + texture = clutter_texture_new (); + + clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL); + clutter_actor_set_size (texture, 400, 400); + clutter_actor_show (texture); + for (i=100; i<=5000; i += 100) for (j=0; j<4; j++) { - const int width = i+j; - const int height = i+j; + const int width = 1000; + const int height = 1000; const gboolean has_alpha = TRUE; const int bpp = has_alpha ? 4 : 3; - int rowstride; - guchar *pixels; - pixels = make_rgba_data (width, height, bpp, has_alpha, &rowstride); + if (!pixels) g_error("No memory for %ix%i RGBA data failed", width, height); printf("o %ix%i texture... ", width, height); - - texture = clutter_texture_new (); if (!clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture), pixels, has_alpha, @@ -93,21 +99,22 @@ main (int argc, char *argv[]) bpp, 0, NULL)) g_error("texture creation failed"); - g_free(pixels); + // g_free(pixels); printf("uploaded to texture...\n"); - clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL); - clutter_actor_set_size (texture, 400, 400); - clutter_actor_show (texture); /* Hide & show to unreaise then realise the texture */ clutter_actor_hide (texture); clutter_actor_show (texture); + // clutter_actor_unrealize (texture); + SPIN(); - clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL); + // clutter_actor_destroy (texture); + + // clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL); } return EXIT_SUCCESS;