void TerrainPreviewWindow::OnPaint(Canvas &canvas) { const GlueMapWindow *map = UIGlobals::GetMap(); if (map == nullptr) return; MapWindowProjection projection = map->VisibleProjection(); if (!projection.IsValid()) { /* TODO: initialise projection to middle of map instead of bailing out */ canvas.ClearWhite(); return; } projection.SetScreenSize(canvas.GetSize()); projection.SetScreenOrigin(canvas.GetWidth() / 2, canvas.GetHeight() / 2); Angle sun_azimuth(Angle::Degrees(-45)); if (renderer.GetSettings().slope_shading == SlopeShading::SUN && CommonInterface::Calculated().sun_data_available) sun_azimuth = CommonInterface::Calculated().sun_azimuth; renderer.Generate(projection, sun_azimuth); #ifdef ENABLE_OPENGL /* enable clipping because the OpenGL terrain renderer uses a large texture that exceeds the window dimensions */ GLCanvasScissor scissor(canvas); #endif renderer.Draw(canvas, projection); }
void TerrainDisplayConfigPanel::OnPreviewPaint(Canvas &canvas) { TerrainRenderer renderer(terrain); renderer.SetSettings(terrain_settings); MapWindowProjection projection = XCSoarInterface::main_window.GetProjection(); projection.SetScreenSize(canvas.get_width(), canvas.get_height()); projection.SetScreenOrigin(canvas.get_width() / 2, canvas.get_height() / 2); Angle sun_azimuth(Angle::Degrees(fixed(-45))); if (terrain_settings.slope_shading == SlopeShading::SUN && XCSoarInterface::Calculated().sun_data_available) sun_azimuth = XCSoarInterface::Calculated().sun_azimuth; renderer.Generate(projection, sun_azimuth); renderer.Draw(canvas, projection); }