本文整理汇总了C++中mat4::look_at方法的典型用法代码示例。如果您正苦于以下问题:C++ mat4::look_at方法的具体用法?C++ mat4::look_at怎么用?C++ mat4::look_at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat4
的用法示例。
在下文中一共展示了mat4::look_at方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: idle
void GLAppMain::idle()
{
float ratio = (float)window_width / (float) window_height;
projection.perspective(45,ratio,1,10000);
vec3 lat = vec3(0,1,0)^lookat;
lat.normalize();
// keyboard events
if(keys[KEY_ESC]) exit();
if(keys[' ']){
goon = !goon;
keys[' '] = 0;
}
if(keys[KEY_UP]) {
pos += lookat*(50/fps);
keys[KEY_UP] = 0;
}
if(keys[KEY_DOWN]) {
pos -= lookat*(50/fps);
keys[KEY_DOWN] = 0;
}
if(keys[KEY_LEFT]) {
pos += lat*(50/fps);
keys[KEY_LEFT] = 0;
}
if(keys[KEY_RIGHT]) {
pos -= lat*(50/fps);
keys[KEY_RIGHT] = 0;
}
static int look = 0;
if(!look && mouse_button & BUTTON_LEFT) {
setCursor(window_width / 2,window_height / 2);
mouse_x = window_width / 2;
mouse_y = window_height / 2;
look = 1;
}
if(mouse_button & BUTTON_RIGHT) look = 0;
if(look) {
showCursor(0);
mat3 m;
m.rotate( lat, (mouse_y - window_height / 2) * 0.2 );
lookat = m*lookat;
m.rotate_y( -(mouse_x - window_width / 2) * 0.2 );
lookat = m*lookat;
setCursor(window_width / 2,window_height / 2);
} else showCursor(1);
vec3 up = lookat^lat;
up.normalize();
modelview.look_at(pos,pos+lookat,up);
}
示例2: opengl_display
void opengl_display()
{
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer);
if(torus_mesh.program != NULL)
{
glViewport(0,0,1024,1024);
glClearColor(0.004,0.01,0.01,0.01);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
view_matrix.look_at(vec3(0,0,distance_z), vec3(0,0,0), vec3(0,1,0));
view_proj_matrix = quad_proj_matrix * view_matrix * world_matrix;
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glUseProgram(torus_mesh.program->get_program());
glUniformMatrix4fv(torus_mesh.loc_view_proj_matrix, 1, GL_FALSE, &view_proj_matrix[0]);
torus_mesh.draw();
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if(quad_mesh.program != NULL)
{
glViewport(0,0,width, height);
glClearColor(0.004,0.01,0.01,0.01);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_BLEND);
// view_proj_matrix = mat4();
glUseProgram(quad_mesh.program->get_program());
// glUniformMatrix4fv(quad_mesh.loc_view_proj_matrix, 1, GL_FALSE, &view_proj_matrix[0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, quad_mesh.texs_idxs[0]);
glUniform1i(quad_mesh.texs_locs[0], 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, quad_mesh.texs_idxs[1]);
glUniform1i(quad_mesh.texs_locs[1], 1);
quad_mesh.draw();
}
}