misc/openalbridge/globals.h
author smxx
Fri, 28 May 2010 20:05:22 +0000
changeset 3485 ab91c56a9050
parent 3364 e5403e2bf02c
child 3513 f589230fa21b
permissions -rw-r--r--
Engine (Henek): * Moved some utility weapons to a new 10th row * Added adjustable flame output to Flamethrower (left/right controls power/intensity) * Added fuel display to flame thrower Frontend: * Added support to bind the new 10th row (default: F10)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     1
/*
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     2
 * OpenAL Bridge - a simple portable library for OpenAL interface
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     3
 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     4
 *
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     6
 * it under the terms of the GNU Lesser General Public License as published by
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     8
 *
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    12
 * GNU Lesser General Public License for more details.
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    13
 *
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    14
 * You should have received a copy of the GNU Lesser General Public License
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    17
 */
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    18
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    19
#ifndef _OALB_GLOBALS_H
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    20
#define _OALB_GLOBALS_H
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    21
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    22
#include <stdio.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    23
#include <stdlib.h>
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    24
#include "al.h"
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    25
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    26
#ifndef _WIN32
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    27
#include <pthread.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    28
#include <syslog.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    29
#else
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    30
#include <process.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    31
#endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    32
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    33
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    34
// control debug verbosity
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    35
#ifdef TRACE
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    36
#ifndef DEBUG
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    37
#define DEBUG
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    38
#endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    39
#endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    40
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    41
// 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei]
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    42
#ifndef _SLEEP_H
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    43
#define _SLEEP_H
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    44
#ifdef _WIN32
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    45
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__))
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    46
#  include <stdlib.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    47
#  define sleep(t) _sleep((t) * 1000)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    48
# else
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    49
#  define WIN32_LEAN_AND_MEAN
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    50
#  include <windows.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    51
#  define sleep(t)  Sleep((t) * 1000)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    52
# endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    53
# ifndef _NEED_SLEEP_ONLY
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    54
#  define msleep(t) Sleep(t)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    55
#  define usleep(t) Sleep((t) / 1000)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    56
# endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    57
#else
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    58
# include <unistd.h>
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    59
# ifndef _NEED_SLEEP_ONLY
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    60
#  define msleep(t) usleep((t) * 1000)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    61
# endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    62
#endif
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    63
#endif // _SLEEP_H
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    64
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    65
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    66
// check compiler requirements
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    67
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    68
#warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    69
#define __LITTLE_ENDIAN__ 1
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    70
#endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    71
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    72
/* use byteswap macros from the host system, hopefully optimized ones ;-)
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    73
 * or define our own version, simple, stupid, straight-forward... */
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    74
#ifdef HAVE_BYTESWAP_H
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    75
#include <byteswap.h>
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    76
#else
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    77
#define bswap_16(x)	(((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8))
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    78
#define bswap_32(x)	(((x & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8)  | \
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    79
                     ((x & 0x0000FF00) << 8)  | (((x) & 0x000000FF) << 24) )
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    80
#endif /* HAVE_BYTESWAP_H */
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    81
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    82
/* swap numbers accordingly to architecture automatically */
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    83
#ifdef __LITTLE_ENDIAN__
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    84
#define ENDIAN_LITTLE_32(x) x
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    85
#define ENDIAN_BIG_32(x)    bswap_32(x)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    86
#define ENDIAN_LITTLE_16(x) x
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    87
#define ENDIAN_BIG_16(x)    bswap_16(x)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    88
#elif __BIG_ENDIAN__
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    89
#define ENDIAN_LITTLE_32(x) bswap_32(x)
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    90
#define ENDIAN_BIG_32(x)    x
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    91
#define ENDIAN_LITTLE_16(x) bswap_16(x)
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    92
#define ENDIAN_BIG_16(x)    x
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    93
#endif
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
    94
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    95
/*file format defines*/
3364
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    96
#define OGG_FILE_FORMAT         0x4F676753
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    97
#define WAV_FILE_FORMAT         0x52494646
e5403e2bf02c no more hardcoded teams, team selection is real \o/
koda
parents: 3362
diff changeset
    98
#define WAV_HEADER_SUBCHUNK2ID  0x64617461
3362
8d3b4d19ce27 in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents: 3360
diff changeset
    99
3353
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
   100
a767dd3786b5 OpenAL makes a comeback! (might require some cleanup)
koda
parents:
diff changeset
   101
#endif /*_OALB_GLOBALS_H*/