summaryrefslogtreecommitdiff
path: root/glgfx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'glgfx.cpp')
-rw-r--r--glgfx.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/glgfx.cpp b/glgfx.cpp
index 7b54254..f3cdec9 100644
--- a/glgfx.cpp
+++ b/glgfx.cpp
@@ -11,6 +11,7 @@ GLint rothandler;
GLint camhandler;
GLint camposhandler;
GLint lightposhandler;
+GLint lightattribhandler;
//device coordinates
// ^
// (y+)
@@ -211,6 +212,7 @@ int genshaders() {
rothandler = glGetUniformLocation(shaderprogramhandle, "rot");
lightposhandler = glGetUniformLocation(shaderprogramhandle, "lightpos");
camposhandler = glGetUniformLocation(shaderprogramhandle, "campos");
+ lightattribhandler = glGetUniformLocation(shaderprogramhandle, "lightattrib");
}
//opens a filebuffer stream and reads every char
std::string readfile(char const * filename) {
@@ -237,13 +239,14 @@ int setcam (float cpx, float cpy, float cpz, float clx, float cly, float clz, fl
glUniform3fv(camposhandler, 1, glm::value_ptr(glm::vec3(cpx,cpy,cpz)));
return 0;
}
-int setlight (float x, float y, float z) {
- glUniform3fv(camposhandler, 1, glm::value_ptr(glm::vec3(x,y,z)));
+int setlight (float x, float y, float z, float r, float g, float b, float lim) {
+ glUniform3fv(lightposhandler, 1, glm::value_ptr(glm::vec3(x,y,z)));
+ glUniform4fv(lightattribhandler, 1, glm::value_ptr(glm::vec4(r,g,b,lim)));
return 0;
}
//draws the model, setting perspective transform and position transform
//done with magic numbers for now for testing purposes
-int drawmodel(float x, float y, float z, float xr, float yr, float zr, float s) {
+int drawmodel(float x, float y, float z, float xr, float yr, float zr, float xs, float ys, float zs) {
// the transformation matrix = rotation matrix of object * scaling matrix * translaton matrix representing difference in camera and object location * -rotation matrix of the camera * perspective transform
//order of application ir right to left
//fov, aspect ratio, size of near and far planes distance
@@ -258,12 +261,12 @@ int drawmodel(float x, float y, float z, float xr, float yr, float zr, float s)
// glm::vec4(0.0f,0.0f,0.5f,1.0f) //w just make it 1
//);
//the translation matrix, matrixes added last are applied first
- glm::mat4 tran;
- tran = glm::scale(tran, glm::vec3(s,s,s));
+ glm::mat4 tran;
tran = glm::translate(tran, glm::vec3(x,y,z));
tran = glm::rotate(tran,glm::radians(xr),glm::vec3(1,0,0)); // axis of rotation x y z
tran = glm::rotate(tran,glm::radians(yr),glm::vec3(0,1,0));
tran = glm::rotate(tran,glm::radians(zr),glm::vec3(0,0,1));
+ tran = glm::scale(tran, glm::vec3(xs, ys, zs));
glm::mat4 rot;
rot = glm::rotate(rot,glm::radians(xr),glm::vec3(1,0,0)); // axis of rotation x y z
rot = glm::rotate(rot,glm::radians(yr),glm::vec3(0,1,0));