Jason McKesson avatar Jason McKesson committed 7a4067e

Issue #49: Better integration with glsdk.
Uses SDK object and view poles, as well as the SDK's matrix stack.

Comments (0)

Files changed (34)

Tut 07 World in Motion/World Scene.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 static float g_fXAngle = 0.0f;
 
 //Trees are 3x3 in X/Z, and fTrunkHeight+fConeHeight in the Y.
-void DrawTree(Framework::MatrixStack &modelMatrix, float fTrunkHeight = 2.0f, float fConeHeight = 3.0f)
+void DrawTree(glutil::MatrixStack &modelMatrix, float fTrunkHeight = 2.0f, float fConeHeight = 3.0f)
 {
 	//Draw trunk.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Scale(glm::vec3(1.0f, fTrunkHeight, 1.0f));
 		modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));
 
 	//Draw the treetop
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, fTrunkHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(3.0f, fConeHeight, 3.0f));
 const float g_fColumnBaseHeight = 0.25f;
 
 //Columns are 1x1 in the X/Z, and fHieght units in the Y.
-void DrawColumn(Framework::MatrixStack &modelMatrix, float fHeight = 5.0f)
+void DrawColumn(glutil::MatrixStack &modelMatrix, float fHeight = 5.0f)
 {
 	//Draw the bottom of the column.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Scale(glm::vec3(1.0f, g_fColumnBaseHeight, 1.0f));
 		modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));
 
 	//Draw the top of the column.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, fHeight - g_fColumnBaseHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(1.0f, g_fColumnBaseHeight, 1.0f));
 
 	//Draw the main column.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, g_fColumnBaseHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(0.8f, fHeight - (g_fColumnBaseHeight * 2.0f), 0.8f));
 const float g_fParthenonBaseHeight = 1.0f;
 const float g_fParthenonTopHeight = 2.0f;
 
