本文整理汇总了C++中glutil::ViewPole类的典型用法代码示例。如果您正苦于以下问题:C++ ViewPole类的具体用法?C++ ViewPole怎么用?C++ ViewPole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewPole类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: display
// G³ówna funkcja rysowania. Tutaj wywo³ujemy wszystkie obiekty do narysowania.
void display() {
currentTime = glutGet(GLUT_ELAPSED_TIME);
CalcCarPosition();
glm::vec4 &worldLightPos = carPosition;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
{
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
setDefaultLightParams(&adsShader, worldLightPos, direction, nextLight);
{
glutil::PushStack push(modelMatrix);
// Pod³oga
{
glutil::PushStack push(modelMatrix);
glm::mat4 invTransform = glm::inverse(modelMatrix.Top());
glUseProgram(adsShader.theProgram);
glUniformMatrix4fv(adsShader.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
glUniform3f(adsShader.Ks, 0.0f, 0.0f, 0.0f); // niech pod³oga nie ma odbicia
g_pPlaneMesh->Render("lit-color");
glUseProgram(0);
}
drawCylinder(modelMatrix, worldLightPos);
drawCar(modelMatrix, worldLightPos);
drawSphere1(modelMatrix, worldLightPos);
drawSphere2(modelMatrix, worldLightPos);
drawTetrahedron1(modelMatrix, worldLightPos);
}
}
glutPostRedisplay();
glutSwapBuffers();
oldTime = currentTime;
}
开发者ID:bryk,项目名称:grafika-projekt,代码行数:44,代码来源:projekt.cpp
示例2: keyboard
//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
//exit the program.
void keyboard(unsigned char key, int x, int y)
{
bool bChangedShininess = false;
bool bChangedLightModel = false;
switch (key)
{
case 27:
delete g_pScene;
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;
case 't': g_bDrawCameraPos = !g_bDrawCameraPos; break;
case '1': g_eTimerMode = TIMER_ALL; printf("All\n"); break;
case '2': g_eTimerMode = TIMER_SUN; printf("Sun\n"); break;
case '3': g_eTimerMode = TIMER_LIGHTS; printf("Lights\n"); break;
case 'l': SetupDaytimeLighting(); break;
case 'L': SetupNighttimeLighting(); break;
case 'k': SetupHDRLighting(); break;
case 32:
{
float sunAlpha = g_lights.GetSunTime();
float sunTimeHours = sunAlpha * 24.0f + 12.0f;
sunTimeHours = sunTimeHours > 24.0f ? sunTimeHours - 24.0f : sunTimeHours;
int sunHours = int(sunTimeHours);
float sunTimeMinutes = (sunTimeHours - sunHours) * 60.0f;
int sunMinutes = int(sunTimeMinutes);
printf("%02i:%02i\n", sunHours, sunMinutes);
}
break;
}
g_viewPole.CharPress(key);
}
开发者ID:Blisse,项目名称:OGLTicTacToe,代码行数:43,代码来源:HDR+Lighting.cpp
示例3: display
void display()
{
g_LightTimer.Update();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
{
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
const glm::vec4 &worldLightPos = CalcLightPosition();
const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
ProgramData &whiteProg = g_Programs[g_eLightModel].whiteProg;
ProgramData &colorProg = g_Programs[g_eLightModel].colorProg;
glUseProgram(whiteProg.theProgram);
glUniform4f(whiteProg.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(whiteProg.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUniform3fv(whiteProg.cameraSpaceLightPosUnif,1, glm::value_ptr(lightPosCameraSpace));
glUniform1f(whiteProg.lightAttenuationUnif, g_fLightAttenuation);
glUniform1f(whiteProg.shininessFactorUnif, g_matParams);
glUniform4fv(whiteProg.baseDiffuseColorUnif, 1,
g_bDrawDark ? glm::value_ptr(g_darkColor) : glm::value_ptr(g_lightColor));
glUseProgram(colorProg.theProgram);
glUniform4f(colorProg.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(colorProg.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUniform3fv(colorProg.cameraSpaceLightPosUnif, 1, glm::value_ptr(lightPosCameraSpace));
glUniform1f(colorProg.lightAttenuationUnif, g_fLightAttenuation);
glUniform1f(colorProg.shininessFactorUnif, g_matParams);
glUseProgram(0);
{
glutil::PushStack push(modelMatrix);
//Render the ground plane.
{
glutil::PushStack push(modelMatrix);
glm::mat3 normMatrix(modelMatrix.Top());
normMatrix = glm::transpose(glm::inverse(normMatrix));
glUseProgram(whiteProg.theProgram);
glUniformMatrix4fv(whiteProg.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniformMatrix3fv(whiteProg.normalModelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
g_pPlaneMesh->Render();
glUseProgram(0);
}
//Render the Cylinder
{
glutil::PushStack push(modelMatrix);
modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
if(g_bScaleCyl)
modelMatrix.Scale(1.0f, 1.0f, 0.2f);
glm::mat3 normMatrix(modelMatrix.Top());
normMatrix = glm::transpose(glm::inverse(normMatrix));
ProgramData &prog = g_bDrawColoredCyl ? colorProg : whiteProg;
glUseProgram(prog.theProgram);
glUniformMatrix4fv(prog.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniformMatrix3fv(prog.normalModelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
if(g_bDrawColoredCyl)
g_pCylinderMesh->Render("lit-color");
else
g_pCylinderMesh->Render("lit");
glUseProgram(0);
}
//Render the light
if(g_bDrawLightSource)
{
glutil::PushStack push(modelMatrix);
modelMatrix.Translate(glm::vec3(worldLightPos));
modelMatrix.Scale(0.1f, 0.1f, 0.1f);
glUseProgram(g_Unlit.theProgram);
glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniform4f(g_Unlit.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f);
g_pCubeMesh->Render("flat");
}
}
}
//.........这里部分代码省略.........
开发者ID:Nuclearfossil,项目名称:ducking-octo-dangerzone,代码行数:101,代码来源:Gaussian+Specular+Lighting.cpp
示例4: display
//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.
void display()
{
g_lights.UpdateTime();
glm::vec4 bkg = g_lights.GetBackgroundColor();
glClearColor(bkg[0], bkg[1], bkg[2], bkg[3]);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
const glm::mat4 &worldToCamMat = modelMatrix.Top();
LightBlock lightData = g_lights.GetLightInformation(worldToCamMat);
glBindBuffer(GL_UNIFORM_BUFFER, g_lightUniformBuffer);
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(lightData), &lightData);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
if(g_pScene)
{
glutil::PushStack push(modelMatrix);
g_pScene->Draw(modelMatrix, g_materialBlockIndex, g_lights.GetTimerValue("tetra"));
}
{
glutil::PushStack push(modelMatrix);
//Render the sun
{
glutil::PushStack push(modelMatrix);
glm::vec3 sunlightDir(g_lights.GetSunlightDirection());
modelMatrix.Translate(sunlightDir * 500.0f);
modelMatrix.Scale(30.0f, 30.0f, 30.0f);
glUseProgram(g_Unlit.theProgram);
glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glm::vec4 lightColor = g_lights.GetSunlightIntensity();
glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor));
g_pScene->GetSphereMesh()->Render("flat");
}
//Render the lights
if(g_bDrawLights)
{
for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++)
{
glutil::PushStack push(modelMatrix);
modelMatrix.Translate(g_lights.GetWorldLightPosition(light));
glUseProgram(g_Unlit.theProgram);
glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glm::vec4 lightColor = g_lights.GetPointLightIntensity(light);
glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor));
g_pScene->GetCubeMesh()->Render("flat");
}
}
if(g_bDrawCameraPos)
{
glutil::PushStack push(modelMatrix);
modelMatrix.SetIdentity();
modelMatrix.Translate(glm::vec3(0.0f, 0.0f, -g_viewPole.GetView().radius));
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glUseProgram(g_Unlit.theProgram);
glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniform4f(g_Unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f);
g_pScene->GetCubeMesh()->Render("flat");
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glUniform4f(g_Unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f);
g_pScene->GetCubeMesh()->Render("flat");
}
}
glutPostRedisplay();
glutSwapBuffers();
}
开发者ID:Nuclearfossil,项目名称:ducking-octo-dangerzone,代码行数:92,代码来源:Scene+Lighting.cpp
示例5: display
void display()
{
g_LightTimer.Update();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(g_pPlaneMesh && g_pCylinderMesh && g_pCubeMesh)
{
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
const glm::vec4 &worldLightPos = CalcLightPosition();
glm::vec4 lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
glUseProgram(g_WhiteDiffuseColor.theProgram);
glUniform3fv(g_WhiteDiffuseColor.lightPosUnif, 1, glm::value_ptr(lightPosCameraSpace));
glUseProgram(g_VertexDiffuseColor.theProgram);
glUniform3fv(g_VertexDiffuseColor.lightPosUnif, 1, glm::value_ptr(lightPosCameraSpace));
glUseProgram(g_WhiteDiffuseColor.theProgram);
glUniform4f(g_WhiteDiffuseColor.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(g_WhiteDiffuseColor.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUseProgram(g_VertexDiffuseColor.theProgram);
glUniform4f(g_VertexDiffuseColor.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(g_VertexDiffuseColor.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUseProgram(0);
{
glutil::PushStack push(modelMatrix);
//Render the ground plane.
{
glutil::PushStack push(modelMatrix);
glUseProgram(g_WhiteDiffuseColor.theProgram);
glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(g_WhiteDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
g_pPlaneMesh->Render();
glUseProgram(0);
}
//Render the Cylinder
{
glutil::PushStack push(modelMatrix);
modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
if(g_bDrawColoredCyl)
{
glUseProgram(g_VertexDiffuseColor.theProgram);
glUniformMatrix4fv(g_VertexDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(g_VertexDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
g_pCylinderMesh->Render("lit-color");
}
else
{
glUseProgram(g_WhiteDiffuseColor.theProgram);
glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(g_WhiteDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
g_pCylinderMesh->Render("lit");
}
glUseProgram(0);
}
//Render the light
if(g_bDrawLight)
{
glutil::PushStack push(modelMatrix);
modelMatrix.Translate(glm::vec3(worldLightPos));
modelMatrix.Scale(0.1f, 0.1f, 0.1f);
glUseProgram(g_Unlit.theProgram);
glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniform4f(g_Unlit.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f);
g_pCubeMesh->Render("flat");
}
}
}
glutPostRedisplay();
glutSwapBuffers();
}
开发者ID:Sand3r-,项目名称:gltut,代码行数:96,代码来源:Vertex+Point+Lighting.cpp
示例6: display
//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.
void display()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(g_pPlaneMesh && g_pCylinderMesh)
{
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection;
glUseProgram(g_WhiteDiffuseColor.theProgram);
glUniform3fv(g_WhiteDiffuseColor.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace));
glUseProgram(g_VertexDiffuseColor.theProgram);
glUniform3fv(g_VertexDiffuseColor.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace));
glUseProgram(0);
{
glutil::PushStack push(modelMatrix);
//Render the ground plane.
{
glutil::PushStack push(modelMatrix);
glUseProgram(g_WhiteDiffuseColor.theProgram);
glUniformMatrix4fv(g_WhiteDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(g_WhiteDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix));
glUniform4f(g_WhiteDiffuseColor.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f);
g_pPlaneMesh->Render();
glUseProgram(0);
}
//Render the Cylinder
{
glutil::PushStack push(modelMatrix);
modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
if(g_bScaleCyl)
modelMatrix.Scale(1.0f, 1.0f, 0.2f);
glUseProgram(g_VertexDiffuseColor.theProgram);
glUniformMatrix4fv(g_VertexDiffuseColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
if(g_bDoInvTranspose)
{
normMatrix = glm::transpose(glm::inverse(normMatrix));
}
glUniformMatrix3fv(g_VertexDiffuseColor.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix));
glUniform4f(g_VertexDiffuseColor.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f);
g_pCylinderMesh->Render("lit-color");
glUseProgram(0);
}
}
}
glutSwapBuffers();
}
开发者ID:Blisse,项目名称:OGLTicTacToe,代码行数:64,代码来源:Scale+and+Lighting.cpp
示例7: display
GLUSboolean display(GLUSfloat time)
{
g_LightTimer.Update(time);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
const glm::vec4 &worldLightPos = CalcLightPosition();
const glm::vec4 &lightPosCameraSpace = modelMatrix.Top() * worldLightPos;
glUseProgram(g_MonoDiffuseProgram.program);
glUniform4f(g_MonoDiffuseProgram.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(g_MonoDiffuseProgram.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUniform3fv(g_MonoDiffuseProgram.cameraSpaceLightPosUnif,1, glm::value_ptr(lightPosCameraSpace));
glUniform1f(g_MonoDiffuseProgram.lightAttenuationUnif, g_fLightAttenuation);
glUniform1f(g_MonoDiffuseProgram.shininessFactorUnif, g_fGaussianRoughness);
glUniform4fv(g_MonoDiffuseProgram.baseDiffuseColorUnif, 1,
g_bDrawDark ? glm::value_ptr(g_darkColor) : glm::value_ptr(g_lightColor));
glUseProgram(g_ColorDiffuseProgram.program);
glUniform4f(g_ColorDiffuseProgram.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(g_ColorDiffuseProgram.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUniform3fv(g_ColorDiffuseProgram.cameraSpaceLightPosUnif, 1, glm::value_ptr(lightPosCameraSpace));
glUniform1f(g_ColorDiffuseProgram.lightAttenuationUnif, g_fLightAttenuation);
glUniform1f(g_ColorDiffuseProgram.shininessFactorUnif, g_fGaussianRoughness);
glUseProgram(0);
{
glutil::PushStack push(modelMatrix);
{
glutil::PushStack push(modelMatrix);
glm::mat3 normMatrix(modelMatrix.Top());
normMatrix = glm::transpose(glm::inverse(normMatrix));
glUseProgram(g_MonoDiffuseProgram.program);
glUniformMatrix4fv(g_MonoDiffuseProgram.modelViewUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniformMatrix3fv(g_MonoDiffuseProgram.modelViewForNormalUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
g_pPlaneMesh->render();
glUseProgram(0);
}
{
glutil::PushStack push(modelMatrix);
modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
if (g_bScaleCyl) {
modelMatrix.Scale(1.0f, 1.0f, 0.2f);
}
glm::mat3 normMatrix(modelMatrix.Top());
normMatrix = glm::transpose(glm::inverse(normMatrix));
ProgramData &prog = g_bDrawColoredCyl ? g_ColorDiffuseProgram : g_MonoDiffuseProgram;
glUseProgram(prog.program);
glUniformMatrix4fv(prog.modelViewUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniformMatrix3fv(prog.modelViewForNormalUnif, 1, GL_FALSE,
glm::value_ptr(normMatrix));
g_pCylinderMesh->render(g_bDrawColoredCyl ? "lit-color" : "lit");
glUseProgram(0);
}
if (g_bDrawLightSource)
{
glutil::PushStack push(modelMatrix);
modelMatrix.Translate(glm::vec3(worldLightPos));
modelMatrix.Scale(0.1f, 0.1f, 0.1f);
glUseProgram(g_UnlitProgram.program);
glUniformMatrix4fv(g_UnlitProgram.modelViewUnif, 1, GL_FALSE,
glm::value_ptr(modelMatrix.Top()));
glUniform4f(g_UnlitProgram.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f);
g_pCubeMesh->render("flat");
}
}
return GLUS_TRUE;
}
开发者ID:cntoplolicon,项目名称:grape,代码行数:91,代码来源:specular_lighting.cpp
示例8: display
void display()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(g_pPlaneMesh && g_pCylinderMesh)
{
glutil::MatrixStack modelMatrix;
modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
glm::vec4 lightDirCameraSpace = modelMatrix.Top() * g_lightDirection;
ProgramData &whiteDiffuse = g_bShowAmbient ? g_WhiteAmbDiffuseColor : g_WhiteDiffuseColor;
ProgramData &vertexDiffuse = g_bShowAmbient ? g_VertexAmbDiffuseColor : g_VertexDiffuseColor;
if(g_bShowAmbient)
{
glUseProgram(whiteDiffuse.theProgram);
glUniform4f(whiteDiffuse.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(whiteDiffuse.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
glUseProgram(vertexDiffuse.theProgram);
glUniform4f(vertexDiffuse.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f);
glUniform4f(vertexDiffuse.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f);
}
else
{
glUseProgram(whiteDiffuse.theProgram);
glUniform4f(whiteDiffuse.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f);
glUseProgram(vertexDiffuse.theProgram);
glUniform4f(vertexDiffuse.lightIntensityUnif, 1.0f, 1.0f, 1.0f, 1.0f);
}
glUseProgram(whiteDiffuse.theProgram);
glUniform3fv(whiteDiffuse.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace));
glUseProgram(vertexDiffuse.theProgram);
glUniform3fv(vertexDiffuse.dirToLightUnif, 1, glm::value_ptr(lightDirCameraSpace));
glUseProgram(0);
{
glutil::PushStack push(modelMatrix);
//Render the ground plane.
{
glutil::PushStack push(modelMatrix);
glUseProgram(whiteDiffuse.theProgram);
glUniformMatrix4fv(whiteDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(whiteDiffuse.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix));
g_pPlaneMesh->Render();
glUseProgram(0);
}
//Render the Cylinder
{
glutil::PushStack push(modelMatrix);
modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
if(g_bDrawColoredCyl)
{
glUseProgram(vertexDiffuse.theProgram);
glUniformMatrix4fv(vertexDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(vertexDiffuse.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix));
g_pCylinderMesh->Render("lit-color");
}
else
{
glUseProgram(whiteDiffuse.theProgram);
glUniformMatrix4fv(whiteDiffuse.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
glm::mat3 normMatrix(modelMatrix.Top());
glUniformMatrix3fv(whiteDiffuse.normalModelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(normMatrix));
g_pCylinderMesh->Render("lit");
}
glUseProgram(0);
}
}
}
glutSwapBuffers();
}
开发者ID:Blisse,项目名称:OGLTicTacToe,代码行数:83,代码来源:Ambient+Lighting.cpp
注:本文中的glutil::ViewPole类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论