本文整理汇总了C++中glm::perspective方法的典型用法代码示例。如果您正苦于以下问题:C++ glm::perspective方法的具体用法?C++ glm::perspective怎么用?C++ glm::perspective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glm
的用法示例。
在下文中一共展示了glm::perspective方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resizeGL
void GLWidget::resizeGL(int w, int h) {
width = w;
height = h;
radius = min(width, height) * .75;
float aspect = (float)w/h;
projMatrix = perspective(45.0f, aspect, 1.0f, 100.0f);
viewMatrix = lookAt(vec3(0,0,-10),vec3(0,0,0),vec3(0,1,0));
modelMatrix = mat4(1.0f);
glUseProgram(cubeProg);
glUniformMatrix4fv(cubeProjMatrixLoc, 1, false, value_ptr(projMatrix));
glUniformMatrix4fv(cubeViewMatrixLoc, 1, false, value_ptr(viewMatrix));
glUniformMatrix4fv(cubeModelMatrixLoc, 1, false, value_ptr(modelMatrix));
glUniformMatrix4fv(cubeRotationMatrixLoc, 1, false, value_ptr(rotationMatrix));
glUseProgram(gridProg);
glUniformMatrix4fv(gridProjMatrixLoc, 1, false, value_ptr(projMatrix));
glUniformMatrix4fv(gridViewMatrixLoc, 1, false, value_ptr(viewMatrix));
glUniformMatrix4fv(gridModelMatrixLoc, 1, false, value_ptr(modelMatrix));
glUniformMatrix4fv(gridRotationMatrixLoc, 1, false, value_ptr(rotationMatrix));
}
示例2: draw
void easygl::draw()
{
// update camera
//vec3 direction = rotate(orientation, vec3(0, 0, -1));
//vec3 direction = rotate(quat(0,0,0,0), vec3(0, 0, -1));
position = vec3(5.0f, 5.0f, 5.0f) + (movement.z * direction + movement.x * right - movement.y * up);
target = position + direction;
modelview = lookAt(position, target, up);
projection = perspective(fieldOfView, aspectRatio, near, far);
glViewport(0,0, viewportSize.x, viewportSize.y);
if(viewportSize.y == 0)
viewportSize.y = 1;
aspectRatio = (float)viewportSize.x / (float)viewportSize.y;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0f,0.0f,0.0f,0.0f);
//glEnable(GL_CULL_FACE);
//glEnable(GL_LINE_SMOOTH);
//glLineWidth(1.0f);
// camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glLoadMatrixf(value_ptr(projection));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLoadMatrixf(value_ptr(modelview));
// light
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, value_ptr(vec4(0.6f, 0.7f, 0.7f, 0.0f)));
glLightfv(GL_LIGHT0, GL_AMBIENT, value_ptr(vec4(0.1f, 0.1f, 0.1f, 1.0f)));
glLightfv(GL_LIGHT0, GL_DIFFUSE, value_ptr(vec4(1.0f, 0.9f, 0.8f, 1.0f)));
glLightfv(GL_LIGHT0, GL_SPECULAR, value_ptr(vec4(1.0f, 1.0f, 1.0f, 1.0f)));
// scene
//drawGrid();
//drawRobot();
drawAxis();
//drawPath();
glColor3f(0.3f, 0, 0);
glBegin(GL_QUADS);
glVertex3f(d.min.x/10, d.min.y/10, -0.01f);
glVertex3f(d.min.x/10, d.max.y/10, -0.01f);
glVertex3f(d.max.x/10, d.max.y/10, -0.01f);
glVertex3f(d.max.x/10, d.min.y/10, -0.01f);
glEnd();
glBegin(GL_LINES);
for(layer &l : d.layers){
for(contur &c : l.conts){
if(c.ctype == contur::toolpath || c.ctype == contur::input)
displaycontour(&c);
}
}
glEnd();
glFlush();
}