/* -*- C++ -*- * Copyright ©2004 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #include "display_pixmap.h" #include void Display_Pixmap::plot(void) { ivec bm_pos(2); dvec map_pos(2); dvec shifted_pos(3); dvec globe_pos(3); dvec latlong(2); ivec colour(3); for(bm_pos[1] = viewport->bottom(); bm_pos[1] < viewport->top(); bm_pos[1]++) { for(bm_pos[0] = viewport->left(); bm_pos[0] < viewport->right(); bm_pos[0]++) { if(!viewport->g(map_pos, bm_pos)) continue; if(projection->g(shifted_pos, map_pos) && orbit->g(globe_pos, shifted_pos) && sphere->g(latlong, globe_pos)) { ivec pixelpos(2); pixelpos[0] = int((latlong[0]+M_PI)*xconv); pixelpos[1] = int((latlong[1]+M_PI_2)*yconv); if(pixelpos[0] < 0) pixelpos[0] = 0; if(pixelpos[1] < 0) pixelpos[1] = 0; if(pixelpos[0] >= picture->width()) pixelpos[0] = picture->width()-1; if(pixelpos[1] >= picture->height()) pixelpos[1] = picture->height()-1; colour = picture->getpixel(pixelpos); } else { colour[0] = colour[1] = colour[2] = 0; continue; } bitmap->setpixel(bm_pos, colour); } } }