Search
lxdream.org :: lxdream/src/plugin.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/plugin.h
changeset 1169:23a9613aceb1
prev1027:4e527bc96109
author nkeynes
date Thu Feb 23 15:24:47 2012 +1000 (12 years ago)
permissions -rw-r--r--
last change Check for existence of glDrawBuffer (assuming that glReadBuffer will
follow). Note only need to guard the common code in gl_fbo.c
file annotate diff log raw
nkeynes@1024
     1
/**
nkeynes@1024
     2
 * $Id$
nkeynes@1024
     3
 *
nkeynes@1024
     4
 * Plugin declarations and support. 
nkeynes@1024
     5
 * 
nkeynes@1024
     6
 * Note plugins mainly exist to make binary packagers' lives easier, 
nkeynes@1024
     7
 *
nkeynes@1024
     8
 * Copyright (c) 2009 Nathan Keynes.
nkeynes@1024
     9
 *
nkeynes@1024
    10
 * This program is free software; you can redistribute it and/or modify
nkeynes@1024
    11
 * it under the terms of the GNU General Public License as published by
nkeynes@1024
    12
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@1024
    13
 * (at your option) any later version.
nkeynes@1024
    14
 *
nkeynes@1024
    15
 * This program is distributed in the hope that it will be useful,
nkeynes@1024
    16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@1024
    17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@1024
    18
 * GNU General Public License for more details.
nkeynes@1024
    19
 */
nkeynes@1024
    20
nkeynes@1024
    21
#ifndef lxdream_plugin_H
nkeynes@1024
    22
#define lxdream_plugin_H
nkeynes@1024
    23
nkeynes@1024
    24
#include "lxdream.h"
nkeynes@1024
    25
nkeynes@1024
    26
#ifdef __cplusplus
nkeynes@1024
    27
extern "C" {
nkeynes@1024
    28
#endif
nkeynes@1024
    29
nkeynes@1024
    30
enum plugin_type {
nkeynes@1024
    31
    PLUGIN_NONE = 0,
nkeynes@1024
    32
    PLUGIN_AUDIO_DRIVER = 1,
nkeynes@1024
    33
    PLUGIN_INPUT_DRIVER = 2,
nkeynes@1024
    34
};
nkeynes@1024
    35
nkeynes@1024
    36
#define PLUGIN_MIN_TYPE 1
nkeynes@1024
    37
#define PLUGIN_MAX_TYPE PLUGIN_INPUT_DRIVER
nkeynes@1024
    38
    
nkeynes@1024
    39
struct plugin_struct {
nkeynes@1024
    40
    enum plugin_type type;
nkeynes@1024
    41
    const char *name;
nkeynes@1024
    42
    const char *version;
nkeynes@1024
    43
    
nkeynes@1024
    44
    /**
nkeynes@1024
    45
     * Plugin registration function, called at load time (dynamic modules) or 
nkeynes@1024
    46
     * startup (static modules). This should register with the appropriate 
nkeynes@1024
    47
     * driver list. 
nkeynes@1024
    48
     * @return TRUE on success, FALSE on failure (although exactly how this 
nkeynes@1024
    49
     * can fail is unclear).
nkeynes@1024
    50
     */
nkeynes@1024
    51
    gboolean (*register_plugin)(void);
nkeynes@1024
    52
};
nkeynes@1024
    53
nkeynes@1024
    54
#define CONSTRUCTOR __attribute__((constructor))
nkeynes@1024
    55
nkeynes@1024
    56
#ifdef PLUGIN
nkeynes@1024
    57
#define DEFINE_PLUGIN(type,name,fn) struct plugin_struct lxdream_plugin_entry = { type, name, VERSION, fn }
nkeynes@1024
    58
#define AUDIO_DRIVER(name, driver) static gboolean __lxdream_plugin_init(void) { return audio_register_driver(&(driver)); }  \
nkeynes@1024
    59
    DEFINE_PLUGIN(PLUGIN_AUDIO_DRIVER, name, __lxdream_plugin_init)
nkeynes@1024
    60
nkeynes@1024
    61
#else /* !ENABLE_SHARED */
nkeynes@1024
    62
#define AUDIO_DRIVER(name,driver) static void CONSTRUCTOR __lxdream_static_constructor(void) { audio_register_driver(&(driver)); } 
nkeynes@1024
    63
#define DEFINE_PLUGIN(type,name,fn) static void CONSTRUCTOR __lxdream_static_constructor(void) { fn(); }
nkeynes@1024
    64
nkeynes@1024
    65
#endif /* ENABLE_SHARED */
nkeynes@1024
    66
nkeynes@1027
    67
gboolean plugin_init();
nkeynes@1024
    68
nkeynes@1024
    69
#ifdef __cplusplus
nkeynes@1024
    70
}
nkeynes@1024
    71
#endif
nkeynes@1024
    72
    
nkeynes@1169
    73
#endif /* !lxdream_plugin_H */
.