Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-07-25 14:17:37 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-07-25 15:42:26 +0300
commit50a46a5973d90787eaa37ea959b9035918a071af (patch)
treec32b8cd522d8400907770cf93c4154b7601b2569 /source/blender/gpu/intern/gpu_buffers.c
parent38e19536bf6dd33cf73578260b17c5bc9d5db268 (diff)
GPU buffer materials:
Separate and reuse some shared code. Also avoid counting for information we already know, such as total loop triangles etc.
Diffstat (limited to 'source/blender/gpu/intern/gpu_buffers.c')
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index b2bfb0b47b8..bbffa5a53c2 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -114,6 +114,36 @@ static int mres_prev_gridsize = -1;
static GLenum mres_prev_index_type = 0;
static unsigned mres_prev_totquad = 0;
+void GPU_buffer_material_finalize(GPUDrawObject *gdo, GPUBufferMaterial *matinfo, int totmat)
+{
+ int i, curmat, curelement;
+
+ /* count the number of materials used by this DerivedMesh */
+ for (i = 0; i < totmat; i++) {
+ if (matinfo[i].totelements > 0)
+ gdo->totmaterial++;
+ }
+
+ /* allocate an array of materials used by this DerivedMesh */
+ gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial,
+ "GPUDrawObject.materials");
+
+ /* initialize the materials array */
+ for (i = 0, curmat = 0, curelement = 0; i < totmat; i++) {
+ if (matinfo[i].totelements > 0) {
+ gdo->materials[curmat] = matinfo[i];
+ gdo->materials[curmat].start = curelement;
+ gdo->materials[curmat].mat_nr = i;
+ gdo->materials[curmat].polys = MEM_mallocN(sizeof(int) * matinfo[i].totpolys, "GPUBufferMaterial.polys");
+
+ curelement += matinfo[i].totelements;
+ curmat++;
+ }
+ }
+
+ MEM_freeN(matinfo);
+}
+
/* stores recently-deleted buffers so that new buffers won't have to
* be recreated as often