Changeset 2138 for libcaca/trunk/caca
- Timestamp:
- Dec 16, 2007, 2:50:41 AM (12 years ago)
- Location:
- libcaca/trunk/caca
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca.c
r2137 r2138 38 38 39 39 #if defined(USE_PLUGINS) 40 # define gl_install(p) caca_plugin_install( "gl", p)41 # define x11_install(p) caca_plugin_install( "x11", p)40 # define gl_install(p) caca_plugin_install(p, "gl") 41 # define x11_install(p) caca_plugin_install(p, "x11") 42 42 #endif 43 43 44 44 static int caca_can_resize(caca_display_t *); 45 static int caca_select_driver(caca_display_t * );45 static int caca_select_driver(caca_display_t *, char const *); 46 46 #if defined(USE_PLUGINS) 47 47 static int caca_plugin_install(char const *, caca_display_t *); … … 59 59 * caca_free_display() is called. 60 60 * 61 * See also caca_create_display_with_driver(). 62 * 61 63 * If an error occurs, NULL is returned and \b errno is set accordingly: 62 64 * - \c ENOMEM Not enough memory. 63 65 * - \c ENODEV Graphical device could not be initialised. 64 66 * 65 * \param cv The cucul ca vas.67 * \param cv The cucul canvas or NULL to create a canvas automatically. 66 68 * \return The caca graphical context or NULL if an error occurred. 67 69 */ 68 70 caca_display_t * caca_create_display(cucul_canvas_t *cv) 71 { 72 return caca_create_display_with_driver(cv, NULL); 73 } 74 75 /** \brief Attach a caca graphical context to a cucul canvas. 76 * 77 * Create a graphical context using device-dependent features (ncurses for 78 * terminals, an X11 window, a DOS command window...) that attaches to a 79 * libcucul canvas. Everything that gets drawn in the libcucul canvas can 80 * then be displayed by the libcaca driver. 81 * 82 * If no cucul canvas is provided, a new one is created. Its handle can be 83 * retrieved using caca_get_canvas() and it is automatically destroyed when 84 * caca_free_display() is called. 85 * 86 * See also caca_create_display(). 87 * 88 * If an error occurs, NULL is returned and \b errno is set accordingly: 89 * - \c ENOMEM Not enough memory. 90 * - \c ENODEV Graphical device could not be initialised. 91 * 92 * \param cv The cucul canvas or NULL to create a canvas automatically. 93 * \param driver A string describing the desired output driver or NULL to 94 * choose the best driver automatically. 95 * \return The caca graphical context or NULL if an error occurred. 96 */ 97 caca_display_t * caca_create_display_with_driver(cucul_canvas_t *cv, 98 char const *driver) 69 99 { 70 100 caca_display_t *dp = malloc(sizeof(caca_display_t)); … … 96 126 #endif 97 127 98 if(caca_select_driver(dp ))128 if(caca_select_driver(dp, driver)) 99 129 { 100 130 #if defined(USE_PLUGINS) … … 155 185 } 156 186 187 /** \brief Return the current output driver 188 * 189 * Return the given display's current output driver. 190 * 191 * This function never fails. 192 * 193 * \param dp The caca display. 194 * \return A static string. 195 */ 196 char const * caca_get_display_driver(caca_display_t *dp) 197 { 198 return dp->drv.driver; 199 } 200 157 201 /** \brief Detach a caca graphical context from a cucul backend context. 158 202 * … … 224 268 * \return An array of strings. 225 269 */ 226 char const * const * caca_get_display_driver_list( caca_display_t *dp)270 char const * const * caca_get_display_driver_list(void) 227 271 { 228 272 static char const * const list[] = … … 270 314 } 271 315 272 static int caca_select_driver(caca_display_t *dp) 273 { 274 #if defined(HAVE_GETENV) && defined(HAVE_STRCASECMP) 275 char *var = getenv("CACA_DRIVER"); 276 316 static int caca_select_driver(caca_display_t *dp, char const *driver) 317 { 318 char const *var = driver; 319 #if defined(HAVE_GETENV) 320 if(!var) 321 var = getenv("CACA_DRIVER"); 322 #endif 323 324 #if defined(HAVE_STRCASECMP) 277 325 /* If the environment variable was set, use it */ 278 326 if(var && *var) … … 340 388 341 389 #if defined(USE_PLUGINS) 342 static int caca_plugin_install(c har const *name, caca_display_t *dp)390 static int caca_plugin_install(caca_display_t *dp, char const *driver) 343 391 { 344 392 char buf[512]; 345 393 int (*sym) (caca_display_t *); 346 394 347 sprintf(buf, "%s/lib%s_plugin.so", PLUGINDIR, name);395 sprintf(buf, "%s/lib%s_plugin.so", PLUGINDIR, driver); 348 396 dp->plugin = dlopen(buf, RTLD_NOW); 349 397 if(!dp->plugin) 350 398 { 351 sprintf(buf, "lib%s_plugin.so", name);399 sprintf(buf, "lib%s_plugin.so", driver); 352 400 dp->plugin = dlopen(buf, RTLD_NOW); 353 401 if(!dp->plugin) … … 355 403 } 356 404 357 sprintf(buf, "%s_install", name);405 sprintf(buf, "%s_install", driver); 358 406 sym = dlsym(dp->plugin, buf); 359 407 if(!sym) -
libcaca/trunk/caca/caca.h
r2135 r2138 155 155 * @{ */ 156 156 __extern caca_display_t * caca_create_display(cucul_canvas_t *); 157 __extern caca_display_t * caca_create_display_with_driver(cucul_canvas_t *, 158 char const *); 159 __extern char const * caca_get_display_driver(caca_display_t *); 157 160 __extern int caca_free_display(caca_display_t *); 158 161 __extern cucul_canvas_t * caca_get_canvas(caca_display_t *); 159 162 __extern int caca_refresh_display(caca_display_t *); 160 __extern char const * const * caca_get_display_driver_list( caca_display_t *);163 __extern char const * const * caca_get_display_driver_list(void); 161 164 __extern int caca_set_display_time(caca_display_t *, unsigned int); 162 165 __extern unsigned int caca_get_display_time(caca_display_t const *); -
libcaca/trunk/caca/caca_internals.h
r2061 r2138 118 118 struct drv 119 119 { 120 enum caca_driver driver; 120 char const * driver; 121 enum caca_driver id; 121 122 struct driver_private *p; 122 123 -
libcaca/trunk/caca/driver_cocoa.m
r2129 r2138 998 998 int cocoa_install(caca_display_t *dp) 999 999 { 1000 dp->drv.driver = CACA_DRIVER_RAW; 1000 dp->drv.id = CACA_DRIVER_COCOA; 1001 dp->drv.driver = "cocoa"; 1001 1002 1002 1003 dp->drv.init_graphics = cocoa_init_graphics; -
libcaca/trunk/caca/driver_conio.c
r2056 r2138 167 167 int conio_install(caca_display_t *dp) 168 168 { 169 dp->drv.driver = CACA_DRIVER_CONIO; 169 dp->drv.id = CACA_DRIVER_CONIO; 170 dp->drv.driver = "conio"; 170 171 171 172 dp->drv.init_graphics = conio_init_graphics; -
libcaca/trunk/caca/driver_gl.c
r2057 r2138 598 598 #endif 599 599 600 dp->drv.driver = CACA_DRIVER_GL; 600 dp->drv.id = CACA_DRIVER_GL; 601 dp->drv.driver = "gl"; 601 602 602 603 dp->drv.init_graphics = gl_init_graphics; -
libcaca/trunk/caca/driver_ncurses.c
r2056 r2138 809 809 int ncurses_install(caca_display_t *dp) 810 810 { 811 dp->drv.driver = CACA_DRIVER_NCURSES; 811 dp->drv.id = CACA_DRIVER_NCURSES; 812 dp->drv.driver = "ncurses"; 812 813 813 814 dp->drv.init_graphics = ncurses_init_graphics; -
libcaca/trunk/caca/driver_raw.c
r2056 r2138 98 98 int raw_install(caca_display_t *dp) 99 99 { 100 dp->drv.driver = CACA_DRIVER_RAW; 100 dp->drv.id = CACA_DRIVER_RAW; 101 dp->drv.driver = "raw"; 101 102 102 103 dp->drv.init_graphics = raw_init_graphics; -
libcaca/trunk/caca/driver_slang.c
r2056 r2138 523 523 int slang_install(caca_display_t *dp) 524 524 { 525 dp->drv.driver = CACA_DRIVER_SLANG; 525 dp->drv.id = CACA_DRIVER_SLANG; 526 dp->drv.driver = "slang"; 526 527 527 528 dp->drv.init_graphics = slang_init_graphics; -
libcaca/trunk/caca/driver_vga.c
r2056 r2138 160 160 int vga_install(caca_display_t *dp) 161 161 { 162 dp->drv.driver = CACA_DRIVER_VGA; 162 dp->drv.id = CACA_DRIVER_VGA; 163 dp->drv.driver = "vga"; 163 164 164 165 dp->drv.init_graphics = vga_init_graphics; -
libcaca/trunk/caca/driver_win32.c
r2056 r2138 350 350 int win32_install(caca_display_t *dp) 351 351 { 352 dp->drv.driver = CACA_DRIVER_WIN32; 352 dp->drv.id = CACA_DRIVER_WIN32; 353 dp->drv.driver = "win32"; 353 354 354 355 dp->drv.init_graphics = win32_init_graphics; -
libcaca/trunk/caca/driver_x11.c
r2057 r2138 790 790 #endif 791 791 792 dp->drv.driver = CACA_DRIVER_X11; 792 dp->drv.id = CACA_DRIVER_X11; 793 dp->drv.driver = "x11"; 793 794 794 795 dp->drv.init_graphics = x11_init_graphics; -
libcaca/trunk/caca/event.c
r2056 r2138 345 345 346 346 #if defined(USE_SLANG) 347 if(dp->drv. driver!= CACA_DRIVER_SLANG)347 if(dp->drv.id != CACA_DRIVER_SLANG) 348 348 #endif 349 349 #if defined(USE_NCURSES) 350 if(dp->drv. driver!= CACA_DRIVER_NCURSES)350 if(dp->drv.id != CACA_DRIVER_NCURSES) 351 351 #endif 352 352 return ret;
Note: See TracChangeset
for help on using the changeset viewer.