void render_objs(void) { int i,j; int mode=GL_FRONT; double pos[3],angle; glMaterialfv(mode,GL_AMBIENT,ambient_ir); glPushMatrix(); if (d_position) { p5glove_get_position(glove, pos); glTranslated(pos[0]*WORLD_SCALE,pos[1]*WORLD_SCALE,pos[2]*WORLD_SCALE); } if (d_rotation) { p5glove_get_rotation(glove,&angle,pos); glRotated(angle, pos[0], pos[1], pos[2]); } if (d_ref_axes) render_axes(); if (d_ref_hand) render_hand(); glPopMatrix(); }
/** * @brief Renderer::render render a single frame, then return * @return true if the user wants to quit the application */ bool Renderer::render(){ process_keys(SDL_GetKeyboardState(NULL)); SDL_Event e; while(SDL_PollEvent(&e)){ if(e.type == SDL_QUIT){ printf("received SDL_QUIT\n"); quit_flag = true; } else if(e.type == SDL_MOUSEMOTION){ mousemove_event(e.motion.xrel, e.motion.yrel); } else if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_RESIZED){ resize_event(e.window.data1, e.window.data2); std::cout << "window resized" << std::endl; } } glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); world_to_camera_matrix = look_matrix(camera_vertical, camera_horizontal, camera_position); camera_to_clip_matrix = glm::mat4( glm::vec4(frustum_scale/(width/(float)height), 0.0, 0.0, 0.0), glm::vec4(0.0, frustum_scale, 0.0, 0.0), glm::vec4(0.0, 0.0, (z_far + z_near)/(z_near - z_far), (2*z_far*z_near)/(z_near - z_far)), glm::vec4(0.0, 0.0, -1.0, 0.0)); // update uniforms for all shaders now (no UBOs in 2.x, unfortunately...) axes_shader->set_camera_to_clip(camera_to_clip_matrix); axes_shader->set_world_to_camera(world_to_camera_matrix); render_axes(); trails_shader->set_camera_to_clip(camera_to_clip_matrix); trails_shader->set_world_to_camera(world_to_camera_matrix); render_trails(); pointsprites_shader->set_camera_to_clip(camera_to_clip_matrix); pointsprites_shader->set_world_to_camera(world_to_camera_matrix); pointsprites_shader->set_uniform("camera_position", camera_position); render_pointsprites(); render_center_of_mass(); SDL_GL_SwapWindow(win); //SDL_Delay(1000/60.0); // limit to 60FPS return quit_flag; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0,0,-5); glRotatef(rot_x, 1, 0, 0); glRotatef(rot_y, 0, 1, 0); render_axes(); glColor3f(1,1,1); glPolygonMode(GL_FRONT, GL_LINE); render_object(); glColor3f(.5,.5,.5); glPolygonMode(GL_FRONT, GL_FILL); render_object(); glutSwapBuffers(); }
void RenderField(Field *field) { Lightcycle *players = field->player; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); field_w = field->width; field_h = field->height; place_camera(field); ground_plane(field_w, field_h); render_axes(); while (players != 0) { render_player(players); players = players->next; } glFlush(); }