-void DrawParthenon(Framework::MatrixStack &modelMatrix)
+void DrawParthenon(glutil::MatrixStack &modelMatrix)
 {
 	//Draw base.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Scale(glm::vec3(g_fParthenonWidth, g_fParthenonBaseHeight, g_fParthenonLength));
 		modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));
 
 	//Draw top.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, g_fParthenonColumnHeight + g_fParthenonBaseHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(g_fParthenonWidth, g_fParthenonTopHeight, g_fParthenonLength));
 	for(int iColumnNum = 0; iColumnNum < int(g_fParthenonWidth / 2.0f); iColumnNum++)
 	{
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3((2.0f * iColumnNum) - (g_fParthenonWidth / 2.0f) + 1.0f,
 				g_fParthenonBaseHeight, fFrontZVal));
 
 			DrawColumn(modelMatrix, g_fParthenonColumnHeight);
 		}
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3((2.0f * iColumnNum) - (g_fParthenonWidth / 2.0f) + 1.0f,
 				g_fParthenonBaseHeight, -fFrontZVal));
 
 	for(int iColumnNum = 1; iColumnNum < int((g_fParthenonLength - 2.0f) / 2.0f); iColumnNum++)
 	{
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3(fRightXVal,
 				g_fParthenonBaseHeight, (2.0f * iColumnNum) - (g_fParthenonLength / 2.0f) + 1.0f));
 
 			DrawColumn(modelMatrix, g_fParthenonColumnHeight);
 		}
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3(-fRightXVal,
 				g_fParthenonBaseHeight, (2.0f * iColumnNum) - (g_fParthenonLength / 2.0f) + 1.0f));
 
 
 	//Draw interior.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, 1.0f, 0.0f));
 		modelMatrix.Scale(glm::vec3(g_fParthenonWidth - 6.0f, g_fParthenonColumnHeight,
 
 	//Draw headpiece.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(
 			0.0f,
 	{25.0f, 45.0f, 2.0f, 3.0f},
 };
 
-void DrawForest(Framework::MatrixStack &modelMatrix)
+void DrawForest(glutil::MatrixStack &modelMatrix)
 {
 	for(int iTree = 0; iTree < ARRAY_COUNT(g_forest); iTree++)
 	{
 		const TreeData &currTree = g_forest[iTree];
 
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 		modelMatrix.Translate(glm::vec3(currTree.fXPos, 0.0f, currTree.fZPos));
 		DrawTree(modelMatrix, currTree.fTrunkHeight, currTree.fConeHeight);
 	}
 
 glm::vec3 ResolveCamPosition()
 {
-	Framework::MatrixStack tempMat;
+	glutil::MatrixStack tempMat;
 
 	float phi = Framework::DegToRad(g_sphereCamRelPos.x);
 	float theta = Framework::DegToRad(g_sphereCamRelPos.y + 90.0f);
 	{
 		const glm::vec3 &camPos = ResolveCamPosition();
 
-		Framework::MatrixStack camMatrix;
+		glutil::MatrixStack camMatrix;
 		camMatrix.SetMatrix(CalcLookAtMatrix(camPos, g_camTarget, glm::vec3(0.0f, 1.0f, 0.0f)));
 
 		glUseProgram(UniformColor.theProgram);
 		glUniformMatrix4fv(UniformColorTint.worldToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(camMatrix.Top()));
 		glUseProgram(0);
 
-		Framework::MatrixStack modelMatrix;
+		glutil::MatrixStack modelMatrix;
 
 		//Render the ground plane.
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			modelMatrix.Scale(glm::vec3(100.0f, 1.0f, 100.0f));
 
 
 		//Draw the building.
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3(20.0f, 0.0f, -10.0f));
 
 			DrawParthenon(modelMatrix);
 			glDisable(GL_DEPTH_TEST);
 			glm::mat4 idenity(1.0f);
 
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			glm::vec3 cameraAimVec = g_camTarget - camPos;
 			modelMatrix.Translate(0.0f, 0.0, -glm::length(cameraAimVec));
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	glUseProgram(UniformColor.theProgram);
 	glUniformMatrix4fv(UniformColor.cameraToClipMatrixUnif, 1, GL_FALSE, glm::value_ptr(persMatrix.Top()));

Tut 07 World in Motion/World With UBO.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 static float g_fXAngle = 0.0f;
 
 //Trees are 3x3 in X/Z, and fTrunkHeight+fConeHeight in the Y.
-void DrawTree(Framework::MatrixStack &modelMatrix, float fTrunkHeight = 2.0f, float fConeHeight = 3.0f)
+void DrawTree(glutil::MatrixStack &modelMatrix, float fTrunkHeight = 2.0f, float fConeHeight = 3.0f)
 {
 	//Draw trunk.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Scale(glm::vec3(1.0f, fTrunkHeight, 1.0f));
 		modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));
 
 	//Draw the treetop
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, fTrunkHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(3.0f, fConeHeight, 3.0f));
 const float g_fColumnBaseHeight = 0.25f;
 
 //Columns are 1x1 in the X/Z, and fHieght units in the Y.
-void DrawColumn(Framework::MatrixStack &modelMatrix, float fHeight = 5.0f)
+void DrawColumn(glutil::MatrixStack &modelMatrix, float fHeight = 5.0f)
 {
 	//Draw the bottom of the column.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Scale(glm::vec3(1.0f, g_fColumnBaseHeight, 1.0f));
 		modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));
 
 	//Draw the top of the column.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, fHeight - g_fColumnBaseHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(1.0f, g_fColumnBaseHeight, 1.0f));
 
 	//Draw the main column.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, g_fColumnBaseHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(0.8f, fHeight - (g_fColumnBaseHeight * 2.0f), 0.8f));
 const float g_fParthenonBaseHeight = 1.0f;
 const float g_fParthenonTopHeight = 2.0f;
 
