This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_DirectFB_video.h
169 lines (134 loc) · 5.61 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2010 Sam Lantinga
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
Sam Lantinga
20
slouken@libsdl.org
21
*/
22
#include "SDL_config.h"
23
24
25
26
#ifndef _SDL_DirectFB_video_h
#define _SDL_DirectFB_video_h
27
28
#include "../SDL_sysvideo.h"
29
#include <directfb.h>
30
31
#include <directfb_version.h>
32
33
#include "SDL_mouse.h"
34
35
36
37
38
39
40
41
/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in
* in case we see this again ...
*/
#define USE_MULTI_API (0)
#define DEBUG 1
42
43
#define LOG_CHANNEL stdout
44
45
46
47
48
49
50
51
#define DFB_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z))
#define DFB_COMPILEDVERSION \
DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION)
#define DFB_VERSION_ATLEAST(X, Y, Z) \
(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
52
53
#if (DFB_VERSION_ATLEAST(1,0,0))
54
55
#define SDL_DIRECTFB_OPENGL 1
#include <directfbgl.h>
56
#else
57
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
58
59
60
61
62
#endif
#if SDL_DIRECTFB_OPENGL
#include "SDL_loadso.h"
#endif
63
64
65
66
67
68
69
70
71
72
#include "SDL_DirectFB_events.h"
/*
* #include "SDL_DirectFB_gamma.h"
* #include "SDL_DirectFB_keyboard.h"
*/
#include "SDL_DirectFB_modes.h"
#include "SDL_DirectFB_mouse.h"
#include "SDL_DirectFB_opengl.h"
#include "SDL_DirectFB_window.h"
73
#include "SDL_DirectFB_WM.h"
74
75
76
77
78
#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */
#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */
#define DFBENV_USE_X11_CHECK "SDL_DIRECTFB_X11_CHECK" /* Default: on */
#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */
79
#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */
80
81
82
83
#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { x->Release(x); x = NULL; } } while (0)
#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0)
#define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#if DEBUG
#define SDL_DFB_DEBUG(x...) do { fprintf(LOG_CHANNEL, "%s:", __FUNCTION__); fprintf(LOG_CHANNEL, x); } while (0)
#define SDL_DFB_DEBUGC(x...) do { fprintf(LOG_CHANNEL, x); } while (0)
#else
#define SDL_DFB_DEBUG(x...) do { } while (0)
#define SDL_DFB_DEBUGC(x...) do { } while (0)
#endif
#define SDL_DFB_CONTEXT "SDL_DirectFB"
#define SDL_DFB_ERR(x...) \
do { \
fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \
SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \
fprintf(LOG_CHANNEL, x ); \
} while (0)
#define SDL_DFB_CHECK(x...) \
do { \
ret = x; \
if (ret != DFB_OK) { \
fprintf(LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
107
108
fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
SDL_SetError( #x, DirectFBErrorString (ret) ); \
} \
} while (0)
#define SDL_DFB_CHECKERR(x...) \
do { \
ret = x; \
if (ret != DFB_OK) { \
fprintf(LOG_CHANNEL, "%s <%d>:\n", __FILE__, __LINE__ ); \
fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
SDL_SetError( #x, DirectFBErrorString (ret) ); \
goto error; \
} \
} while (0)
#define SDL_DFB_CALLOC(r, n, s) \
do { \
r = SDL_calloc (n, s); \
if (!(r)) { \
fprintf( LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
SDL_OutOfMemory(); \
goto error; \
} \
} while (0)
134
135
136
/* Private display data */
137
#define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (dev ? (DFB_DeviceData *) ((dev)->driverdata) : NULL)
138
139
140
141
142
#define DFB_MAX_SCREENS 10
typedef struct _DFB_DeviceData DFB_DeviceData;
struct _DFB_DeviceData
143
{
144
145
146
int initialized;
IDirectFB *dfb;
147
148
149
150
151
152
153
154
int num_mice;
int mouse_id[0x100];
int num_keyboard;
struct
{
int is_generic;
int id;
} keyboard[10];
155
DFB_WindowData *firstwin;
156
157
int use_yuv_underlays;
158
int use_linux_input;
159
int has_own_wm;
160
161
/* OpenGL */
162
163
void (*glFinish) (void);
void (*glFlush) (void);
164
165
166
/* global events */
IDirectFBEventBuffer *events;
167
};
168
169
#endif /* _SDL_DirectFB_video_h */