summaryrefslogtreecommitdiff
path: root/gen.cpp
diff options
context:
space:
mode:
authorknolax <1339802534.kk@gmail.com>2017-02-22 20:43:47 -0500
committerknolax <1339802534.kk@gmail.com>2017-02-22 20:43:47 -0500
commitc7bdd6fcae58e09597071405c1449df64e084c51 (patch)
treec9ca26278a7a86725aa2e5af7e1a330c89265137 /gen.cpp
parentd137bf2485050b54bb0ac65ef543ba24f18fabbe (diff)
implemented phoung shading and surrounding infrastructure, gen.cpp compiles a simple program that creates raw vertex data from vertexes in a way that surppassess the limitations of opengl's native elements[] protocol. next step is to allow for z distance based override and multi draw;
Diffstat (limited to 'gen.cpp')
-rw-r--r--gen.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/gen.cpp b/gen.cpp
new file mode 100644
index 0000000..167d9e7
--- /dev/null
+++ b/gen.cpp
@@ -0,0 +1,55 @@
+#include <stdio.h>
+int main () {
+ float vertexdata[] = {
+ -0.5, 0.5, -.5, // x y z
+ 0.5, 0.5, -.5,
+ 0.5, -0.5, -.5,
+ -0.5, -0.5, -.5,
+ -0.5, 0.5, 0.5, // x y z
+ 0.5, 0.5, 0.5,
+ 0.5, -0.5, 0.5,
+ -0.5, -0.5, 0.5,
+ //normal positions
+ 1.0, 0.0, 0.0,
+ -1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, -1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ 0.0, 0.0, -1.0,
+ };
+ //polygons of the box mode based on the vertex data.
+ //they must be clockwise from the front so that they are culled when not
+ //seen
+ int elementdata[] = {
+ 0,13, 1,13, 3,13,
+ 3,13, 1,13, 2,13,
+
+ 1,8, 5,8, 2,8,
+ 2,8, 5,8, 6,8,
+
+ 5,12, 4,12, 6,12,
+ 4,12, 7,12, 6,12,
+
+ 4,9, 0,9, 7,9,
+ 0,9, 3,9, 7,9,
+
+ 3,11, 6,11, 7,11,
+ 2,11, 6,11, 3,11,
+
+ 0,10, 4,10, 5,10,
+ 5,10, 1,10, 0,10,
+ };
+ int i = 0;
+ printf("float vertexdata[] = {\n");
+ while (i < 72) {
+ printf("%f,%f,%f, ",vertexdata[(elementdata[i] * 3)],vertexdata[(elementdata[i] * 3) + 1],vertexdata[(elementdata[i] * 3 )+ 2]);
+ if (((i + 1) % 6) == 0) {
+ printf("\n");
+ } else if (((i + 1) % 2) == 0) {
+ printf("\t");
+ }
+ i++;
+ }
+ printf("};");
+ return 0;
+}