本文整理汇总了C++中GLFrame::rotate_local_y方法的典型用法代码示例。如果您正苦于以下问题:C++ GLFrame::rotate_local_y方法的具体用法?C++ GLFrame::rotate_local_y怎么用?C++ GLFrame::rotate_local_y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLFrame
的用法示例。
在下文中一共展示了GLFrame::rotate_local_y方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_events
int handle_events(GLFrame& camera_frame, unsigned int last_time, unsigned int cur_time)
{
SDL_Event event;
int sc;
//for now
int width = WIDTH;
int height = HEIGHT;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
sc = event.key.keysym.scancode;
if (sc == SDL_SCANCODE_ESCAPE) {
return 1;
} else if (sc == SDL_SCANCODE_P) {
polygon_mode = (polygon_mode + 1) % 3;
if (polygon_mode == 0)
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
else if (polygon_mode == 1)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
break;
case SDL_MOUSEMOTION:
{
//printf("%d %d %d %d\n", event.motion.y, event.motion.x, event.motion.xrel, event.motion.yrel);
float dx = event.motion.xrel;
float dy = event.motion.yrel;
camera_frame.rotate_local_y(DEG_TO_RAD(-dx/50));
camera_frame.rotate_local_x(DEG_TO_RAD(dy/25));
if (9 < dx*dx + dy*dy) {
camera_frame.rotate_local_y(DEG_TO_RAD(-dx/30));
camera_frame.rotate_local_x(DEG_TO_RAD(dy/25));
//mousex = width/2;
//mousey = height/2;
}
}
break;
case SDL_QUIT:
return 1;
}
}
//SDL_PumpEvents() is called above in SDL_PollEvent()
const Uint8 *state = SDL_GetKeyboardState(NULL);
float time = (cur_time - last_time)/1000.0f;
#define MOVE_SPEED 5
if (state[controls[LEFT]]) {
camera_frame.move_right(time * MOVE_SPEED);
}
if (state[controls[RIGHT]]) {
camera_frame.move_right(time * -MOVE_SPEED);
}
if (state[controls[UP]]) {
camera_frame.move_up(time * MOVE_SPEED);
}
if (state[controls[DOWN]]) {
camera_frame.move_up(time * -MOVE_SPEED);
}
if (state[controls[FORWARD]]) {
camera_frame.move_forward(time * MOVE_SPEED);
}
if (state[controls[BACK]]) {
camera_frame.move_forward(time * -MOVE_SPEED);
}
if (state[controls[TILTLEFT]]) {
camera_frame.rotate_local_z(DEG_TO_RAD(-60*time));
}
if (state[controls[TILTRIGHT]]) {
camera_frame.rotate_local_z(DEG_TO_RAD(60*time));
}
return 0;
}