summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/Terminus.ttfbin0 -> 423992 bytes
-rw-r--r--example/fragmentshader.glsl6
-rwxr-xr-xexample/mainbin0 -> 49192 bytes
-rw-r--r--example/main.cpp57
-rw-r--r--example/main.h4
-rw-r--r--example/main.obin0 -> 4424 bytes
-rw-r--r--example/makefile6
-rw-r--r--example/vertexshader.glsl10
8 files changed, 83 insertions, 0 deletions
diff --git a/example/Terminus.ttf b/example/Terminus.ttf
new file mode 100644
index 0000000..3eb75d2
--- /dev/null
+++ b/example/Terminus.ttf
Binary files differ
diff --git a/example/fragmentshader.glsl b/example/fragmentshader.glsl
new file mode 100644
index 0000000..d15860a
--- /dev/null
+++ b/example/fragmentshader.glsl
@@ -0,0 +1,6 @@
+#version 130
+out vec4 outpix;
+void main()
+{
+ outpix = vec4(1.0, 0.0, 0.0, 0.5);
+}
diff --git a/example/main b/example/main
new file mode 100755
index 0000000..5d3327b
--- /dev/null
+++ b/example/main
Binary files differ
diff --git a/example/main.cpp b/example/main.cpp
new file mode 100644
index 0000000..0748ace
--- /dev/null
+++ b/example/main.cpp
@@ -0,0 +1,57 @@
+#include<stdio.h>
+#include<time.h>
+#include "glgfx.h"
+#include "gfx.h"
+#include "main.h"
+#include "gui.h"
+int loop;
+int rot = 0;
+float dir = 0.0f;
+int main (int argc, char * argv[]) {
+ //inits program
+ initgfx(400,600, "rotating cube");
+ initglgfx();
+ //main loop, this is defined in main.h and global
+ loop = 1;
+ while(loop) {
+ cleargfx();
+ //polls events, which are in a buffer
+ //returns 1 if there is event in buffer
+ //returns 0 if buffer is empty
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ switch (event.type) {
+ //loop is a global defined in main.h
+ case SDL_QUIT:
+ printf("loop = 0;\n");
+ loop = 0;
+ break;
+
+ }
+ }
+ dir += 0.05;
+ if (dir > 360.0f) {
+ rot++;
+ rot = rot % 3;
+ dir = 0.0f;
+ }
+ switch (rot) {
+ case 0:
+ drawmodel(0.0f, 0.0f, -2.0f, dir, 0.0f, 0.0f);
+ drawmodel(0.5f, 3.0f, -10.0f, dir, 0.0f, 0.0f);
+ break;
+ case 1:
+ drawmodel(0.0f, 0.0f, -2.0f, 0.0f, dir, 0.0f);
+ drawmodel(0.5f, 3.0f, -10.0f, 0.0f, dir, 0.0f);
+ break;
+ case 2:
+ drawmodel(0.0f, 0.0f, -2.0f, 0.0f, 0.0f, dir);
+ drawmodel(0.5f, 3.0f, -10.0f, 0.0f, 0.0f, dir);
+ break;
+ }
+ updategfx();
+ }
+ quitgfx();
+ return 0;
+}
+
diff --git a/example/main.h b/example/main.h
new file mode 100644
index 0000000..e02ea4b
--- /dev/null
+++ b/example/main.h
@@ -0,0 +1,4 @@
+#ifndef MAIN_H
+#define MAIN_H
+extern int loop;
+#endif
diff --git a/example/main.o b/example/main.o
new file mode 100644
index 0000000..5b75d16
--- /dev/null
+++ b/example/main.o
Binary files differ
diff --git a/example/makefile b/example/makefile
new file mode 100644
index 0000000..578059f
--- /dev/null
+++ b/example/makefile
@@ -0,0 +1,6 @@
+main : main.o
+ g++ main.o -o main -L/home/knolax/code/cpp/gfx -lgui -lgfx -lSDL2 -lSDL2_ttf -L/home/knolax/code/cpp/glgfx -lglgfx -lGLEW -lGL
+main.o : main.cpp
+ g++ -c main.cpp -I/home/knolax/code/cpp/gfx -I/home/knolax/code/cpp/glgfx
+clean :
+ rm main.o
diff --git a/example/vertexshader.glsl b/example/vertexshader.glsl
new file mode 100644
index 0000000..4187969
--- /dev/null
+++ b/example/vertexshader.glsl
@@ -0,0 +1,10 @@
+#version 130
+uniform mat4 proj;
+uniform mat4 tran;
+uniform mat4 cam;
+in vec3 position;
+
+void main()
+{
+ gl_Position = proj * cam * tran * vec4(position, 1.0f);
+}