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.
This commit is contained in:
parent
4d990a93a8
commit
296d14e946
@ -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 \
|
||||
|
39
cogl/cogl-vertex-array-private.h
Normal file
39
cogl/cogl-vertex-array-private.h
Normal file
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
70
cogl/cogl-vertex-array.c
Normal file
70
cogl/cogl-vertex-array.c
Normal file
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
|
77
cogl/cogl-vertex-array.h
Normal file
77
cogl/cogl-vertex-array.h
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> 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__ */
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include <cogl/cogl-vector.h>
|
||||
#include <cogl/cogl-texture-3d.h>
|
||||
#include <cogl/cogl-index-array.h>
|
||||
#include <cogl/cogl-vertex-array.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user