summaryrefslogtreecommitdiff
path: root/inc/opengl
diff options
context:
space:
mode:
authoriamn1ck <iamn1ck@yahoo.com>2017-02-19 07:00:34 -0600
committerTom Barrett <tombarrett@siu.edu>2017-03-07 13:22:46 -0600
commit74c6854fd8dcbaee736ac0421805ff1e03c4a1e2 (patch)
tree4a3ae40bea9b07a2111128e98d9272bdbac2af87 /inc/opengl
parent03885192b9ff7d3c5e2dcfd98aefd21e9b62f603 (diff)
-quadtree and opengl rendering are now in the master branch !
-using sdl_rect for location and size ended up being not so great due to it not having floats, so we reverted back to using location -much, much refractoring is now needed
Diffstat (limited to 'inc/opengl')
-rw-r--r--inc/opengl/basicshader.frag9
-rw-r--r--inc/opengl/basicshader.geom33
-rw-r--r--inc/opengl/basicshader.vert15
-rw-r--r--inc/opengl/theshader.frag7
-rw-r--r--inc/opengl/theshader.geom24
-rw-r--r--inc/opengl/theshader.vert15
6 files changed, 103 insertions, 0 deletions
diff --git a/inc/opengl/basicshader.frag b/inc/opengl/basicshader.frag
new file mode 100644
index 0000000..9aa9d0b
--- /dev/null
+++ b/inc/opengl/basicshader.frag
@@ -0,0 +1,9 @@
+#version 320 es
+in highp vec3 fColor;
+out highp vec4 outColor;
+
+
+void main()
+{
+ outColor = vec4(fColor, 1.0);
+} \ No newline at end of file
diff --git a/inc/opengl/basicshader.geom b/inc/opengl/basicshader.geom
new file mode 100644
index 0000000..3540d10
--- /dev/null
+++ b/inc/opengl/basicshader.geom
@@ -0,0 +1,33 @@
+#version 320 es
+layout(points) in;
+layout(line_strip, max_vertices = 64) out;
+
+in highp vec3 vColor[];
+in highp float vSides[];
+out highp vec3 fColor;
+
+const float PI = 3.1415926;
+
+void main()
+{
+ fColor = vColor[0];
+
+ for (int i = 0; i <= 4; i++) { // Angle between each side in radians
+
+ vec4 offset = vec4(vSides[0] *.8,-vSides[0] *1.1, 0.0, 0.0);
+ if(i==1)
+ offset = vec4(vSides[0] *.8,vSides[0] *1.1, 0.0, 0.0);
+ if(i==2)
+ offset = vec4(-vSides[0] *.8,vSides[0] *1.1, 0.0, 0.0);
+ if(i==3)
+ offset = vec4(-vSides[0] *.8,-vSides[0] *1.1, 0.0, 0.0);
+ if(i==4)
+ offset = vec4(vSides[0] *.8,-vSides[0] *1.1, 0.0, 0.0);
+
+
+ gl_Position = gl_in[0].gl_Position - offset;
+
+ EmitVertex();
+ }
+ EndPrimitive();
+}
diff --git a/inc/opengl/basicshader.vert b/inc/opengl/basicshader.vert
new file mode 100644
index 0000000..f17aef5
--- /dev/null
+++ b/inc/opengl/basicshader.vert
@@ -0,0 +1,15 @@
+#version 320 es
+in highp vec2 pos;
+in highp vec3 color;
+in highp float sides;
+uniform mat4 MVP;
+
+out highp vec3 fColor;
+out highp float vSides;
+
+void main()
+{
+ gl_Position = MVP * vec4(pos, 0.0, 1.0);
+ fColor = color;
+ vSides = sides;
+}
diff --git a/inc/opengl/theshader.frag b/inc/opengl/theshader.frag
new file mode 100644
index 0000000..4f870cb
--- /dev/null
+++ b/inc/opengl/theshader.frag
@@ -0,0 +1,7 @@
+#version 320 es
+in highp vec3 fColor;
+out highp vec4 outColor;
+void main()
+{
+ outColor = vec4(fColor, 1.0);
+} \ No newline at end of file
diff --git a/inc/opengl/theshader.geom b/inc/opengl/theshader.geom
new file mode 100644
index 0000000..a49e6bc
--- /dev/null
+++ b/inc/opengl/theshader.geom
@@ -0,0 +1,24 @@
+#version 320 es
+layout(points) in;
+layout(triangle_strip, max_vertices = 64) out;
+
+in highp vec3 vColor[];
+in highp float vSides[];
+out highp vec3 fColor;
+
+const float PI = 3.1415926;
+
+void main()
+{
+ fColor = vColor[0];
+
+ for (float i = 0.0; i <= vSides[0]; i+=1.0) { // Angle between each side in radians
+ float ang = PI * 2.0 / vSides[0] * i;
+ // Offset from center of point (0.3 to accomodate for aspect ratio)
+ vec4 offset = vec4(cos(ang) * 0.3, -sin(ang) * 0.4, 0.0, 0.0);
+ gl_Position = gl_in[0].gl_Position - offset;
+
+ EmitVertex();
+ }
+ EndPrimitive();
+} \ No newline at end of file
diff --git a/inc/opengl/theshader.vert b/inc/opengl/theshader.vert
new file mode 100644
index 0000000..b7cfe3b
--- /dev/null
+++ b/inc/opengl/theshader.vert
@@ -0,0 +1,15 @@
+#version 320 es
+in highp vec2 pos;
+in highp vec3 color;
+in highp float sides;
+uniform mat4 MVP;
+
+out highp vec3 fColor;
+out highp float vSides;
+
+void main()
+{
+ gl_Position = MVP * vec4(pos, 0.0, 1.0);
+ fColor = color;
+ vSides = sides;
+}