Search
lxdream.org :: lxdream/src/lxdream.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/lxdream.h
changeset 1159:580436b01b6c
prev1109:700c5ab26a63
next1292:799fdd4f704a
author nkeynes
date Wed Jan 19 17:50:09 2011 +1000 (9 years ago)
permissions -rw-r--r--
last change Implement vertex array range support, and move buffer operations to gl_vbo.c
file annotate diff log raw
nkeynes@477
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@477
     3
 *
nkeynes@477
     4
 * Common type definitions and forward declarations
nkeynes@477
     5
 *
nkeynes@477
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@477
     7
 *
nkeynes@477
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@477
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@477
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@477
    11
 * (at your option) any later version.
nkeynes@477
    12
 *
nkeynes@477
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@477
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@477
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@477
    16
 * GNU General Public License for more details.
nkeynes@477
    17
 */
nkeynes@477
    18
nkeynes@736
    19
#ifndef lxdream_lxdream_H
nkeynes@736
    20
#define lxdream_lxdream_H 1
nkeynes@477
    21
nkeynes@477
    22
#include <stdint.h>
nkeynes@477
    23
#include <glib/gtypes.h>
nkeynes@477
    24
nkeynes@507
    25
#include "../config.h"
nkeynes@507
    26
nkeynes@477
    27
#ifdef __cplusplus
nkeynes@477
    28
extern "C" {
nkeynes@477
    29
#endif
nkeynes@477
    30
nkeynes@738
    31
#define APP_NAME PACKAGE
nkeynes@738
    32
extern const char lxdream_package_name[];
nkeynes@738
    33
extern const char lxdream_short_version[];
nkeynes@738
    34
extern const char lxdream_full_version[];
nkeynes@738
    35
extern const char lxdream_copyright[];
nkeynes@738
    36
nkeynes@477
    37
nkeynes@477
    38
#define MB *1024*1024
nkeynes@477
    39
#define KB *1024
nkeynes@477
    40
nkeynes@477
    41
#ifndef max
nkeynes@477
    42
#define max(a,b) ( (a) > (b) ? (a) : (b) )
nkeynes@477
    43
#endif
nkeynes@477
    44
nkeynes@502
    45
/**
nkeynes@569
    46
 * A 29-bit address in SH4 external address space
nkeynes@502
    47
 */
nkeynes@477
    48
typedef uint32_t sh4addr_t;
nkeynes@569
    49
nkeynes@569
    50
/**
nkeynes@569
    51
 * A 32-bit address in SH4 virtual address space.
nkeynes@569
    52
 */
nkeynes@569
    53
typedef uint32_t sh4vma_t;
nkeynes@569
    54
nkeynes@502
    55
/**
nkeynes@502
    56
 * A direct pointer into SH4 memory
nkeynes@502
    57
 */
nkeynes@502
    58
typedef unsigned char *sh4ptr_t;
nkeynes@477
    59
nkeynes@477
    60
/******************* Forward type declarations ******************/
nkeynes@477
    61
nkeynes@477
    62
typedef struct render_buffer *render_buffer_t;
nkeynes@477
    63
typedef struct frame_buffer *frame_buffer_t;
nkeynes@1159
    64
typedef struct vertex_buffer *vertex_buffer_t;
nkeynes@477
    65
nkeynes@477
    66
/*************************** Logging ****************************/
nkeynes@477
    67
nkeynes@477
    68
#define EMIT_FATAL 0
nkeynes@477
    69
#define EMIT_ERR 1
nkeynes@477
    70
#define EMIT_WARN 2
nkeynes@477
    71
#define EMIT_INFO 3
nkeynes@477
    72
#define EMIT_DEBUG 4
nkeynes@477
    73
#define EMIT_TRACE 5
nkeynes@477
    74
nkeynes@477
    75
#ifdef MODULE
nkeynes@477
    76
#define MODULE_NAME MODULE.name
nkeynes@477
    77
#else
nkeynes@477
    78
#define MODULE_NAME "*****"
nkeynes@477
    79
#endif
nkeynes@477
    80
nkeynes@556
    81
gboolean set_global_log_level( const gchar *level );
nkeynes@477
    82
void log_message( void *, int level, const char *source, const char *msg, ... );
nkeynes@477
    83
nkeynes@477
    84
#define FATAL( ... ) log_message( NULL, EMIT_FATAL, MODULE_NAME, __VA_ARGS__ )
nkeynes@477
    85
#define ERROR( ... ) log_message( NULL, EMIT_ERR, MODULE_NAME, __VA_ARGS__ )
nkeynes@477
    86
#define WARN( ... ) log_message( NULL, EMIT_WARN, MODULE_NAME, __VA_ARGS__ )
nkeynes@477
    87
#define INFO( ... ) log_message( NULL, EMIT_INFO, MODULE_NAME, __VA_ARGS__ )
nkeynes@477
    88
#define DEBUG( ... ) log_message( NULL, EMIT_DEBUG, MODULE_NAME, __VA_ARGS__ )
nkeynes@477
    89
#define TRACE( ... ) log_message( NULL, EMIT_TRACE, MODULE_NAME, __VA_ARGS__ )
nkeynes@477
    90
nkeynes@1096
    91
/* Error reporting */
nkeynes@1096
    92
#define MAX_ERROR_MSG_SIZE 512
nkeynes@1096
    93
typedef struct error_struct {
nkeynes@1096
    94
    unsigned int code;
nkeynes@1096
    95
    char msg[MAX_ERROR_MSG_SIZE];
nkeynes@1096
    96
} ERROR;
nkeynes@1096
    97
nkeynes@1109
    98
#define LX_ERR_NONE          0
nkeynes@1109
    99
#define LX_ERR_NOMEM         1  /* Out-of-memory */
nkeynes@1109
   100
#define LX_ERR_CONFIG        2  /* Configuration problem */
nkeynes@1109
   101
#define LX_ERR_UNHANDLED     3  /* A lower-level error occurred which we don't understand */
nkeynes@1109
   102
#define LX_ERR_BUG           4
nkeynes@1109
   103
#define LX_ERR_FILE_NOOPEN   9  /* File could not be opened (ENOENT or EACCESS usually) */
nkeynes@1109
   104
#define LX_ERR_FILE_IOERROR 10  /* I/O error encountered in file */
nkeynes@1109
   105
#define LX_ERR_FILE_INVALID 11  /* File contents are invalid for its type */
nkeynes@1109
   106
#define LX_ERR_FILE_UNKNOWN 12  /* File type is unrecognized */
nkeynes@1109
   107
#define LX_ERR_FILE_UNSUP   13  /* File type is unsupported */
nkeynes@1109
   108
nkeynes@1096
   109
#define SET_ERROR(err, n, ...) if( (err) != NULL ) { (err)->code = n; snprintf( (err)->msg, sizeof((err)->msg), __VA_ARGS__ ); }
nkeynes@1109
   110
#define CLEAR_ERROR(err) do { (err)->code = 0; (err)->msg[0] = 0; } while(0)
nkeynes@1096
   111
nkeynes@477
   112
nkeynes@905
   113
#ifdef HAVE_FASTCALL
nkeynes@939
   114
#define FASTCALL __attribute__((regparm(2)))
nkeynes@905
   115
#else
nkeynes@905
   116
#define FASTCALL
nkeynes@905
   117
#endif
nkeynes@477
   118
nkeynes@477
   119
#ifdef __cplusplus
nkeynes@477
   120
}
nkeynes@477
   121
#endif
nkeynes@477
   122
nkeynes@736
   123
#endif /* !lxdream_lxdream_H */
.