Commits

Jason McKesson committed 46630d4

Various fixes. Particularly close-based fixes.
Tut13: Fixed the geometry impostor, an ATI bug wasn't really fixed.

  • Participants
  • Parent commits 6778295

Comments (0)

Files changed (7)

File Tut 12 Dynamic Range/Gamma Correction.cpp

 //If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function.
 void display()
 {
+    if(!g_pScene)
+        return;
+
 	g_lights.UpdateTime();
 
 	float gamma = g_isGammaCorrect ? g_gammaValue : 1.0f;
 
 //Called whenever a key on the keyboard was pressed.
 //The key is given by the ''key'' parameter, which is in ASCII.
-//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to 
+//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to
 //exit the program.
 void keyboard(unsigned char key, int x, int y)
 {
 		g_pScene = NULL;
 		glutLeaveMainLoop();
 		return;
-		
+
 	case 'p': g_lights.TogglePause(g_eTimerMode); break;
 	case '-': g_lights.RewindTime(g_eTimerMode, 1.0f); break;
 	case '=': g_lights.FastForwardTime(g_eTimerMode, 1.0f); break;

File Tut 13 Impostors/GeomImpostor.cpp

 	PerLight lights[NUMBER_OF_LIGHTS];
 };
 
-struct MaterialBlock
+struct MaterialEntry
 {
 	glm::vec4 diffuseColor;
 	glm::vec4 specularColor;
 
 void CreateMaterials()
 {
-	std::vector<MaterialBlock> ubArray(NUMBER_OF_SPHERES);
+	std::vector<MaterialEntry> ubArray(NUMBER_OF_SPHERES);
 
 	ubArray[0].diffuseColor = glm::vec4(0.1f, 0.1f, 0.8f, 1.0f);
 	ubArray[0].specularColor = glm::vec4(0.8f, 0.8f, 0.8f, 1.0f);
 	glGenBuffers(1, &g_materialArrayUniformBuffer);
 	glGenBuffers(1, &g_materialTerrainUniformBuffer);
 	glBindBuffer(GL_UNIFORM_BUFFER, g_materialArrayUniformBuffer);
-	glBufferData(GL_UNIFORM_BUFFER, sizeof(MaterialBlock) * ubArray.size(), &ubArray[0], GL_STATIC_DRAW);
+	glBufferData(GL_UNIFORM_BUFFER, sizeof(MaterialEntry) * ubArray.size(), &ubArray[0], GL_STATIC_DRAW);
 
 	glBindBuffer(GL_UNIFORM_BUFFER, g_materialTerrainUniformBuffer);
-	MaterialBlock mtl;
+	MaterialEntry mtl;
 	mtl.diffuseColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
 	mtl.specularColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
 	mtl.specularShininess = 0.6f;
-	glBufferData(GL_UNIFORM_BUFFER, sizeof(MaterialBlock), &mtl, GL_STATIC_DRAW);
+	glBufferData(GL_UNIFORM_BUFFER, sizeof(MaterialEntry), &mtl, GL_STATIC_DRAW);
 
 	glBindBuffer(GL_UNIFORM_BUFFER, 0);
 }
 
 		{
 			glBindBufferRange(GL_UNIFORM_BUFFER, g_materialBlockIndex, g_materialTerrainUniformBuffer,
-				0, sizeof(MaterialBlock));
+				0, sizeof(MaterialEntry));
 
 			glm::mat3 normMatrix(modelMatrix.Top());
 			normMatrix = glm::transpose(glm::inverse(normMatrix));
 
 		{
 			glBindBufferRange(GL_UNIFORM_BUFFER, g_materialBlockIndex, g_materialArrayUniformBuffer,
-				0, sizeof(MaterialBlock) * NUMBER_OF_SPHERES);
-			
+				0, sizeof(MaterialEntry) * NUMBER_OF_SPHERES);
+
 			glUseProgram(g_litImpProg.theProgram);
 			glBindVertexArray(g_imposterVAO);
 			glDrawArrays(GL_POINTS, 0, NUMBER_OF_SPHERES);
 
 //Called whenever a key on the keyboard was pressed.
 //The key is given by the ''key'' parameter, which is in ASCII.
-//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to 
+//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to
 //exit the program.
 void keyboard(unsigned char key, int x, int y)
 {

File Tut 13 Impostors/data/GeomImpostor.frag

 {
 	vec4 diffuseColor;
 	vec4 specularColor;
-	float specularShininess;
+	vec4 specularShininess;		//ATI Array Bug fix. Not really a vec4.
 };
 
 const int NUMBER_OF_SPHERES = 4;
 	
 	vec3 halfAngle = normalize(lightDir + viewDirection);
 	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
-	float exponent = angleNormalHalf / material.specularShininess;
+	float exponent = angleNormalHalf / material.specularShininess.x;
 	exponent = -(exponent * exponent);
 	float gaussianTerm = exp(exponent);
 

File Tut 16 Gamma and Textures/Gamma Landscape.cpp

 //If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function.
 void display()
 {
+    if(!g_pLightEnv)
+        return;
+
 	if(g_useGammaDisplay)
 		glEnable(GL_FRAMEBUFFER_SRGB);
 	else
 
 //Called whenever a key on the keyboard was pressed.
 //The key is given by the ''key'' parameter, which is in ASCII.
-//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to 
+//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to
 //exit the program.
 void keyboard(unsigned char key, int x, int y)
 {

File Tut 16 Gamma and Textures/GammaRamp.cpp

 
 #include <string>
+#include <memory>
 #include <vector>
 #include <math.h>
 #include <stdio.h>
 			pxTrans.format, pxTrans.type, image.GetImageData());
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
 		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, pImageSet->GetMipmapCount() - 1);
-		
+
 		glBindTexture(GL_TEXTURE_2D, g_textures[1]);
 		glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8, dims.width, dims.height, 0,
 			pxTrans.format, pxTrans.type, image.GetImageData());
 
 //Called whenever a key on the keyboard was pressed.
 //The key is given by the ''key'' parameter, which is in ASCII.
-//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to 
+//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to
 //exit the program.
 void keyboard(unsigned char key, int x, int y)
 {

File Tut 16 Gamma and Textures/LightEnv.cpp

 
+#include <exception>
+#include <stdexcept>
 #include <algorithm>
 #include <fstream>
 #include <sstream>

File framework/framework.lua

 		
 		files {...}
 
-		UseLibs(usedLibs)
-
 		includedirs {"../tinyxml", "../framework"}
 			
 		links "framework"
 
+		--Must be after including framwork... because GCC is stupid.
+		UseLibs(usedLibs)
+
 		configuration "Debug"
 			defines {"DEBUG", "_DEBUG"}
 			flags "Symbols"