From 296d14e94625b95304092d0b66d1d37871f58b71 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 12 Oct 2010 12:34:27 +0100 Subject: cogl: Adds experimental CoglVertexArray type This adds a new CoglVertexArray object which is a subclass of CoglBuffer used to hold vertex attributes. A later commit will add a CoglVertexAttribute API which will be used to describe the attributes inside a CoglVertexArray. --- cogl/Makefile.am | 3 ++ cogl/cogl-vertex-array-private.h | 39 ++++++++++++++++++++ cogl/cogl-vertex-array.c | 70 ++++++++++++++++++++++++++++++++++++ cogl/cogl-vertex-array.h | 77 ++++++++++++++++++++++++++++++++++++++++ cogl/cogl.h | 1 + 5 files changed, 190 insertions(+) create mode 100644 cogl/cogl-vertex-array-private.h create mode 100644 cogl/cogl-vertex-array.c create mode 100644 cogl/cogl-vertex-array.h diff --git a/cogl/Makefile.am b/cogl/Makefile.am index cd7a3cf4..8b992573 100644 --- a/cogl/Makefile.am +++ b/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/cogl/cogl-vertex-array-private.h b/cogl/cogl-vertex-array-private.h new file mode 100644 index 00000000..f24c7dec --- /dev/null +++ b/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/cogl/cogl-vertex-array.c b/cogl/cogl-vertex-array.c new file mode 100644 index 00000000..23e010e2 --- /dev/null +++ b/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/cogl/cogl-vertex-array.h b/cogl/cogl-vertex-array.h new file mode 100644 index 00000000..a27e627d --- /dev/null +++ b/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/cogl/cogl.h b/cogl/cogl.h index 83bacfb1..efa2f216 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -55,6 +55,7 @@ #include #include #include +#include #endif G_BEGIN_DECLS -- cgit v1.2.1