-void DrawParthenon(Framework::MatrixStack &modelMatrix)
+void DrawParthenon(glutil::MatrixStack &modelMatrix)
 {
 	//Draw base.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Scale(glm::vec3(g_fParthenonWidth, g_fParthenonBaseHeight, g_fParthenonLength));
 		modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));
 
 	//Draw top.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, g_fParthenonColumnHeight + g_fParthenonBaseHeight, 0.0f));
 		modelMatrix.Scale(glm::vec3(g_fParthenonWidth, g_fParthenonTopHeight, g_fParthenonLength));
 	for(int iColumnNum = 0; iColumnNum < int(g_fParthenonWidth / 2.0f); iColumnNum++)
 	{
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3((2.0f * iColumnNum) - (g_fParthenonWidth / 2.0f) + 1.0f,
 				g_fParthenonBaseHeight, fFrontZVal));
 
 			DrawColumn(modelMatrix, g_fParthenonColumnHeight);
 		}
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3((2.0f * iColumnNum) - (g_fParthenonWidth / 2.0f) + 1.0f,
 				g_fParthenonBaseHeight, -fFrontZVal));
 
 	for(int iColumnNum = 1; iColumnNum < int((g_fParthenonLength - 2.0f) / 2.0f); iColumnNum++)
 	{
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3(fRightXVal,
 				g_fParthenonBaseHeight, (2.0f * iColumnNum) - (g_fParthenonLength / 2.0f) + 1.0f));
 
 			DrawColumn(modelMatrix, g_fParthenonColumnHeight);
 		}
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3(-fRightXVal,
 				g_fParthenonBaseHeight, (2.0f * iColumnNum) - (g_fParthenonLength / 2.0f) + 1.0f));
 
 
 	//Draw interior.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(0.0f, 1.0f, 0.0f));
 		modelMatrix.Scale(glm::vec3(g_fParthenonWidth - 6.0f, g_fParthenonColumnHeight,
 
 	//Draw headpiece.
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		modelMatrix.Translate(glm::vec3(
 			0.0f,
 	{25.0f, 45.0f, 2.0f, 3.0f},
 };
 
-void DrawForest(Framework::MatrixStack &modelMatrix)
+void DrawForest(glutil::MatrixStack &modelMatrix)
 {
 	for(int iTree = 0; iTree < ARRAY_COUNT(g_forest); iTree++)
 	{
 		const TreeData &currTree = g_forest[iTree];
 
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 		modelMatrix.Translate(glm::vec3(currTree.fXPos, 0.0f, currTree.fZPos));
 		DrawTree(modelMatrix, currTree.fTrunkHeight, currTree.fConeHeight);
 	}
 
 glm::vec3 ResolveCamPosition()
 {
-	Framework::MatrixStack tempMat;
+	glutil::MatrixStack tempMat;
 
 	float phi = Framework::DegToRad(g_sphereCamRelPos.x);
 	float theta = Framework::DegToRad(g_sphereCamRelPos.y + 90.0f);
 	{
 		const glm::vec3 &camPos = ResolveCamPosition();
 
-		Framework::MatrixStack camMatrix;
+		glutil::MatrixStack camMatrix;
 		camMatrix.SetMatrix(CalcLookAtMatrix(camPos, g_camTarget, glm::vec3(0.0f, 1.0f, 0.0f)));
 
 		glBindBuffer(GL_UNIFORM_BUFFER, g_GlobalMatricesUBO);
 		glBufferSubData(GL_UNIFORM_BUFFER, sizeof(glm::mat4), sizeof(glm::mat4), glm::value_ptr(camMatrix.Top()));
 		glBindBuffer(GL_UNIFORM_BUFFER, 0);
 
-		Framework::MatrixStack modelMatrix;
+		glutil::MatrixStack modelMatrix;
 
 		//Render the ground plane.
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			modelMatrix.Scale(glm::vec3(100.0f, 1.0f, 100.0f));
 
 
 		//Draw the building.
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 			modelMatrix.Translate(glm::vec3(20.0f, 0.0f, -10.0f));
 
 			DrawParthenon(modelMatrix);
 		{
 			glDisable(GL_DEPTH_TEST);
 
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			modelMatrix.Translate(g_camTarget);
 			modelMatrix.Scale(1.0f, 1.0f, 1.0f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	glBindBuffer(GL_UNIFORM_BUFFER, g_GlobalMatricesUBO);
 	glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(glm::mat4), glm::value_ptr(persMatrix.Top()));

Tut 08 Getting Oriented/CameraRelative.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 
 glm::vec3 ResolveCamPosition()
 {
-	Framework::MatrixStack tempMat;
+	glutil::MatrixStack tempMat;
 
 	float phi = Framework::DegToRad(g_sphereCamRelPos.x);
 	float theta = Framework::DegToRad(g_sphereCamRelPos.y + 90.0f);
 	glClearDepth(1.0f);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	Framework::MatrixStack currMatrix;
+	glutil::MatrixStack currMatrix;
 	const glm::vec3 &camPos = ResolveCamPosition();
 	currMatrix.SetMatrix(CalcLookAtMatrix(camPos, g_camTarget, glm::vec3(0.0f, 1.0f, 0.0f)));
 
 	glUseProgram(theProgram);
 
 	{
-		Framework::MatrixStackPusher stack(currMatrix);
+		glutil::PushStack stack(currMatrix);
 		currMatrix.Scale(100.0f, 1.0f, 100.0f);
 
 		glUniform4f(baseColorUnif, 0.2f, 0.5f, 0.2f, 1.0f);
 	}
 
 	{
-		Framework::MatrixStackPusher stack(currMatrix);
+		glutil::PushStack stack(currMatrix);
 		currMatrix.Translate(g_camTarget);
 		currMatrix.ApplyMatrix(glm::mat4_cast(g_orientation));
 		currMatrix.RotateX(-90);

Tut 08 Getting Oriented/GimbalLock.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 
 bool g_bDrawGimbals = true;
 
-void DrawGimbal(Framework::MatrixStack &currMatrix, GimbalAxis eAxis, glm::vec4 baseColor)
+void DrawGimbal(glutil::MatrixStack &currMatrix, GimbalAxis eAxis, glm::vec4 baseColor)
 {
 	if(!g_bDrawGimbals)
 		return;
 
-	Framework::MatrixStackPusher pusher(currMatrix);
+	glutil::PushStack pusher(currMatrix);
 
 	switch(eAxis)
 	{
 	glClearDepth(1.0f);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	Framework::MatrixStack currMatrix;
+	glutil::MatrixStack currMatrix;
 	currMatrix.Translate(glm::vec3(0.0f, 0.0f, -200.0f));
 	currMatrix.RotateX(g_angles.fAngleX);
 	DrawGimbal(currMatrix, GIMBAL_X_AXIS, glm::vec4(0.4f, 0.4f, 1.0f, 1.0f));

Tut 08 Getting Oriented/Interpolation.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 	glClearDepth(1.0f);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	Framework::MatrixStack currMatrix;
+	glutil::MatrixStack currMatrix;
 	currMatrix.Translate(glm::vec3(0.0f, 0.0f, -200.0f));
 	currMatrix.ApplyMatrix(glm::mat4_cast(g_orient.GetOrient()));
 

Tut 08 Getting Oriented/QuaternionYPR.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 	glClearDepth(1.0f);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	Framework::MatrixStack currMatrix;
+	glutil::MatrixStack currMatrix;
 	currMatrix.Translate(glm::vec3(0.0f, 0.0f, -200.0f));
 	currMatrix.ApplyMatrix(glm::mat4_cast(g_orientation));
 

Tut 09 Lights on/Ambient Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 
 Framework::Mesh *g_pCylinderMesh = NULL;
 Framework::Mesh *g_pPlaneMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 20.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
 	if(g_pPlaneMesh && g_pCylinderMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection;
 
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glUseProgram(whiteDiffuse.theProgram);
 				glUniformMatrix4fv(whiteDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bDrawColoredCyl)
 				{
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 09 Lights on/Basic Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 
 
 Framework::Mesh *g_pCylinderMesh = NULL;
 Framework::Mesh *g_pPlaneMesh = NULL;
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 20.0f, 1.5f, 0.5f};
 
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
 	if(g_pPlaneMesh && g_pCylinderMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection;
 
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glUseProgram(g_WhiteDiffuseColor.theProgram);
 				glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bDrawColoredCyl)
 				{
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 09 Lights on/Scale and Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 
 
 Framework::Mesh *g_pCylinderMesh = NULL;
 Framework::Mesh *g_pPlaneMesh = NULL;
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 20.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
+
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
 	if(g_pPlaneMesh && g_pCylinderMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection;
 
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glUseProgram(g_WhiteDiffuseColor.theProgram);
 				glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bScaleCyl)
 					modelMatrix.Scale(1.0f, 1.0f, 0.2f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 10 Plane Lights/Fragment Attenuation.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 Framework::Mesh *g_pPlaneMesh = NULL;
 Framework::Mesh *g_pCubeMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 200.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
 	if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		const glm::vec4 &worldLightPos = CalcLightPosition();
 		const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glm::mat3 normMatrix(modelMatrix.Top());
 				normMatrix = glm::transpose(glm::inverse(normMatrix));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bScaleCyl)
 					modelMatrix.Scale(1.0f, 1.0f, 0.2f);
 			//Render the light
 			if(g_bDrawLight)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(glm::vec3(worldLightPos));
 				modelMatrix.Scale(0.1f, 0.1f, 0.1f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 10 Plane Lights/Fragment Point Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 Framework::Mesh *g_pPlaneMesh = NULL;
 Framework::Mesh *g_pCubeMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 200.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
 	if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		const glm::vec4 &worldLightPos = CalcLightPosition();
 
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glUseProgram(pWhiteProgram->theProgram);
 				glUniformMatrix4fv(pWhiteProgram->modelToCameraMatrixUnif, 1, GL_FALSE,
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bScaleCyl)
 					modelMatrix.Scale(1.0f, 1.0f, 0.2f);
 			//Render the light
 			if(g_bDrawLight)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(glm::vec3(worldLightPos));
 				modelMatrix.Scale(0.1f, 0.1f, 0.1f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 10 Plane Lights/Vertex Point Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 Framework::Mesh *g_pPlaneMesh = NULL;
 Framework::Mesh *g_pCubeMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 20.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
+
 GLuint g_projectionUniformBuffer = 0;
 
 struct ProjectionBlock
 
 	if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		const glm::vec4 &worldLightPos = CalcLightPosition();
 
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glUseProgram(g_WhiteDiffuseColor.theProgram);
 				glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE,
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bDrawColoredCyl)
 				{
 			//Render the light
 			if(g_bDrawLight)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(glm::vec3(worldLightPos));
 				modelMatrix.Scale(0.1f, 0.1f, 0.1f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 11 Shinies/Blinn vs Phong Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 Framework::Mesh *g_pPlaneMesh = NULL;
 Framework::Mesh *g_pCubeMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 200.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
+
 GLuint g_projectionUniformBuffer = 0;
 
 struct ProjectionBlock
 
 	if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		const glm::vec4 &worldLightPos = CalcLightPosition();
 		const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glm::mat3 normMatrix(modelMatrix.Top());
 				normMatrix = glm::transpose(glm::inverse(normMatrix));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bScaleCyl)
 					modelMatrix.Scale(1.0f, 1.0f, 0.2f);
 			//Render the light
 			if(g_bDrawLightSource)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(glm::vec3(worldLightPos));
 				modelMatrix.Scale(0.1f, 0.1f, 0.1f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 11 Shinies/Gaussian Specular Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 Framework::Mesh *g_pPlaneMesh = NULL;
 Framework::Mesh *g_pCubeMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 200.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
+
 GLuint g_projectionUniformBuffer = 0;
 
 struct ProjectionBlock
 
 	if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		const glm::vec4 &worldLightPos = CalcLightPosition();
 		const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glm::mat3 normMatrix(modelMatrix.Top());
 				normMatrix = glm::transpose(glm::inverse(normMatrix));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bScaleCyl)
 					modelMatrix.Scale(1.0f, 1.0f, 0.2f);
 			//Render the light
 			if(g_bDrawLightSource)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(glm::vec3(worldLightPos));
 				modelMatrix.Scale(0.1f, 0.1f, 0.1f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 11 Shinies/Phong Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 Framework::Mesh *g_pPlaneMesh = NULL;
 Framework::Mesh *g_pCubeMesh = NULL;
 
-Framework::RadiusDef radiusDef = {5.0f, 3.0f, 200.0f, 1.5f, 0.5f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 0.5f, 0.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	5.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
-Framework::ObjectPole g_objectPole(objectCenter, &g_mousePole);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 20.0f,
+	1.5f, 0.5f,
+	0.0f, 0.0f,		//No camera movement.
+	90.0f/250.0f
+};
+
+glutil::ObjectData g_initialObjectData =
+{
+	glm::vec3(0.0f, 0.5f, 0.0f),
+	glm::fquat(1.0f, 0.0f, 0.0f, 0.0f),
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
+glutil::ObjectPole g_objtPole = glutil::ObjectPole(g_initialObjectData,
+												   90.0f/250.0f, glutil::MB_RIGHT_BTN, &g_viewPole);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
-		g_objectPole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
+		Framework::ForwardMouseMotion(g_objtPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
+		Framework::ForwardMouseButton(g_objtPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
-		g_objectPole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
+		Framework::ForwardMouseWheel(g_objtPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 
 	if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
 	{
-		Framework::MatrixStack modelMatrix;
-		modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+		glutil::MatrixStack modelMatrix;
+		modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 		const glm::vec4 &worldLightPos = CalcLightPosition();
 		const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
 		glUseProgram(0);
 
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			//Render the ground plane.
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				glm::mat3 normMatrix(modelMatrix.Top());
 				normMatrix = glm::transpose(glm::inverse(normMatrix));
 
 			//Render the Cylinder
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
-				modelMatrix.ApplyMatrix(g_objectPole.CalcMatrix());
+				modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
 
 				if(g_bScaleCyl)
 					modelMatrix.Scale(1.0f, 1.0f, 0.2f);
 			//Render the light
 			if(g_bDrawLightSource)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(glm::vec3(worldLightPos));
 				modelMatrix.Scale(0.1f, 0.1f, 0.1f);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();

Tut 12 Dynamic Range/Gamma Correction.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>
 
 LightManager g_lights;
 
-Framework::RadiusDef radiusDef = {50.0f, 3.0f, 80.0f, 4.0f, 1.0f};
-glm::vec3 objectCenter = glm::vec3(-59.5f, 44.0f, 95.0f);
+///////////////////////////////////////////////
+// View/Object Setup
+glutil::ViewData g_initialViewData =
+{
+	glm::vec3(-59.5f, 44.0f, 95.0f),
+	glm::fquat(0.92387953f, 0.3826834f, 0.0f, 0.0f),
+	50.0f,
+	0.0f
+};
 
-Framework::MousePole g_mousePole(objectCenter, radiusDef);
+glutil::ViewScale g_viewScale =
+{
+	3.0f, 80.0f,
+	4.0f, 1.0f,
+	5.0f, 1.0f,
+	90.0f/250.0f
+};
+
+glutil::ViewPole g_viewPole = glutil::ViewPole(g_initialViewData,
+											   g_viewScale, glutil::MB_LEFT_BTN);
 
 namespace
 {
 	void MouseMotion(int x, int y)
 	{
-		g_mousePole.GLUTMouseMove(glm::ivec2(x, y));
+		Framework::ForwardMouseMotion(g_viewPole, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseButton(int button, int state, int x, int y)
 	{
-		g_mousePole.GLUTMouseButton(button, state, glm::ivec2(x, y));
+		Framework::ForwardMouseButton(g_viewPole, button, state, x, y);
 		glutPostRedisplay();
 	}
 
 	void MouseWheel(int wheel, int direction, int x, int y)
 	{
-		g_mousePole.GLUTMouseWheel(direction, glm::ivec2(x, y));
+		Framework::ForwardMouseWheel(g_viewPole, wheel, direction, x, y);
 		glutPostRedisplay();
 	}
 }
 	glClearDepth(1.0f);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-	Framework::MatrixStack modelMatrix;
-	modelMatrix.SetMatrix(g_mousePole.CalcMatrix());
+	glutil::MatrixStack modelMatrix;
+	modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
 
 	const glm::mat4 &worldToCamMat = modelMatrix.Top();
 	LightBlockGamma lightData = g_lights.GetLightInformationGamma(worldToCamMat);
 
 	if(g_pScene)
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 
 		g_pScene->Draw(modelMatrix, g_materialBlockIndex, g_lights.GetTimerValue("tetra"));
 	}
 
 	{
-		Framework::MatrixStackPusher push(modelMatrix);
+		glutil::PushStack push(modelMatrix);
 		//Render the sun
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			glm::vec3 sunlightDir(g_lights.GetSunlightDirection());
 			modelMatrix.Translate(sunlightDir * 500.0f);
 		{
 			for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++)
 			{
-				Framework::MatrixStackPusher push(modelMatrix);
+				glutil::PushStack push(modelMatrix);
 
 				modelMatrix.Translate(g_lights.GetWorldLightPosition(light));
 
 
 		if(g_bDrawCameraPos)
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			glutil::PushStack push(modelMatrix);
 
 			modelMatrix.SetIdentity();
-			modelMatrix.Translate(glm::vec3(0.0f, 0.0f, -g_mousePole.GetLookAtDistance()));
+			modelMatrix.Translate(glm::vec3(0.0f, 0.0f, -g_viewPole.GetView().radius));
 
 			glDisable(GL_DEPTH_TEST);
 			glDepthMask(GL_FALSE);
 //This is an opportunity to call glViewport or glScissor to keep up with the change in size.
 void reshape (int w, int h)
 {
-	Framework::MatrixStack persMatrix;
-	persMatrix.Perspective(45.0f, (h / (float)w), g_fzNear, g_fzFar);
+	glutil::MatrixStack persMatrix;
+	persMatrix.Perspective(45.0f, (w / (float)h), g_fzNear, g_fzFar);
 
 	ProjectionBlock projData;
 	projData.cameraToClipMatrix = persMatrix.Top();
 		break;
 	}
 
-	g_mousePole.GLUTKeyOffset(key, 5.0f, 1.0f);
+	g_viewPole.CharPress(key);
 }
 
 

Tut 12 Dynamic Range/HDR Lighting.cpp

 #include <math.h>
 #include <stdio.h>
 #include <glload/gl_3_3.h>
+#include <glutil/glutil.h>
 #include <GL/freeglut.h>
 #include "../framework/framework.h"
 #include "../framework/Mesh.h"
 #include "../framework/MatrixStack.h"
 #include "../framework/MousePole.h"
-#include "../framework/ObjectPole.h"
 #include "../framework/Timer.h"
 #include <glm/glm.hpp>
 #include <glm/gtc/type_ptr.hpp>