You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

166 lines
5.2 KiB

  1. /* $Id$ */
  2. /** \page migrating Migrating from libcaca 0.x to the 1.0 API
  3. This section will guide you through the migration of a \e libcaca 0.x
  4. application to the latest API version.
  5. \section foo1 Overview
  6. The most important changes in the 1.0 API of \e libcaca are the
  7. \e libcaca / \e libcucul split and the object-oriented design. Where
  8. you used to do:
  9. \code
  10. #include <caca.h>
  11. int main(void)
  12. {
  13. /* Initialise libcaca */
  14. caca_init();
  15. /* Set window title */
  16. caca_set_window_title("Hello!");
  17. /* Choose drawing colours */
  18. caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_WHITE);
  19. /* Draw a string at coordinates (0, 0) */
  20. caca_putstr(0, 0, "This is a message");
  21. /* Refresh display */
  22. caca_refresh();
  23. /* Wait for a key press event */
  24. caca_wait_event(CACA_EVENT_KEY_PRESS);
  25. /* Clean up library */
  26. caca_end();
  27. return 0;
  28. }
  29. \endcode
  30. You now do:
  31. \code
  32. #include <cucul.h>
  33. #include <caca.h>
  34. int main(void)
  35. {
  36. /* Initialise libcaca */
  37. cucul_canvas_t *cv; caca_display_t *dp; caca_event_t ev;
  38. cv = cucul_create_canvas(0, 0);
  39. dp = caca_create_display(cv);
  40. /* Set window title */
  41. caca_set_display_title(dp, "Hello!");
  42. /* Choose drawing colours */
  43. cucul_set_color(cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE);
  44. /* Draw a string at coordinates (0, 0) */
  45. cucul_putstr(cv, 0, 0, "This is a message");
  46. /* Refresh display */
  47. caca_refresh_display();
  48. /* Wait for a key press event */
  49. caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
  50. /* Clean up library */
  51. caca_free_display(dp);
  52. cucul_free_canvas(cv);
  53. return 0;
  54. }
  55. \endcode
  56. Note the following important things:
  57. - Functions now take an object handle as their first argument.
  58. - All input/output functions start with \b caca_ and all
  59. drawing and text handling functions start with \b cucul_ .
  60. \section foo2 Function equivalence list
  61. \subsection bar1 Basic functions
  62. - \b caca_init(): use cucul_create_canvas() to create a \e libcucul canvas,
  63. followed by caca_create_display() to attach a \e libcaca display to it.
  64. - \b caca_set_delay(): unchanged.
  65. - \b caca_get_feature(): deprecated.
  66. - \b caca_set_feature(): deprecated, see cucul_set_dither_antialias(),
  67. cucul_set_dither_color() and cucul_set_dither_mode() instead.
  68. - \b caca_get_feature_name(): deprecated, see cucul_get_dither_mode_list(),
  69. cucul_get_dither_antialias_list() and cucul_get_dither_color_list()
  70. instead.
  71. - \b caca_get_rendertime(): unchanged.
  72. - \b caca_get_width(): use cucul_get_canvas_width().
  73. - \b caca_get_height(): use cucul_get_canvas_height().
  74. - \b caca_set_window_title(): use caca_set_display_title().
  75. - \b caca_get_window_width(): use caca_get_display_width().
  76. - \b caca_get_window_height(): use caca_get_display_height().
  77. - \b caca_refresh(): use caca_refresh_display().
  78. - \b caca_end(): use caca_free_display() to detach the \e libcaca display,
  79. followed by cucul_free_canvas() to free the underlying \e libcucul canvas.
  80. \subsection bar2 Event handling
  81. - \b caca_get_event(): unchanged.
  82. - \b caca_wait_event(): use caca_get_event() with a \c timeout argument
  83. of \b -1.
  84. - \b caca_get_mouse_x(): unchanged.
  85. - \b caca_get_mouse_y(): unchanged.
  86. \subsection bar3 Character printing
  87. - \b caca_set_color(): use cucul_set_color() or cucul_set_truecolor().
  88. - \b caca_get_fg_color(): deprecated.
  89. - \b caca_get_bg_color(): deprecated.
  90. - \b caca_get_color_name(): use cucul_get_color_name().
  91. - \b caca_putchar(): use cucul_putchar().
  92. - \b caca_putstr(): use cucul_putstr().
  93. - \b caca_printf(): use cucul_printf().
  94. - \b caca_clear(): use cucul_clear_canvas().
  95. \subsection bar4 Primitives drawing
  96. - \b caca_draw_line(): use cucul_draw_line().
  97. - \b caca_draw_polyline(): use cucul_draw_polyline().
  98. - \b caca_draw_thin_line(): use cucul_draw_thin_line().
  99. - \b caca_draw_thin_polyline(): use cucul_draw_thin_polyline().
  100. - \b caca_draw_circle(): use cucul_draw_circle().
  101. - \b caca_draw_ellipse(): use cucul_draw_ellipse().
  102. - \b caca_draw_thin_ellipse(): use cucul_draw_thin_ellipse().
  103. - \b caca_fill_ellipse(): use cucul_fill_ellipse().
  104. - \b caca_draw_box(): use cucul_draw_box().
  105. - \b caca_draw_thin_box(): use cucul_draw_thin_box().
  106. - \b caca_fill_box(): use cucul_fill_box().
  107. - \b caca_draw_triangle(): use cucul_draw_triangle().
  108. - \b caca_draw_thin_triangle(): use cucul_draw_thin_triangle().
  109. - \b caca_fill_triangle(): use cucul_fill_triangle().
  110. \subsection bar5 Mathematical functions
  111. - \b caca_rand(): use cucul_rand()
  112. - \b caca_sqrt(): this function is now deprecated
  113. \subsection bar6 Sprite handling
  114. The sprite handling functions are currently being reworked.
  115. \subsection bar7 Bitmap handling
  116. - \b caca_create_bitmap(): use cucul_create_dither().
  117. - \b caca_set_bitmap_palette(): use cucul_set_dither_palette().
  118. - \b caca_draw_bitmap(): use cucul_dither_bitmap().
  119. - \b caca_free_bitmap(): use cucul_free_dither().
  120. \section foo3 Compilation
  121. The \c caca-config utility is deprecated in favour of the standard
  122. \c pkg-config interface:
  123. \code
  124. gcc -c foobar.c -o foobar.o `pkg-config --cflags caca`
  125. gcc foobar.o -o foobar `pkg-config --libs caca`
  126. \endcode
  127. \c caca-config is still provided as a convenience tool but will be removed
  128. in the future.
  129. */