2001-09-04 22:53:46 +00:00
|
|
|
/*
|
|
|
|
SDL - Simple DirectMedia Layer
|
2006-02-01 06:32:25 +00:00
|
|
|
Copyright (C) 1997-2006 Sam Lantinga
|
2001-09-04 22:53:46 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2006-02-01 06:32:25 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2001-09-04 22:53:46 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2006-02-01 06:32:25 +00:00
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2001-09-04 22:53:46 +00:00
|
|
|
|
|
|
|
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
|
2006-02-01 06:32:25 +00:00
|
|
|
Lesser General Public License for more details.
|
2001-09-04 22:53:46 +00:00
|
|
|
|
2006-02-01 06:32:25 +00:00
|
|
|
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
|
2001-09-04 22:53:46 +00:00
|
|
|
|
|
|
|
Sam Lantinga
|
2001-12-14 12:38:15 +00:00
|
|
|
slouken@libsdl.org
|
2001-09-04 22:53:46 +00:00
|
|
|
*/
|
2006-02-21 08:46:50 +00:00
|
|
|
#include "SDL_config.h"
|
2001-09-04 22:53:46 +00:00
|
|
|
|
|
|
|
#ifndef _SDL_DirectFB_video_h
|
|
|
|
#define _SDL_DirectFB_video_h
|
|
|
|
|
|
|
|
#include <directfb.h>
|
2007-08-11 21:51:19 +00:00
|
|
|
#include <directfb_version.h>
|
|
|
|
|
|
|
|
#define LOG_CHANNEL stdout
|
|
|
|
|
|
|
|
#if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
|
|
|
|
#error "SDL_DIRECTFB: Please compile against libdirectfb version >=0.9.24"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (DIRECTFB_MAJOR_VERSION >= 1) && (DIRECTFB_MINOR_VERSION >= 0) && (DIRECTFB_MICRO_VERSION >= 0 )
|
|
|
|
#define SDL_DIRECTFB_OPENGL 1
|
|
|
|
#include <directfbgl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if SDL_DIRECTFB_OPENGL
|
|
|
|
#include "SDL_loadso.h"
|
|
|
|
#endif
|
2001-09-04 22:53:46 +00:00
|
|
|
|
|
|
|
#include "SDL_mouse.h"
|
2006-02-16 10:11:48 +00:00
|
|
|
#include "../SDL_sysvideo.h"
|
2001-09-04 22:53:46 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
#define DEBUG 1
|
|
|
|
|
|
|
|
#define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
|
|
|
|
#define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
|
|
|
|
#define SDL_DFB_UNLOCK(x) do { if ( x ) { x->Unlock(x); } } while (0)
|
|
|
|
|
|
|
|
#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__ ); \
|
|
|
|
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)
|
2001-09-04 22:53:46 +00:00
|
|
|
|
|
|
|
/* Private display data */
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
#define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (DFB_DeviceData *) ((dev)->driverdata)
|
|
|
|
#define SDL_DFB_WINDOWDATA(win) DFB_WindowData *windata = ((win) ? (DFB_WindowData *) ((win)->driverdata) : NULL)
|
|
|
|
#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (dev)->displays[(win)->display].driverdata : NULL)
|
|
|
|
|
|
|
|
typedef struct _DFB_DisplayData DFB_DisplayData;
|
|
|
|
|
|
|
|
#define DFB_MAX_SCREENS 10
|
|
|
|
#define DFB_MAX_MODES 50
|
|
|
|
|
|
|
|
struct _DFB_DisplayData
|
|
|
|
{
|
|
|
|
IDirectFBDisplayLayer *layer;
|
|
|
|
DFBSurfacePixelFormat pixelformat;
|
2008-08-26 02:32:45 +00:00
|
|
|
//FIXME: support for multiple layer ...
|
2007-08-11 21:51:19 +00:00
|
|
|
DFBDisplayLayerID vidID;
|
|
|
|
|
2008-08-26 02:32:45 +00:00
|
|
|
int vidIDinuse;
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
int cw;
|
|
|
|
int ch;
|
|
|
|
|
|
|
|
int nummodes;
|
|
|
|
SDL_DisplayMode *modelist;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
WMcursor *last_cursor;
|
|
|
|
WMcursor *blank_cursor;
|
|
|
|
WMcursor *default_cursor;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _DFB_WindowData DFB_WindowData;
|
|
|
|
struct _DFB_WindowData
|
|
|
|
{
|
|
|
|
IDirectFBSurface *surface;
|
|
|
|
IDirectFBPalette *palette;
|
|
|
|
IDirectFBWindow *window;
|
|
|
|
IDirectFBGL *gl_context;
|
|
|
|
IDirectFBEventBuffer *eventbuffer;
|
|
|
|
DFBWindowID windowID;
|
2008-08-26 02:32:45 +00:00
|
|
|
int id; /* SDL window id */
|
2007-08-11 21:51:19 +00:00
|
|
|
DFB_WindowData *next;
|
2008-08-26 02:32:45 +00:00
|
|
|
Uint8 opacity;
|
2007-08-11 21:51:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _DFB_DeviceData DFB_DeviceData;
|
|
|
|
struct _DFB_DeviceData
|
2001-09-04 22:53:46 +00:00
|
|
|
{
|
2006-07-10 21:04:37 +00:00
|
|
|
int initialized;
|
|
|
|
|
|
|
|
IDirectFB *dfb;
|
2007-08-11 21:51:19 +00:00
|
|
|
int mouse;
|
|
|
|
int keyboard;
|
2008-08-26 02:32:45 +00:00
|
|
|
int kbdgeneric;
|
2007-08-11 21:51:19 +00:00
|
|
|
DFB_WindowData *firstwin;
|
2006-07-10 21:04:37 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
int numscreens;
|
|
|
|
DFBScreenID screenid[DFB_MAX_SCREENS];
|
|
|
|
DFBDisplayLayerID gralayer[DFB_MAX_SCREENS];
|
|
|
|
DFBDisplayLayerID vidlayer[DFB_MAX_SCREENS];
|
|
|
|
|
2008-08-26 02:32:45 +00:00
|
|
|
int aux; /* auxiliary integer for callbacks */
|
2007-08-11 21:51:19 +00:00
|
|
|
|
2008-08-26 02:32:45 +00:00
|
|
|
/* OpenGL */
|
2007-08-11 21:51:19 +00:00
|
|
|
void (*glFinish) (void);
|
|
|
|
void (*glFlush) (void);
|
2001-09-04 22:53:46 +00:00
|
|
|
};
|
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
struct SDL_GLDriverData
|
|
|
|
{
|
|
|
|
int gl_active; /* to stop switching drivers while we have a valid context */
|
2001-09-04 22:53:46 +00:00
|
|
|
|
2007-08-11 21:51:19 +00:00
|
|
|
#if SDL_DIRECTFB_OPENGL
|
|
|
|
IDirectFBGL *gl_context;
|
|
|
|
#endif /* SDL_DIRECTFB_OPENGL */
|
|
|
|
};
|
2002-08-31 04:13:28 +00:00
|
|
|
|
2001-09-04 22:53:46 +00:00
|
|
|
#endif /* _SDL_DirectFB_video_h */
|