Source

gltut / Tut 18 Bumpy Textures / Bumpy Square.cpp

Diff from to

Tut 18 Bumpy Textures/Bumpy Square.cpp

 GLuint g_unlitProg;
 Framework::Mesh *g_pSphereMesh = NULL;
 Framework::NodeRef g_bumpMapNode;
+Framework::NodeRef g_highPolyNode;
 
 
 
 	SetStateBinderWithNodes(nodes, g_lightNumBinder);
 
 	Framework::NodeRef bumpMapNode = pScene->FindNode("object");
+	Framework::NodeRef highPolyNode = pScene->FindNode("high_poly");
 	
 	GLuint unlit = pScene->FindProgram("p_unlit");
 	Framework::Mesh *pSphereMesh = pScene->FindMesh("m_sphere");
 	g_unlitModelToCameraMatrixUnif = glGetUniformLocation(unlit, "modelToCameraMatrix");
 	g_unlitObjectColorUnif = glGetUniformLocation(unlit, "objectColor");
 	g_bumpMapNode = bumpMapNode;
+	g_highPolyNode = highPolyNode;
 
 	std::swap(nodes, g_nodes);
 	nodes.clear();	//If something was there already, delete it.
 bool g_bDrawCameraPos = false;
 bool g_bDrawLightPos = true;
 bool g_bLongLightRange = false;
+bool g_bDrawBumpmap = true;
 
 int g_displayWidth = 500;
 int g_displayHeight = 500;
 	glBufferData(GL_UNIFORM_BUFFER, sizeof(LightBlock), &lightData, GL_STREAM_DRAW);
 }
 
+std::string GetRenderName()
+{
+	if(g_bDrawBumpmap)
+		return "bump_regular";
+	else
+		return "high_regular";
+}
+
 //Called to update the display.
 //You should call glutSwapBuffers after all of your rendering to display what you rendered.
 //If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function.
 			glm::vec4(0.0f, 0.0f, 1.0f, 0.0f),
 			glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
 		g_bumpMapNode.SetNodePreTransform(temp);
+		g_highPolyNode.SetNodePreTransform(temp);
 	}
 
-	g_pScene->Render(modelMatrix.Top());
+	g_pScene->Render(GetRenderName(), modelMatrix.Top());
 
 	if(g_pObjPole && g_bDrawLightPos)
 	{
 		glutLeaveMainLoop();
 		return;
 	case 32:
-/*
-		if(g_pViewPole)
-		{
-			const glutil::ViewData &view = g_pViewPole->GetView();
-			printf("%f  %f  %f  %f\n", view.orient.x, view.orient.y, view.orient.z, view.orient.w);
-		}
-*/
+		g_bDrawBumpmap = !g_bDrawBumpmap;
 		break;
 	case 't':
 		g_bDrawCameraPos = !g_bDrawCameraPos;