aboutsummaryrefslogtreecommitdiff
path: root/src/osc_graphics.h
blob: 2a08678b0e562ae6fe4154549db2b8d48b22c16e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef __OSC_GRAPHICS_H
#define __OSC_GRAPHICS_H

#include <stdio.h>

#include <SDL.h>

#include "osc_server.h"
#include "layer.h"

/*
 * Macros
 */
#define NARRAY(ARRAY) \
	(sizeof(ARRAY) / sizeof((ARRAY)[0]))

#define SDL_MAYBE_LOCK(SURFACE) do {		\
	if (SDL_MUSTLOCK(SURFACE))		\
		SDL_LockSurface(SURFACE);	\
} while (0)

#define SDL_MAYBE_UNLOCK(SURFACE) do {		\
	if (SDL_MUSTLOCK(SURFACE))		\
		SDL_UnlockSurface(SURFACE);	\
} while (0)

#define SDL_FREESURFACE_SAFE(SURFACE) do {	\
	if (SURFACE) {				\
		SDL_FreeSurface(SURFACE);	\
		SURFACE = NULL;			\
	}					\
} while (0)

#define SDL_ERROR(FMT, ...) do {					\
	fprintf(stderr, "%s(%d): " FMT ": %s\n",			\
		__FILE__, __LINE__, ##__VA_ARGS__, SDL_GetError());	\
} while (0)
	
/*
 * Declarations
 */
extern SDL_Surface *screen;

extern int config_dump_osc;

#endif