diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am index cd7a3cf40..8b9925733 100644 --- a/clutter/cogl/cogl/Makefile.am +++ b/clutter/cogl/cogl/Makefile.am @@ -73,6 +73,7 @@ cogl_public_h = \ $(srcdir)/cogl-types.h \ $(srcdir)/cogl-vertex-buffer.h \ $(srcdir)/cogl-index-array.h \ + $(srcdir)/cogl-vertex-array.h \ $(srcdir)/cogl.h \ $(NULL) @@ -208,6 +209,8 @@ cogl_sources_c = \ $(srcdir)/cogl-vertex-buffer.c \ $(srcdir)/cogl-index-array-private.h \ $(srcdir)/cogl-index-array.c \ + $(srcdir)/cogl-vertex-array-private.h \ + $(srcdir)/cogl-vertex-array.c \ $(srcdir)/cogl-matrix.c \ $(srcdir)/cogl-vector.c \ $(srcdir)/cogl-matrix-private.h \ diff --git a/clutter/cogl/cogl/cogl-vertex-array-private.h b/clutter/cogl/cogl/cogl-vertex-array-private.h new file mode 100644 index 000000000..f24c7dec0 --- /dev/null +++ b/clutter/cogl/cogl/cogl-vertex-array-private.h @@ -0,0 +1,39 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2010 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * + * + * Authors: + * Robert Bragg + */ + +#ifndef __COGL_VERTEX_ARRAY_PRIVATE_H +#define __COGL_VERTEX_ARRAY_PRIVATE_H + +#include "cogl-buffer-private.h" + +struct _CoglVertexArray +{ + CoglBuffer _parent; +}; + +#endif /* __COGL_VERTEX_ARRAY_PRIVATE_H */ + diff --git a/clutter/cogl/cogl/cogl-vertex-array.c b/clutter/cogl/cogl/cogl-vertex-array.c new file mode 100644 index 000000000..23e010e26 --- /dev/null +++ b/clutter/cogl/cogl/cogl-vertex-array.c @@ -0,0 +1,70 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2010 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * + * + * Authors: + * Robert Bragg + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "cogl-object-private.h" +#include "cogl-vertex-array.h" +#include "cogl-vertex-array-private.h" + +static void _cogl_vertex_array_free (CoglVertexArray *array); + +COGL_BUFFER_DEFINE (VertexArray, vertex_array); + +CoglVertexArray * +cogl_vertex_array_new (gsize bytes) +{ + CoglVertexArray *array = g_slice_new (CoglVertexArray); + gboolean use_malloc; + + if (!cogl_features_available (COGL_FEATURE_VBOS)) + use_malloc = TRUE; + else + use_malloc = FALSE; + + /* parent's constructor */ + _cogl_buffer_initialize (COGL_BUFFER (array), + bytes, + use_malloc, + COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY, + COGL_BUFFER_USAGE_HINT_VERTEX_ARRAY, + COGL_BUFFER_UPDATE_HINT_STATIC); + + return _cogl_vertex_array_object_new (array); +} + +static void +_cogl_vertex_array_free (CoglVertexArray *array) +{ + /* parent's destructor */ + _cogl_buffer_fini (COGL_BUFFER (array)); + + g_slice_free (CoglVertexArray, array); +} + diff --git a/clutter/cogl/cogl/cogl-vertex-array.h b/clutter/cogl/cogl/cogl-vertex-array.h new file mode 100644 index 000000000..a27e627de --- /dev/null +++ b/clutter/cogl/cogl/cogl-vertex-array.h @@ -0,0 +1,77 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2010 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + * + * + * + * Authors: + * Robert Bragg + */ + +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __COGL_VERTEX_ARRAY_H__ +#define __COGL_VERTEX_ARRAY_H__ + +G_BEGIN_DECLS + +/** + * SECTION:cogl-vertex-array + * @short_description: Fuctions for creating and manipulating vertex arrays + * + * FIXME + */ + +typedef struct _CoglVertexArray CoglVertexArray; + +/** + * cogl_vertex_array_new: + * @size: The number of bytes to allocate for vertex attribute data. + * + * Declares a new #CoglVertexArray of @size bytes to contain arrays of vertex + * attribute data. Once declared, data can be set using cogl_buffer_set_data() + * or by mapping it into the application's address space using cogl_buffer_map(). + * + * Since: 1.4 + * Stability: Unstable + */ +CoglVertexArray * +cogl_vertex_array_new (gsize bytes); + +/** + * cogl_is_vertex_array: + * @object: A #CoglObject + * + * Gets whether the given object references a #CoglVertexArray. + * + * Returns: %TRUE if the handle references a #CoglVertexArray, + * %FALSE otherwise + * + * Since: 1.4 + * Stability: Unstable + */ +gboolean +cogl_is_vertex_array (void *object); + +G_END_DECLS + +#endif /* __COGL_VERTEX_ARRAY_H__ */ + diff --git a/clutter/cogl/cogl/cogl.h b/clutter/cogl/cogl/cogl.h index 83bacfb10..efa2f216b 100644 --- a/clutter/cogl/cogl/cogl.h +++ b/clutter/cogl/cogl/cogl.h @@ -55,6 +55,7 @@ #include #include #include +#include #endif G_BEGIN_DECLS