[Bf-blender-cvs] [1e9ef2a25e0] blender2.8: GWN: Add GWN_batch_draw_procedural

Clément Foucault noreply at git.blender.org
Wed Feb 14 19:02:36 CET 2018


Commit: 1e9ef2a25e08462a020de3897bc3b68a782c4120
Author: Clément Foucault
Date:   Wed Feb 14 17:55:01 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB1e9ef2a25e08462a020de3897bc3b68a782c4120

GWN: Add GWN_batch_draw_procedural

This allow to drawn large amounts of primitives without any memory footprint.

===================================================================

M	intern/gawain/gawain/gwn_batch.h
M	intern/gawain/src/gwn_batch.c

===================================================================

diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h
index 9564d8cd587..94cd893f09e 100644
--- a/intern/gawain/gawain/gwn_batch.h
+++ b/intern/gawain/gawain/gwn_batch.h
@@ -85,11 +85,9 @@ void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]);
 void GWN_batch_draw(Gwn_Batch*);
 
 
-// clement : temp stuff
 void GWN_batch_draw_stupid(Gwn_Batch*, int v_first, int v_count);
 void GWN_batch_draw_stupid_instanced(Gwn_Batch*, Gwn_Batch*, int instance_first, int instance_count);
-
-
+void GWN_batch_draw_procedural(Gwn_Batch*, Gwn_PrimType, int v_count);
 
 
 #if 0 // future plans
diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c
index 9cd5400f144..ec3f98e348c 100644
--- a/intern/gawain/src/gwn_batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -417,3 +417,18 @@ void GWN_batch_draw_stupid_instanced(Gwn_Batch* batch_instanced, Gwn_Batch* batc
 
 	glBindVertexArray(0);
 	}
+
+// just draw some vertices and let shader place them where we want.
+void GWN_batch_draw_procedural(Gwn_Batch* batch, Gwn_PrimType prim_type, int v_count)
+	{
+	// we cannot draw without vao ... annoying ...
+	if (batch->vao_id)
+		glBindVertexArray(batch->vao_id);
+	else
+		Batch_prime(batch);
+
+	GLenum type = convert_prim_type_to_gl(prim_type);
+	glDrawArrays(type, 0, v_count);
+
+	glBindVertexArray(0);
+	}



More information about the Bf-blender-cvs mailing list