本文整理汇总了C++中PointLight::getDiffuse方法的典型用法代码示例。如果您正苦于以下问题:C++ PointLight::getDiffuse方法的具体用法?C++ PointLight::getDiffuse怎么用?C++ PointLight::getDiffuse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointLight
的用法示例。
在下文中一共展示了PointLight::getDiffuse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyLight
void OpenGLShaderPointLight::copyLight(PointLight &light)
{
setParamValue("position", light.getPosition());
setParamValue("ambient", light.getAmbient());
setParamValue("diffuse", light.getDiffuse());
setParamValue("specular", light.getSpecular());
setParamValue("attenuation", light.getAttenuation());
setParamValue("cutoff", light.getCutoff());
bind();
}
示例2: render
void LegacyRenderer::render(const ICamera<float>& camera, const PointLight<float>& light, const TriangleBuffer& buffer)
{
const auto& positions = buffer.getPositions().get();// buffers[0].get();
const auto& normals = buffer.getNormals().get();//buffers[1].get();
if (positions.empty()) {
return;
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
const auto& projectionMatrix = camera.getProjectionMatrix();
const auto& modelviewMatrix = camera.getModelviewMatrix();;
std::vector<float> lightPos = { light.getPos().getX(), light.getPos().getY(), light.getPos().getZ(), 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPos.data());
glLightfv(GL_LIGHT0, GL_DIFFUSE, light.getDiffuse().toArray4().data());
// glLightfv(GL_LIGHT0, GL_SPECULAR, light.getSpecular().toArray4().data());
glLightfv(GL_LIGHT0, GL_AMBIENT, white);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glLoadMatrixf(projectionMatrix.toArray().data());
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLoadMatrixf(modelviewMatrix.toArray().data());
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, yellow);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, positions.data());
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, normals.data());
//glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(positions.size()) / 3);
for (const auto& b : buffer.getBlocks()) {
const auto& indices = b.getIndices();
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indices.size()), GL_UNSIGNED_INT, indices.data());
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glDisable(GL_DEPTH_TEST);
}