本文整理汇总了C++中tdogl::Camera::matrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Camera::matrix方法的具体用法?C++ Camera::matrix怎么用?C++ Camera::matrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tdogl::Camera
的用法示例。
在下文中一共展示了Camera::matrix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderInstance
//renders a single `ModelInstance`
static void RenderInstance(const ModelInstance& inst) {
ModelAsset* asset = inst.asset;
tdogl::Program* shaders = asset->shaders;
//bind the shaders
shaders->use();
//set the shader uniforms
shaders->setUniform("camera", gCamera.matrix());
shaders->setUniform("model", inst.transform);
shaders->setUniform("material.tex", 0); //set to 0 because the texture will be bound to GL_TEXTURE0
shaders->setUniform("material.shininess", asset->shininess);
shaders->setUniform("material.specularColor", asset->specularColor);
shaders->setUniform("light.position", gLight.position);
shaders->setUniform("light.intensities", gLight.intensities);
shaders->setUniform("light.attenuation", gLight.attenuation);
shaders->setUniform("light.ambientCoefficient", gLight.ambientCoefficient);
shaders->setUniform("cameraPosition", gCamera.position());
//bind the texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, asset->texture->object());
//bind VAO and draw
glBindVertexArray(asset->vao);
glDrawArrays(asset->drawType, asset->drawStart, asset->drawCount);
//unbind everything
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
shaders->stopUsing();
}
示例2: Render
static void Render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0, 0.1, 0.1, 1.0); //set the background
glUseProgram(gProgram->object());
gProgram -> setUniform("camera", gCamera.matrix());
gProgram -> setUniform("model", glm::rotate(glm::mat4(), gDegreesRotated, Axis));
gProgram -> setUniform("light.position", gLight.position);
gProgram -> setUniform("light.intensities",gLight.intensities);
gProgram -> setUniform("materialSpecularColor", specularColor);
gProgram -> setUniform("materialShininess", material_shininess);
gProgram -> setUniform("light.attenuation", gLight.attenuation);
gProgram -> setUniform("light.ambientCoefficient", gLight.ambientCoefficient);
gProgram -> setUniform("cameraPosition", gCamera.position());
glBindVertexArray(gVAO);
glDrawArrays(GL_TRIANGLES, 0, NumVertices);
glBindVertexArray(0);
//glFlush();
gProgram -> stopUsing();
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH);
glfwSwapBuffers();
}
示例3: Render
// draws a single frame
static void Render() {
// clear everything
glClearColor(0, 0, 0, 1); // black
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// bind the program (the shaders)
gProgram->use();
// set the "camera" uniform
gProgram->setUniform("camera", gCamera.matrix());
// set the "model" uniform in the vertex shader, based on the gDegreesRotated global
gProgram->setUniform("model", glm::rotate(glm::mat4(), gDegreesRotated, glm::vec3(0,1,0)));
// bind the texture and set the "tex" uniform in the fragment shader
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gTexture->object());
gProgram->setUniform("tex", 0); //set to 0 because the texture is bound to GL_TEXTURE0
// bind the VAO (the triangle)
glBindVertexArray(gVAO);
// draw the VAO
glDrawArrays(GL_TRIANGLES, 0, 6*2*3);
// unbind the VAO, the program and the texture
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
gProgram->stopUsing();
// swap the display buffers (displays what was just drawn)
glfwSwapBuffers();
}
示例4: RenderInstance
static void RenderInstance(const ModelInstance& inst) {
ModelAsset* asset = inst.asset;
tdogl::Program* shaders = asset->shaders;
// bind the shaders
shaders->use();
// set the shader uniforms
shaders->setUniform("camera", gCamera.matrix());
shaders->setUniform("model", inst.transform);
shaders->setUniform("tex", 0);
// bind the texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, asset->texture->object());
// bind VAO and draw
glBindVertexArray(asset->vao);
glDrawArrays(asset->drawType, asset->drawStart, asset->drawCount);
// unbind everything
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
shaders->stopUsing();
}
示例5: Render
// draws a single frame
static void Render() {
// clear everything
glClearColor(0, 0, 0, 1); // black
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// render all the instances
std::list<ModelInstance>::const_iterator it;
for(it = gInstances.begin(); it != gInstances.end(); ++it){
RenderInstance(*it, gCamera.matrix());
}
// swap the display buffers (displays what was just drawn)
glfwSwapBuffers();
}
示例6: Render
void Render(GLFWwindow* window)
{
// clear everything
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLint uniformCamera = glGetUniformLocation(gProgram, "camera");
if (uniformCamera == -1)
throw std::runtime_error(std::string("Program uniform not found: ") + "camera");
glUniformMatrix4fv(uniformCamera, 1, GL_FALSE, glm::value_ptr(gCamera.matrix()));
GLint uniformModel = glGetUniformLocation(gProgram, "model");
if (uniformModel == -1)
throw std::runtime_error(std::string("Program uniform not found: ") + "tex");
glm::tmat4x4<float, glm::highp> modelMatrix = glm::rotate(glm::mat4(), glm::radians(gDegreesRotated), glm::vec3(0, 1, 0));
glUniformMatrix4fv(uniformModel, 1, GL_FALSE, glm::value_ptr(modelMatrix));
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gTex);
GLint uniformTex = glGetUniformLocation(gProgram, "tex");
if (uniformTex == -1)
throw std::runtime_error(std::string("Program uniform not found: ") + "tex");
glUniform1i(uniformTex, 0);
glBindVertexArray(gVAO);
// draw the VAO
glDrawArrays(GL_TRIANGLES, 0, 6 * 2 * 3);
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
glfwSwapBuffers(window);
}