src/video/directfb/SDL_DirectFB_video.h
author Sam Lantinga
Sun, 31 Aug 2008 16:04:32 +0000
changeset 2737 140a7edcf2bd
parent 2721 e82a0e3e9b0e
child 2859 99210400e8b9
permissions -rw-r--r--
Date: Sun, 31 Aug 2008 17:53:59 +0200
From: Couriersud
Subject: Re: Updated DirectFB driver for SDL1.3

attached is a patch which brings the directfb driver in line with
current svn. In addition:

* driver now is in line with the structure of the X11 driver.
This adds a couple of files.
* driver now supports relative mouse movements
slouken@167
     1
/*
slouken@167
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@167
     4
slouken@167
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@167
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@167
     9
slouken@167
    10
    This library is distributed in the hope that it will be useful,
slouken@167
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@167
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@167
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@167
    18
slouken@167
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@167
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@167
    23
slouken@167
    24
#ifndef _SDL_DirectFB_video_h
slouken@167
    25
#define _SDL_DirectFB_video_h
slouken@167
    26
slouken@2737
    27
#include "../SDL_sysvideo.h"
slouken@2737
    28
slouken@167
    29
#include <directfb.h>
slouken@2226
    30
#include <directfb_version.h>
slouken@2226
    31
slouken@2737
    32
#include "SDL_mouse.h"
slouken@2737
    33
slouken@2737
    34
#define DEBUG 0
slouken@2226
    35
#define LOG_CHANNEL 	stdout
slouken@2226
    36
slouken@2226
    37
#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
slouken@2226
    38
#error "SDL_DIRECTFB: Please compile against libdirectfb version >=0.9.24"
slouken@2226
    39
#endif
slouken@2226
    40
slouken@2226
    41
#if (DIRECTFB_MAJOR_VERSION >= 1) && (DIRECTFB_MINOR_VERSION >= 0) && (DIRECTFB_MICRO_VERSION >= 0 )
slouken@2226
    42
#define SDL_DIRECTFB_OPENGL 1
slouken@2226
    43
#include <directfbgl.h>
slouken@2226
    44
#endif
slouken@2226
    45
slouken@2226
    46
#if SDL_DIRECTFB_OPENGL
slouken@2226
    47
#include "SDL_loadso.h"
slouken@2226
    48
#endif
slouken@167
    49
slouken@2737
    50
#include "SDL_DirectFB_events.h"
slouken@2737
    51
/*
slouken@2737
    52
 * #include "SDL_DirectFB_gamma.h"
slouken@2737
    53
 * #include "SDL_DirectFB_keyboard.h"
slouken@2737
    54
 */
slouken@2737
    55
#include "SDL_DirectFB_modes.h"
slouken@2737
    56
#include "SDL_DirectFB_mouse.h"
slouken@2737
    57
#include "SDL_DirectFB_opengl.h"
slouken@2737
    58
#include "SDL_DirectFB_window.h"
slouken@167
    59
slouken@2737
    60
#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY"
slouken@2737
    61
#define DFBENV_USE_YUV_DIRECT   "SDL_DIRECTFB_YUV_DIRECT"
slouken@2226
    62
slouken@2226
    63
#define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
slouken@2226
    64
#define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
slouken@2226
    65
#define SDL_DFB_UNLOCK(x) do { if ( x ) { x->Unlock(x); } } while (0)
slouken@2226
    66
slouken@2226
    67
#if DEBUG
slouken@2226
    68
#define SDL_DFB_DEBUG(x...) do { fprintf(LOG_CHANNEL, "%s:", __FUNCTION__); fprintf(LOG_CHANNEL, x); } while (0)
slouken@2226
    69
#define SDL_DFB_DEBUGC(x...) do { fprintf(LOG_CHANNEL, x); } while (0)
slouken@2226
    70
#else
slouken@2226
    71
#define SDL_DFB_DEBUG(x...) do { } while (0)
slouken@2226
    72
