gfx3.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*--------------------------------------------------------------------------
  2. DEPUI-GFX-TK 3.0 - GPL portable source code libraries
  3. http://www.deleveld.dds.nl/depui.htm
  4. See file docs/copying for copyright details
  5. ---------------------------------------------------------------------------*/
  6. #define MXMODULE_BITLINE
  7. #define MXMODULE_LOADTGA
  8. #include "degfx/degfx.c"
  9. #include <time.h>
  10. static MX_BITMAP *bitmap;
  11. static void draw(const MX_RECT * r)
  12. {
  13. /* Draw a background */
  14. mx_rectfill(r->x1, r->y1, r->x2, r->y2, MXCOLOR_lightskyblue3);
  15. /* Draw the bitmap on the screen */
  16. mx_blit(bitmap, 0, 0, 0, 0, MXDEFAULT, MXDEFAULT);
  17. mx_blit(bitmap, 0, 0, 50, 10, MXDEFAULT, MXDEFAULT);
  18. mx_blit(bitmap, 0, 0, 100, 20, MXDEFAULT, MXDEFAULT);
  19. }
  20. int main(int argc, char *argv[])
  21. {
  22. unsigned i;
  23. (void) argc;
  24. (void) argv;
  25. /* Start the graphic system */
  26. if (!mx_gfx_start(0))
  27. return 1;
  28. /* Load in the bitmap */
  29. bitmap = mx_bitmap_tga("title.tga");
  30. if (!bitmap)
  31. return 2;
  32. /* Make the bitmap pixels transparent */
  33. for (i = 0; i <= (unsigned) mx_h(bitmap); i++) {
  34. MX_BITMAP_ITER start = mx_bitmap_iter(bitmap, 0, i);
  35. const MX_BITMAP_ITER end = mx_bitmap_iter(bitmap, mx_w(bitmap), i);
  36. while (start != end) {
  37. *start = MXTRANS(*start, (i * 0xff) / mx_h(bitmap));
  38. ++start;
  39. }
  40. }
  41. /* Tell what the redraw funtion is */
  42. mx_gfx_redraw(draw);
  43. /* Main loop */
  44. while (mx_gfx_poll()) {
  45. /* Move the pointer */
  46. mx_gfx_pointer(0, 0, 0);
  47. /* Exit when key is hit */
  48. if (mx_gfx_key(0, 0))
  49. break;
  50. }
  51. /* Free the bitmap */
  52. mx_delete(bitmap);
  53. return 0;
  54. }