diff --git a/Aug25_2_grahams_convex_hull/.gitignore b/Aug25_2_grahams_convex_hull/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/Aug25_2_grahams_convex_hull/.idea/.gitignore b/Aug25_2_grahams_convex_hull/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Aug25_2_grahams_convex_hull/.idea/grahams_convex_hull.iml b/Aug25_2_grahams_convex_hull/.idea/grahams_convex_hull.iml
new file mode 100644
index 0000000..9b4cf84
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/.idea/grahams_convex_hull.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Aug25_2_grahams_convex_hull/.idea/modules.xml b/Aug25_2_grahams_convex_hull/.idea/modules.xml
new file mode 100644
index 0000000..2b75b75
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Aug25_2_grahams_convex_hull/.idea/vcs.xml b/Aug25_2_grahams_convex_hull/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Aug25_2_grahams_convex_hull/Cargo.lock b/Aug25_2_grahams_convex_hull/Cargo.lock
new file mode 100644
index 0000000..8c9ea3d
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "grahams_convex_hull"
+version = "0.1.0"
diff --git a/Aug25_2_grahams_convex_hull/Cargo.toml b/Aug25_2_grahams_convex_hull/Cargo.toml
new file mode 100644
index 0000000..da6843d
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "grahams_convex_hull"
+version = "0.1.0"
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/Aug25_2_grahams_convex_hull/src/main.rs b/Aug25_2_grahams_convex_hull/src/main.rs
new file mode 100644
index 0000000..b557f87
--- /dev/null
+++ b/Aug25_2_grahams_convex_hull/src/main.rs
@@ -0,0 +1,158 @@
+use std::cmp::Ordering;
+
+fn main() {
+ let mut points: Vec = vec![
+ Point::new(0, 10),
+ Point::new(1, 18),
+ Point::new(2, 14),
+ Point::new(4, 2),
+ Point::new(5, 9),
+ Point::new(6, 13),
+ Point::new(7, 7),
+ Point::new(8, 17),
+ Point::new(9, 4),
+ Point::new(15, 11),
+ ];
+
+ let starting_point = get_starting_point(&points);
+ let initial_vector = Vector::new(0, -10);
+
+ sort_by_lexicographic_polar_sorted_order(&mut points, &starting_point, &initial_vector);
+
+ //This is the part where the convex hull problem is solved completely using angles
+
+ let mut convex_hull_stack: Vec<&Point> = Vec::new();
+
+ convex_hull_stack.push(&points[0]);
+ convex_hull_stack.push(&points[1]);
+ convex_hull_stack.push(&points[2]);
+
+ for i in 3..points.len() {
+ loop {
+ let point = &points[i];
+ let top_point = convex_hull_stack.pop().unwrap();
+ let top_point2 = *convex_hull_stack.last().unwrap();
+
+ let new_vec = point.get_relative_position(top_point2);
+ let prev_vec = top_point.get_relative_position(top_point2);
+
+ let resultant_angle = Vector::resultant_of(&new_vec, &prev_vec).angle_between(&prev_vec);
+
+ if resultant_angle > 0 as f64 {
+ convex_hull_stack.push(top_point);
+ convex_hull_stack.push(point);
+ break;
+ }
+ }
+ }
+
+
+
+ for &point in &convex_hull_stack {
+ point.print();
+ }
+}
+
+fn get_starting_point(points: &Vec) -> Point {
+ let mut starting_point: &Point = &points[0];
+ for point in points {
+ if point.x < starting_point.x {
+ starting_point = point;
+ }
+ else if point.x == starting_point.x {
+ if point.y < starting_point.y {
+ starting_point = point
+ }
+ }
+ }
+
+ Point::new(starting_point.x, starting_point.y)
+}
+
+fn sort_by_lexicographic_polar_sorted_order(points: &mut Vec, starting_point: &Point, initial_vector: &Vector) {
+ points.sort_by(|a, b| {
+ let a_angle = a.get_relative_position(starting_point).angle_between(initial_vector);
+ let b_angle = b.get_relative_position(starting_point).angle_between(initial_vector);
+ if a_angle < b_angle {
+ Ordering::Less
+ }
+ else if a_angle > b_angle {
+ Ordering::Greater
+ }
+ else {
+ Ordering::Equal
+ }
+ });
+}
+
+
+
+struct Point {
+ x: i32,
+ y: i32,
+}
+
+impl Point {
+ fn new(x: i32, y: i32) -> Point {
+ Point { x, y }
+ }
+
+ fn print(&self) {
+ println!("x: {}, y: {}", self.x, self.y);
+ }
+
+ fn distance_from(&self, other: &Point) -> f64 {
+ let x_diff = self.x - other.x;
+ let y_diff = self.y - other.y;
+ ((x_diff * x_diff + y_diff * y_diff) as f64).sqrt()
+ }
+
+ fn get_relative_position(&self, with_respect_to_point: &Point) -> Vector {
+ let x_diff = self.x - with_respect_to_point.x;
+ let y_diff = self.y - with_respect_to_point.y;
+ Vector::new(x_diff, y_diff)
+ }
+}
+
+
+
+struct Vector {
+ x: i32,
+ y: i32,
+}
+
+impl Vector {
+ fn new(x: i32, y: i32) -> Vector {
+ Vector { x, y }
+ }
+
+ fn print(&self) {
+ println!("{}i + {}j", self.x, self.y);
+ }
+
+ fn magnitude(&self) -> f64 {
+ ((self.x * self.x + self.y * self.y) as f64).sqrt()
+ }
+
+ fn dot_product(&self, other: &Vector) -> i32 {
+ self.x * other.x + self.y * other.y
+ }
+
+ fn cross_product(&self, other: &Vector) -> i32 {
+ self.x * other.y - self.y * other.x
+ }
+
+ fn angle_between(&self, other: &Vector) -> f64 {
+ let cross_product = self.cross_product(other) as f64;
+ let dot_product = self.dot_product(other) as f64;
+ //TODO: The negative sign is used to correct for some other mistake I made elsewhere (in terms of dot or cross product)
+ -cross_product.atan2(dot_product)
+ }
+
+ fn resultant_of(vec1: &Vector, vec2: &Vector) -> Vector {
+ let x_diff = vec1.x + vec2.x;
+ let y_diff = vec1.y + vec2.y;
+ Vector::new(x_diff, y_diff)
+ }
+}
+
diff --git a/FVAR_UE19CS315.sln b/FVAR_UE19CS315.sln
index 5ad4d8c..c0b5d2a 100644
--- a/FVAR_UE19CS315.sln
+++ b/FVAR_UE19CS315.sln
@@ -17,6 +17,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sep1_3_3dPolygon", "Sep1_3_
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sep6_1_OpenGLLighting", "Sep6_1_OpenGLLighting\Sep6_1_OpenGLLighting.vcxproj", "{80754C14-4419-44A8-B8AB-D2C80134B8D0}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sep8_1_InputInteractions", "Sep8_1_InputInteractions\Sep8_1_InputInteractions.vcxproj", "{4CB333BD-F2F7-4148-B62D-65F9812B790C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sep8_2_MouseCameraMovement", "Sep8_2_MouseCameraMovement\Sep8_2_MouseCameraMovement.vcxproj", "{D46AC5F2-2B67-465B-AD8C-68364918E978}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -81,6 +85,22 @@ Global
{80754C14-4419-44A8-B8AB-D2C80134B8D0}.Release|x64.Build.0 = Release|x64
{80754C14-4419-44A8-B8AB-D2C80134B8D0}.Release|x86.ActiveCfg = Release|Win32
{80754C14-4419-44A8-B8AB-D2C80134B8D0}.Release|x86.Build.0 = Release|Win32
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Debug|x64.ActiveCfg = Debug|x64
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Debug|x64.Build.0 = Debug|x64
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Debug|x86.ActiveCfg = Debug|Win32
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Debug|x86.Build.0 = Debug|Win32
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Release|x64.ActiveCfg = Release|x64
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Release|x64.Build.0 = Release|x64
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Release|x86.ActiveCfg = Release|Win32
+ {4CB333BD-F2F7-4148-B62D-65F9812B790C}.Release|x86.Build.0 = Release|Win32
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Debug|x64.ActiveCfg = Debug|x64
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Debug|x64.Build.0 = Debug|x64
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Debug|x86.ActiveCfg = Debug|Win32
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Debug|x86.Build.0 = Debug|Win32
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Release|x64.ActiveCfg = Release|x64
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Release|x64.Build.0 = Release|x64
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Release|x86.ActiveCfg = Release|Win32
+ {D46AC5F2-2B67-465B-AD8C-68364918E978}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Sep8_1_InputInteractions/Sep8_1_InputInteractions.cpp b/Sep8_1_InputInteractions/Sep8_1_InputInteractions.cpp
new file mode 100644
index 0000000..c5007f0
--- /dev/null
+++ b/Sep8_1_InputInteractions/Sep8_1_InputInteractions.cpp
@@ -0,0 +1,233 @@
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+struct GLPoint {
+ GLfloat x, y;
+};
+
+float randColorf()
+{
+ return ((float)(rand() % 100)) / 100;
+}
+
+float PI = 3.14;
+
+///
+/// ambient (r,g,b), diffuse (r,g,b), specular (r,g,b), reflectibility/shininess (0-128)
+///
+void setMaterial(
+ GLfloat ambientR, GLfloat ambientG, GLfloat ambientB,
+ GLfloat diffuseR, GLfloat diffuseG, GLfloat diffuseB,
+ GLfloat specularR, GLfloat specularG, GLfloat specularB,
+ int shine)
+{
+ ///create "vectors" from the values for the light
+ GLfloat ambient[] = { ambientR, ambientG, ambientB };
+ GLfloat diffuse[] = { diffuseR, diffuseG, diffuseB };
+ GLfloat specular[] = { specularR, specularG, specularB };
+
+ glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); //sets how ambience should work for the material
+ glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); //sets how diffuse should work for the material
+ glMaterialfv(GL_FRONT, GL_SPECULAR, specular); //sets how specular should work for the material
+ glMaterialf(GL_FRONT, GL_SHININESS, shine);
+}
+
+float zoom = 4;
+int axisX = 1, axisY = 0, axisZ = 0;
+float tX = 0, tY = 0, tZ = 0;
+float angle = 0;
+
+///
+/// a callback function that is executed at regular intervals of time registered under 'glutIdleFunc'
+///
+void timerCallBack_camera()
+{
+ angle += 0.5;
+
+ Sleep(10);
+
+ //redisplay after the paramters are changed.
+ glutPostRedisplay();
+}
+
+void display_rotating_camera_view()
+{
+ //Clear the Windows
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //you need to clear GL_DEPTH_BUFFER_BIT when depth is enabled
+
+ // Setup projection window/matrix that we will view
+ glMatrixMode(GL_PROJECTION); // Select Projection Matrix
+
+ // replace current matrix with identity matrix
+ glLoadIdentity();
+
+ //perspective graphic view for 3D - makes distant objects smaller. Includes FOV, aspect ratio, near, far [near and far are distances FROM the camera to the zNearPlane and zFarPlane]
+ gluPerspective(80, 1, 0.5, 50);
+
+
+ // Sets the modelview matrix that helps you setup the matrix that the camera will "look" at
+ glMatrixMode(GL_MODELVIEW);
+
+ glLoadIdentity();
+
+ // set the vectors as: eyePosition, lookingAtPosition, RotateCameraVector (rotates around the vector from the camera towards the point it's looking)
+ gluLookAt(zoom, zoom, zoom, 0, 0, 0, 0, 1, 0);
+
+
+ glColor3f(0, 1, 1);
+ //glRotatef(angle, axisX, axisY, axisZ);
+ glTranslatef(tX, tY, tZ);
+ //parametres: ambient (r,g,b), diffuse (r,g,b), specular (r,g,b), reflectibility/shininess (0-128)
+ setMaterial(0.2, 0.2, 0.2, 0.6, 0.6, 0.6, 0.8, 0.8, 0.8, 40); //differnet intensities of white light
+ //draw teapot
+ glutSolidTeapot(1);
+
+
+ // Insteda of glFlush(), Swap buffers are used when fast rendering of the screen needs to be done
+ // they use two beffers which are written to/rendered alternatively
+ // Only the modifed parts of one buffer as compared to the previous buffer are actually changed to save CPU/GPU
+ //(make sure you have enabled GL_)
+ glutSwapBuffers();
+}
+
+///
+///
+///
+/// The key that was pressed on the keyboard
+/// Mouse pointer position x
+/// Mouse pointer position y
+void customKeys(unsigned char key, int x, int y)
+{
+ switch (key)
+ {
+ case '-': zoom++; break;
+ case '=': zoom--; break;
+ case 'x': axisX = 1, axisY = 0, axisZ = 0;break;
+ case 'y': axisX = 0, axisY = 1, axisZ = 0;break;
+ case 'z': axisX = 0, axisY = 0, axisZ = 1;break;
+ case 'q': tZ -= 0.2; break;
+ case 'e': tZ += 0.2; break;
+ default:
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+void specialKeys(int key, int x, int y)
+{
+ switch (key)
+ {
+ case GLUT_KEY_DOWN: tY -= 0.2; break;
+ case GLUT_KEY_UP: tY += 0.2; break;
+ case GLUT_KEY_LEFT:tX -= 0.2; break;
+ case GLUT_KEY_RIGHT: tX += 0.2; break;
+ default:
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+void customMouseFunc(int button, int state, int x, int y)
+{
+ switch (button)
+ {
+
+ case GLUT_MIDDLE_BUTTON:
+ switch (state)
+ {
+ case GLUT_UP: break;
+ case GLUT_DOWN: break;
+ default:
+ break;
+ }
+ break;
+
+ case GLUT_RIGHT_BUTTON:
+ switch (state)
+ {
+ case GLUT_UP: break;
+ case GLUT_DOWN: tZ += 0.2; break;
+ default:
+ break;
+ }
+ break;
+
+ case GLUT_LEFT_BUTTON:
+ switch (state)
+ {
+ case GLUT_UP: break;
+ case GLUT_DOWN: tZ -= 0.2; break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+void customMotionFunc(int x, int y)
+{
+ cout << x << ", " << y << endl;
+}
+
+int main(int argc, char* argv[])
+{
+ // Step1: initialize GLUT using the command line parameters
+ glutInit(&argc, argv);
+
+ // Step2: Setup the size of the opengl window, display mode
+ glutInitWindowSize(640, 640);
+ glutInitWindowPosition(1400, 400);
+ //here we add depth buffer to the rgb buffer display
+ //we also enable double buffering
+ glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GL_DOUBLE);
+
+ // Step3: creating the window
+ glutCreateWindow("Open GL Lighting");
+
+ //set up lighting for the scene
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);//only enabling this
+
+ //This tells opengl to allow us to change the color of the material (without this, the lighting - GL_LIGHT0 - will result in a grayscale view)
+ glEnable(GL_COLOR_MATERIAL);
+
+ //enable depth test - do depth comparisons and update the depth buffer
+ glEnable(GL_DEPTH_TEST);
+
+ //set window background color
+ glClearColor(0, 0, 0, 0);
+
+
+ /// Step4: defining a callback function for looping into the rasterizer.
+ glutDisplayFunc(display_rotating_camera_view);
+
+ /// If you enable the timerCallBack_camera, you will see the camera rotating
+ /// define a "timer" callback function which is called over and voer again
+ glutIdleFunc(timerCallBack_camera);
+
+ //define callback for keyboard interactions
+ glutKeyboardFunc(customKeys);
+ glutSpecialFunc(specialKeys);
+
+ // define a callback for mouse event
+ glutMouseFunc(customMouseFunc);
+
+ // defining callback for mouse movement
+ glutMotionFunc(customMotionFunc);
+
+ // Step5: Telling the GLUT to loop into the callback
+ glutMainLoop();
+}
+
diff --git a/Sep8_1_InputInteractions/Sep8_1_InputInteractions.vcxproj b/Sep8_1_InputInteractions/Sep8_1_InputInteractions.vcxproj
new file mode 100644
index 0000000..c48f332
--- /dev/null
+++ b/Sep8_1_InputInteractions/Sep8_1_InputInteractions.vcxproj
@@ -0,0 +1,147 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {4cb333bd-f2f7-4148-b62d-65f9812b790c}
+ Sep81InputInteractions
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sep8_1_InputInteractions/Sep8_1_InputInteractions.vcxproj.filters b/Sep8_1_InputInteractions/Sep8_1_InputInteractions.vcxproj.filters
new file mode 100644
index 0000000..5e9d35e
--- /dev/null
+++ b/Sep8_1_InputInteractions/Sep8_1_InputInteractions.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.cpp b/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.cpp
new file mode 100644
index 0000000..edd2928
--- /dev/null
+++ b/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.cpp
@@ -0,0 +1,183 @@
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+struct GLVec {
+ GLfloat x, y, z;
+};
+
+float randColorf()
+{
+ return ((float)(rand() % 100)) / 100;
+}
+
+float PI = 3.14;
+
+///
+/// ambient (r,g,b), diffuse (r,g,b), specular (r,g,b), reflectibility/shininess (0-128)
+///
+void setMaterial(
+ GLfloat ambientR, GLfloat ambientG, GLfloat ambientB,
+ GLfloat diffuseR, GLfloat diffuseG, GLfloat diffuseB,
+ GLfloat specularR, GLfloat specularG, GLfloat specularB,
+ int shine)
+{
+ ///create "vectors" from the values for the light
+ GLfloat ambient[] = { ambientR, ambientG, ambientB };
+ GLfloat diffuse[] = { diffuseR, diffuseG, diffuseB };
+ GLfloat specular[] = { specularR, specularG, specularB };
+
+ glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); //sets how ambience should work for the material
+ glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); //sets how diffuse should work for the material
+ glMaterialfv(GL_FRONT, GL_SPECULAR, specular); //sets how specular should work for the material
+ glMaterialf(GL_FRONT, GL_SHININESS, shine);
+}
+
+float zoom = 4;
+float phi = 0, theta = PI / 2;
+
+void display_rotating_camera_view()
+{
+ //Clear the Windows
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //you need to clear GL_DEPTH_BUFFER_BIT when depth is enabled
+
+ // Setup projection window/matrix that we will view
+ glMatrixMode(GL_PROJECTION); // Select Projection Matrix
+
+ // replace current matrix with identity matrix
+ glLoadIdentity();
+
+ //perspective graphic view for 3D - makes distant objects smaller. Includes FOV, aspect ratio, near, far [near and far are distances FROM the camera to the zNearPlane and zFarPlane]
+ gluPerspective(80, 1, 0.5, 50);
+
+
+ // Sets the modelview matrix that helps you setup the matrix that the camera will "look" at
+ glMatrixMode(GL_MODELVIEW);
+
+ glLoadIdentity();
+
+ GLVec Vec = {
+ zoom * cos(phi) * sin(theta),
+ zoom * sin(phi) * sin(theta),
+ zoom * cos(theta)
+ };
+
+
+ // set the vectors as: eyePosition, lookingAtPosition, RotateCameraVector (rotates around the vector from the camera towards the point it's looking)
+ gluLookAt(Vec.x, Vec.y, Vec.z, 0, 0, 0, 0, 1, 0);
+
+ glColor3f(0, 1, 1);
+ //parametres: ambient (r,g,b), diffuse (r,g,b), specular (r,g,b), reflectibility/shininess (0-128)
+ setMaterial(0.2, 0.2, 0.2, 0.6, 0.6, 0.6, 0.8, 0.8, 0.8, 40); //differnet intensities of white light
+ //draw teapot
+ glutSolidTeapot(1);
+
+
+ // Insteda of glFlush(), Swap buffers are used when fast rendering of the screen needs to be done
+ // they use two beffers which are written to/rendered alternatively
+ // Only the modifed parts of one buffer as compared to the previous buffer are actually changed to save CPU/GPU
+ //(make sure you have enabled GL_)
+ glutSwapBuffers();
+}
+
+void customMouseFunc(int button, int state, int x, int y)
+{
+ /*switch (button)
+ {
+
+ case GLUT_MIDDLE_BUTTON:
+ switch (state)
+ {
+ case GLUT_UP: break;
+ case GLUT_DOWN: break;
+ default:
+ break;
+ }
+ break;
+
+ case GLUT_RIGHT_BUTTON:
+ switch (state)
+ {
+ case GLUT_UP: break;
+ case GLUT_DOWN: tZ += 0.2; break;
+ default:
+ break;
+ }
+ break;
+
+ case GLUT_LEFT_BUTTON:
+ switch (state)
+ {
+ case GLUT_UP: break;
+ case GLUT_DOWN: tZ -= 0.2; break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ glutPostRedisplay();*/
+}
+
+int prevX = 0, prevY = 0;
+
+void customMotionFunc(int x, int y)
+{
+ theta += (x - prevX) * PI / 180;
+ //phi += (y - prevY) * PI / 180;
+
+ glutPostRedisplay();
+
+ prevX = x;
+ prevY = y;
+}
+
+int main(int argc, char* argv[])
+{
+ // Step1: initialize GLUT using the command line parameters
+ glutInit(&argc, argv);
+
+ // Step2: Setup the size of the opengl window, display mode
+ glutInitWindowSize(640, 640);
+ glutInitWindowPosition(1400, 400);
+ //here we add depth buffer to the rgb buffer display
+ //we also enable double buffering
+ glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GL_DOUBLE);
+
+ // Step3: creating the window
+ glutCreateWindow("Open GL Lighting");
+
+ //set up lighting for the scene
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);//only enabling this
+
+ //This tells opengl to allow us to change the color of the material (without this, the lighting - GL_LIGHT0 - will result in a grayscale view)
+ glEnable(GL_COLOR_MATERIAL);
+
+ //enable depth test - do depth comparisons and update the depth buffer
+ glEnable(GL_DEPTH_TEST);
+
+ //set window background color
+ glClearColor(0, 0, 0, 0);
+
+
+ /// Step4: defining a callback function for looping into the rasterizer.
+ glutDisplayFunc(display_rotating_camera_view);
+
+ // define a callback for mouse event
+ glutMouseFunc(customMouseFunc);
+
+ // defining callback for mouse movement
+ glutMotionFunc(customMotionFunc);
+
+ // Step5: Telling the GLUT to loop into the callback
+ glutMainLoop();
+}
+
diff --git a/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.vcxproj b/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.vcxproj
new file mode 100644
index 0000000..d49db5f
--- /dev/null
+++ b/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.vcxproj
@@ -0,0 +1,147 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {d46ac5f2-2b67-465b-ad8c-68364918e978}
+ Sep82MouseCameraMovement
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.vcxproj.filters b/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.vcxproj.filters
new file mode 100644
index 0000000..d67af41
--- /dev/null
+++ b/Sep8_2_MouseCameraMovement/Sep8_2_MouseCameraMovement.vcxproj.filters
@@ -0,0 +1,22 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Source Files
+
+
+
\ No newline at end of file