#define SDL_DFB_DEBUGC(x...) do { } while (0)
slouken@2226
    73
#endif
slouken@2226
    74
slouken@2226
    75
#define SDL_DFB_CONTEXT "SDL_DirectFB"
slouken@2226
    76
slouken@2226
    77
#define SDL_DFB_ERR(x...) 							\
slouken@2226
    78
	do {											\
slouken@2226
    79
		fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t",			\
slouken@2226
    80
			SDL_DFB_CONTEXT, __FILE__, __LINE__ );	\
slouken@2226
    81
		fprintf(LOG_CHANNEL, x );						\
slouken@2226
    82
	} while (0)
slouken@2226
    83
slouken@2226
    84
#define SDL_DFB_CHECK(x...) \
slouken@2226
    85
     do {                                                                \
slouken@2226
    86
          ret = x;                                                    \
slouken@2226
    87
          if (ret != DFB_OK) {                                        \
slouken@2226
    88
               fprintf(LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); 	      \
slouken@2226
    89
               SDL_SetError( #x, DirectFBErrorString (ret) );         \
slouken@2226
    90
          }                                                           \
slouken@2226
    91
     } while (0)
slouken@2226
    92
slouken@2226
    93
#define SDL_DFB_CHECKERR(x...) \
slouken@2226
    94
     do {                                                                \
slouken@2226
    95
          ret = x;                                                    \
slouken@2226
    96
          if (ret != DFB_OK) {                                        \
slouken@2226
    97
               fprintf(LOG_CHANNEL, "%s <%d>:\n", __FILE__, __LINE__ ); \
slouken@2226
    98
               fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
slouken@2226
    99
               fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
slouken@2226
   100
               SDL_SetError( #x, DirectFBErrorString (ret) );         \
slouken@2226
   101
               goto error; 					      \
slouken@2226
   102
          }                                                           \
slouken@2226
   103
     } while (0)
slouken@2226
   104
slouken@2226
   105
#define SDL_DFB_CALLOC(r, n, s) \
slouken@2226
   106
     do {                                                                \
slouken@2226
   107
          r = SDL_calloc (n, s);                                      \
slouken@2226
   108
          if (!(r)) {                                                 \
slouken@2226
   109
               fprintf( LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
slouken@2226
   110
               SDL_OutOfMemory();                                     \
slouken@2226
   111
               goto error; 					      \
slouken@2226
   112
          }                                                           \
slouken@2226
   113
     } while (0)
slouken@167
   114
slouken@167
   115
/* Private display data */
slouken@167
   116
slouken@2226
   117
#define SDL_DFB_DEVICEDATA(dev)  DFB_DeviceData *devdata = (DFB_DeviceData *) ((dev)->driverdata)
slouken@2226
   118
slouken@2226
   119
#define DFB_MAX_SCREENS 10
slouken@2226
   120
slouken@2226
   121
typedef struct _DFB_DeviceData DFB_DeviceData;
slouken@2226
   122
struct _DFB_DeviceData
slouken@167
   123
{
slouken@1895
   124
    int initialized;
slouken@167
   125
slouken@1895
   126
    IDirectFB *dfb;
slouken@2226
   127
    int mouse;
slouken@2226
   128
    int keyboard;
slouken@2721
   129
    int kbdgeneric;
slouken@2226
   130
    DFB_WindowData *firstwin;
icculus@728
   131
slouken@2737
   132
    int use_yuv_underlays;
slouken@2226
   133
slouken@2721
   134
    /* OpenGL */
slouken@2226
   135
    void (*glFinish) (void);
slouken@2226
   136
    void (*glFlush) (void);
slouken@167
   137
slouken@2737
   138
    /* global events */
slouken@2737
   139
    IDirectFBEventBuffer *events;
slouken@2226
   140
};
slouken@478
   141
slouken@167
   142
#endif /* _SDL_DirectFB_video_h */