openalbridge/wrappers.c
changeset 2191 20c62f787a4d
child 2194 1597710c6118
equal deleted inserted replaced
2190:cfcad6142d48 2191:20c62f787a4d
       
     1 /*
       
     2  * OpenAL Bridge - a simple portable library for OpenAL interface
       
     3  * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  */
       
    18 
       
    19 #include <stdio.h>
       
    20 #include <stdlib.h>
       
    21 #include "wrappers.h"
       
    22 #include "al.h"
       
    23 
       
    24 #ifdef __CPLUSPLUS
       
    25 extern "C" {
       
    26 #endif 
       
    27 	
       
    28 	void *Malloc (size_t nbytes)
       
    29 	{
       
    30 		void *aptr;
       
    31 		if ( (aptr = malloc(nbytes)) == NULL)
       
    32 			fprintf(stderr, "ERROR: not enough memory! malloc() failed");
       
    33 		return aptr;
       
    34 	}
       
    35 	
       
    36 	FILE *Fopen (const char *fname, char *mode)
       
    37 	{
       
    38 		FILE *fp;
       
    39 		if ((fp=fopen(fname,mode)) == NULL)
       
    40 			fprintf (stderr, "ERROR: can't open file %s in mode '%s'", fname, mode);
       
    41 		return fp;
       
    42 	}
       
    43 	
       
    44 	ALint AlGetError (const char *str) {
       
    45 		ALenum error;
       
    46 		
       
    47 		error = alGetError();
       
    48 		if (error != AL_NO_ERROR) {
       
    49 			fprintf(stderr, str, error);
       
    50 			return -2;
       
    51 		} else 
       
    52 			return AL_TRUE;
       
    53 	}
       
    54 	
       
    55 #ifdef __CPLUSPLUS
       
    56 }
       
    57 #endif