init.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*!
  2. \file lib/driver/init.c
  3. \brief Display Driver - initialization
  4. (C) 2006-2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Glynn Clements <glynn gclements.plus.com> (original contributor)
  8. \author Huidae Cho <grass4u gmail.com>
  9. */
  10. #include <grass/config.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <grass/gis.h>
  14. #include <grass/fontcap.h>
  15. #include "driverlib.h"
  16. #include "driver.h"
  17. const struct driver *driver;
  18. struct GFONT_CAP *ftcap;
  19. int screen_width;
  20. int screen_height;
  21. double cur_x;
  22. double cur_y;
  23. double text_size_x;
  24. double text_size_y;
  25. double text_rotation;
  26. double text_sinrot;
  27. double text_cosrot;
  28. int matrix_valid;
  29. /*!
  30. \brief Initialize display driver
  31. \param drv pointer to driver structure
  32. */
  33. void LIB_init(const struct driver *drv)
  34. {
  35. const char *p;
  36. driver = drv;
  37. ftcap = parse_fontcap();
  38. /* initialize graphics */
  39. p = getenv("GRASS_RENDER_WIDTH");
  40. screen_width = (p && atoi(p)) ? atoi(p) : DEF_WIDTH;
  41. p = getenv("GRASS_RENDER_HEIGHT");
  42. screen_height = (p && atoi(p)) ? atoi(p) : DEF_HEIGHT;
  43. if (COM_Graph_set() < 0)
  44. exit(1);
  45. COM_Set_window(0, screen_height, 0, screen_width);
  46. }