summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/fragmentshader.glsl8
-rwxr-xr-xexample/mainbin49568 -> 54072 bytes
-rw-r--r--example/makefile2
-rw-r--r--example/textures/elev.bmpbin0 -> 4000138 bytes
-rw-r--r--example/textures/elev.pngbin0 -> 198073 bytes
-rw-r--r--example/textures/tex.bmpbin0 -> 4000138 bytes
-rw-r--r--example/textures/tex.pngbin0 -> 164345 bytes
-rw-r--r--example/vertexshader.glsl3
8 files changed, 11 insertions, 2 deletions
diff --git a/example/fragmentshader.glsl b/example/fragmentshader.glsl
index 70c55b5..6e8c4c5 100644
--- a/example/fragmentshader.glsl
+++ b/example/fragmentshader.glsl
@@ -2,11 +2,15 @@
out vec4 outpix;
uniform vec3 campos;
uniform vec3 lightpos;
+uniform sampler2D tex;
+uniform sampler2D elev;
//varing blends them it is transformed to world space
varying vec4 fragpos;
varying vec4 fragnormal;
+varying vec2 fragtexcoord;
void main()
{
+ vec4 elevpix = texture(elev, fragtexcoord);
vec3 lightnormal = normalize((lightpos - vec3(fragpos.x, fragpos.y, fragpos.z)));
float diffuse = dot(lightnormal, vec3(fragnormal.x, fragnormal.y, fragnormal.z));
if (diffuse < 0.0) {
@@ -17,9 +21,11 @@ void main()
diffuse = pow(diffuse, 2.0);
reflect = pow(reflect, 2.0);
float light = .4 * reflect + .6 * diffuse;
+ vec4 texpix = texture(tex, fragtexcoord);
//this should be the vertex in camera space without the w value
//outpix = gl_FragCoord;
- outpix = vec4(light * 1.0,light * 1.0,light * 1.0, 1.0);
+ outpix = texpix;
+ //outpix = vec4(light * 1.0,light * 1.0,light * 1.0, 1.0);
//outpix = vec4(fragpos.x ,fragpos.y ,fragpos.z, 0.5);
//outpix = vec4(fragnormal.x, fragnormal.y, fragnormal.z, 0.5);
}
diff --git a/example/main b/example/main
index 51bb73a..14fd1e1 100755
--- a/example/main
+++ b/example/main
Binary files differ
diff --git a/example/makefile b/example/makefile
index 578059f..4a86980 100644
--- a/example/makefile
+++ b/example/makefile
@@ -1,5 +1,5 @@
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
+ 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 -lSOIL
main.o : main.cpp
g++ -c main.cpp -I/home/knolax/code/cpp/gfx -I/home/knolax/code/cpp/glgfx
clean :
diff --git a/example/textures/elev.bmp b/example/textures/elev.bmp
new file mode 100644
index 0000000..cb9fec6
--- /dev/null
+++ b/example/textures/elev.bmp
Binary files differ
diff --git a/example/textures/elev.png b/example/textures/elev.png
new file mode 100644
index 0000000..68c4308
--- /dev/null
+++ b/example/textures/elev.png
Binary files differ
diff --git a/example/textures/tex.bmp b/example/textures/tex.bmp
new file mode 100644
index 0000000..620d364
--- /dev/null
+++ b/example/textures/tex.bmp
Binary files differ
diff --git a/example/textures/tex.png b/example/textures/tex.png
new file mode 100644
index 0000000..79d9a1c
--- /dev/null
+++ b/example/textures/tex.png
Binary files differ
diff --git a/example/vertexshader.glsl b/example/vertexshader.glsl
index f60ec9f..8ba8228 100644
--- a/example/vertexshader.glsl
+++ b/example/vertexshader.glsl
@@ -5,12 +5,15 @@ uniform mat4 cam;
uniform mat4 rot;
in vec3 position;
in vec3 vnormal;
+in vec3 texcoord;
varying vec4 fragpos;
varying vec4 fragnormal; // if this needs to not be blended jsut have all vertexes in a poly be the same
+varying vec2 fragtexcoord;
void main()
{
//this is the actual position
gl_Position = proj * cam * tran * vec4(position, 1.0f);// - vec4(gl_Normal, 1.0f);
fragpos = tran * vec4(position, 1.0f);
fragnormal = (tran * vec4(vnormal, 1.0f)) - (tran * vec4(0.0, 0.0, 0.0, 1.0));
+ fragtexcoord = texcoord.xy;
}