latest
[vg.git] / vg_graph.h
diff --git a/vg_graph.h b/vg_graph.h
new file mode 100644 (file)
index 0000000..fac1984
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef VG_GRAPH_H
+#define VG_GRAPH_H
+
+#define VG_GAME
+#include "vg/vg.h"
+
+enum { k_vg_graph_max_samples  = 1024 };
+enum { k_vg_graph_max_vertices = k_vg_graph_max_samples * 2 };
+enum { k_vg_graph_max_indices  = (k_vg_graph_max_samples-1) * 6 };
+
+struct vg_graph
+{
+   GLuint vao, vbo, ebo;
+};
+
+VG_STATIC void vg_graph_init( struct vg_graph *graph )
+{
+   vg_acquire_thread_sync();
+   {
+      glGenVertexArrays( 1, &graph->vao );
+      glGenBuffers( 1, &graph->vbo );
+      glGenBuffers( 1, &graph->ebo );
+      glBindVertexArray( graph->vao );
+
+      size_t stride = sizeof(v2f);
+
+      glBindBuffer( GL_ARRAY_BUFFER, graph->vbo );
+      glBufferData( GL_ARRAY_BUFFER, k_vg_graph_max_vertices*stride, 
+                                     NULL, GL_DYNAMIC_DRAW );
+
+      glBindVertexArray( graph->vao );
+      glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, graph->ebo );
+      glBufferData( GL_ELEMENT_ARRAY_BUFFER, 
+            k_vg_graph_max_indices*sizeof(u16), NULL,
+            GL_DYNAMIC_DRAW );
+
+      glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, stride, (void *)0 );
+      glEnableVertexAttribArray( 0 );
+      VG_CHECK_GL_ERR();
+   }
+}
+
+VG_STATIC void vg_graph_add_sample( struct vg_graph *graph )
+{
+   
+}
+
+#endif /* VG_GRAPH_H */