当前位置: 首页>>代码示例>>C++>>正文


C++ glm::perspective方法代码示例

本文整理汇总了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));
}
开发者ID:joshatron,项目名称:CSCI-441-Labs,代码行数:24,代码来源:glwidget.cpp

示例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();
}
开发者ID:rene-dev,项目名称:knuthcam,代码行数:64,代码来源:easygl.cpp


注:本文中的glm::perspective方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。