From 72ee43e9470c6fdbc6ed7ff92b85dfa5062c5762 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 6 Jan 2015 18:51:37 +0000 Subject: Added separate event handlers for mouse button clicks and mouse wheel movement. --- src/render/camera.cc | 17 +++++++++++++---- src/render/screenshot.cc | 25 +++---------------------- src/render/state.cc | 2 +- 3 files changed, 17 insertions(+), 27 deletions(-) (limited to 'src/render') diff --git a/src/render/camera.cc b/src/render/camera.cc index 881d9ae..d6cf562 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -328,12 +328,21 @@ void Camera::frame(float seconds) distance = math::max(FRUSTUMFRONT / WORLDSCALE, FRUSTUMFRONT / WORLDSCALE + camera_zoom * core::localcontrol()->radius()) + 0.001f; } else if (mode() == Cockpit) { + + camera_scene_axis.assign(target_axis); + + direction_target = + 90 * target_direction; + pitch_target = + 90 * target_pitch; - // freelook target - target_axis.change_direction(90 * target_direction); - target_axis.change_pitch(90 * target_pitch); + // adjust direction + d = degrees180f(direction_current - direction_target); + direction_current = degrees360f(direction_current - d * seconds); + camera_scene_axis.change_direction(direction_current); - camera_scene_axis.assign(target_axis); + // adjust pitch + d = degrees180f(pitch_current - pitch_target); + pitch_current = degrees360f(pitch_current - d * seconds); + camera_scene_axis.change_pitch(pitch_current); if (core::localcontrol()->model()) { const float modelscale = core::localcontrol()->radius() / core::localcontrol()->model()->radius(); diff --git a/src/render/screenshot.cc b/src/render/screenshot.cc index 2fd7e9a..0142ad3 100644 --- a/src/render/screenshot.cc +++ b/src/render/screenshot.cc @@ -20,7 +20,7 @@ #include "render/tgafile.h" #include "render/gl.h" -#include +#include namespace render { @@ -34,25 +34,6 @@ int Screenshot::current_date = 0; void Screenshot::savegameshot(const std::string & filename) { - // TODO do the actual drawing - - // Clear the color and depth buffers. - gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - // set camera transformation - Camera::frame(0.0f); - - render::Camera::frustum(); - - // draw the world - draw(0.0f); - - gl::disable(GL_TEXTURE_2D); - gl::disable(GL_BLEND); - - // swap GL buffers - SDL_GL_SwapBuffers(); - int w = State::width(); int h = State::height(); @@ -62,7 +43,7 @@ void Screenshot::savegameshot(const std::string & filename) if ((w > 0) && (h > 0)) { // read pixels into an image instance - render::Image image(w, h, 3); + Image image(w, h, 3); glReadPixels( (GLsizei) ((State::width() - w) / 2), @@ -76,7 +57,7 @@ void Screenshot::savegameshot(const std::string & filename) con_debug << "Saving " << filename << std::endl; - render::JPG::save(filename.c_str(), image, 85); + JPG::save(filename.c_str(), image, 85); } } void Screenshot::save() diff --git a/src/render/state.cc b/src/render/state.cc index 8ada29c..e88ce06 100644 --- a/src/render/state.cc +++ b/src/render/state.cc @@ -7,7 +7,7 @@ #include #include -#include "SDL/SDL.h" +#include "SDL2/SDL.h" #include "render/state.h" #include "render/gl.h" -- cgit v1.2.3