Commit 819cc951 authored by Sam Lantinga's avatar Sam Lantinga

Couriersud to Sam

Hi Sam,

20100815_1.diff contains updates for the directfb driver:

- more documentation, mainly on software OpenGL in README.directfb
- Revised error handling leading to leaner code
- Improved/fixed OpenGL handling of multiple contexts.
- Made the built-in simple window manager handle OpenGL windows.
- Rewrote pixelformat mapping - this was quite ugly before.

Well, all software GL, but working :-)
parent f0de16c6
......@@ -65,10 +65,26 @@ you need to have the following font installed:
OPENGL Support
==============
As of this writing 20070810 you need to pull Mesa from git and do the following:
The following instructions will give you *software* opengl. However this
works at least on all directfb supported platforms.
As of this writing 20100802 you need to pull Mesa from git and do the following:
------------------------
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
cd mesa
git clone git://anongit.freedesktop.org/git/mesa/mesa
------------------------
Edit configs/linux-directfb so that the Directories-section looks like
------------------------
# Directories
SRC_DIRS = mesa glu
GLU_DIRS = sgi
DRIVER_DIRS = directfb
PROGRAM_DIRS =
------------------------
make linux-directfb
make
......@@ -87,3 +103,4 @@ export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
./testgl
This diff is collapsed.
......@@ -41,10 +41,10 @@ struct _DFB_Theme
DFBColor max_color;
};
extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window);
extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h);
extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
extern void DirectFB_WM_RedrawLayout(SDL_Window * window);
extern void DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window);
extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window,
DFBWindowEvent * evt);
......
......@@ -31,7 +31,8 @@
#define DFB_SYM(ret, name, args, al, func) ret (*name) args;
static struct _SDL_DirectFB_Symbols
{
DFB_SYMS const unsigned int *directfb_major_version;
DFB_SYMS
const unsigned int *directfb_major_version;
const unsigned int *directfb_minor_version;
const unsigned int *directfb_micro_version;
} SDL_DirectFB_Symbols;
......
This diff is collapsed.
This diff is collapsed.
......@@ -253,7 +253,7 @@ DirectFB_InitMouse(_THIS)
void
DirectFB_QuitMouse(_THIS)
{
SDL_DFB_DEVICEDATA(_this);
//SDL_DFB_DEVICEDATA(_this);
}
......
......@@ -30,6 +30,10 @@ struct SDL_GLDriverData
int gl_active; /* to stop switching drivers while we have a valid context */
int initialized;
DirectFB_GLContext *firstgl; /* linked list */
/* OpenGL */
void (*glFinish) (void);
void (*glFlush) (void);
};
#define OPENGL_REQUIRS_DLOPEN
......@@ -94,7 +98,7 @@ DirectFB_GL_Shutdown(_THIS)
int
DirectFB_GL_LoadLibrary(_THIS, const char *path)
{
SDL_DFB_DEVICEDATA(_this);
//SDL_DFB_DEVICEDATA(_this);
void *handle = NULL;
......@@ -122,9 +126,6 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
SDL_DFB_DEBUG("Loaded library: %s\n", path);
/* Unload the old driver and reset the pointers */
DirectFB_GL_UnloadLibrary(_this);
_this->gl_config.dll_handle = handle;
_this->gl_config.driver_loaded = 1;
if (path) {
......@@ -134,8 +135,8 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
*_this->gl_config.driver_path = '\0';
}
devdata->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish");
devdata->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush");
_this->gl_data->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish");
_this->gl_data->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush");
return 0;
}
......@@ -143,6 +144,7 @@ DirectFB_GL_LoadLibrary(_THIS, const char *path)
static void
DirectFB_GL_UnloadLibrary(_THIS)
{
#if 0
int ret;
if (_this->gl_config.driver_loaded) {
......@@ -153,6 +155,10 @@ DirectFB_GL_UnloadLibrary(_THIS)
_this->gl_config.dll_handle = NULL;
_this->gl_config.driver_loaded = 0;
}
#endif
/* Free OpenGL memory */
SDL_free(_this->gl_data);
_this->gl_data = NULL;
}
void *
......@@ -167,11 +173,11 @@ DirectFB_GL_GetProcAddress(_THIS, const char *proc)
SDL_GLContext
DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
{
//SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window);
DirectFB_GLContext *context;
int ret;
SDL_DFB_CALLOC(context, 1, sizeof(*context));
SDL_DFB_CALLOC(context, 1, sizeof(DirectFB_GLContext));
SDL_DFB_CHECKERR(windata->surface->GetGL(windata->surface,
&context->context));
......@@ -179,11 +185,14 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
if (!context->context)
return NULL;
SDL_DFB_CHECKERR(context->context->Unlock(context->context));
context->is_locked = 0;
context->sdl_window = window;
context->next = _this->gl_data->firstgl;
_this->gl_data->firstgl = context;
SDL_DFB_CHECK(context->context->Unlock(context->context));
if (DirectFB_GL_MakeCurrent(_this, window, context) < 0) {
DirectFB_GL_DeleteContext(_this, context);
return NULL;
......@@ -198,28 +207,24 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window)
int
DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{
SDL_DFB_WINDOWDATA(window);
//SDL_DFB_WINDOWDATA(window);
DirectFB_GLContext *ctx = (DirectFB_GLContext *) context;
DirectFB_GLContext *p;
int ret;
for (p = _this->gl_data->firstgl; p; p = p->next)
p->context->Unlock(p->context);
if (windata) {
windata->gl_context = NULL;
/* Everything is unlocked, check for a resize */
DirectFB_AdjustWindowSurface(window);
{
if (p->is_locked) {
SDL_DFB_CHECKERR(p->context->Unlock(p->context));
p->is_locked = 0;
}
}
if (ctx != NULL) {
SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context));
ctx->is_locked = 1;
}
if (windata)
windata->gl_context = ctx;
return 0;
error:
return -1;
......@@ -242,28 +247,36 @@ DirectFB_GL_GetSwapInterval(_THIS)
void
DirectFB_GL_SwapWindow(_THIS, SDL_Window * window)
{
SDL_DFB_DEVICEDATA(_this);
//SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window);
int ret;
DFBRegion region;
DirectFB_GLContext *p;
region.x1 = 0;
region.y1 = 0;
region.x2 = window->w;
region.y2 = window->h;
#if 0
if (devdata->glFinish)
devdata->glFinish();
else if (devdata->glFlush)
devdata->glFlush();
#endif
if (1 || windata->gl_context) {
/* SDL_DFB_CHECKERR(windata->gl_context->context->Unlock(windata->gl_context->context)); */
SDL_DFB_CHECKERR(windata->surface->Flip(windata->surface, &region,
DSFLIP_ONSYNC));
/* SDL_DFB_CHECKERR(windata->gl_context->context->Lock(windata->gl_context->context)); */
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
if (p->sdl_window == window && p->is_locked)
{
SDL_DFB_CHECKERR(p->context->Unlock(p->context));
p->is_locked = 0;
}
}
SDL_DFB_CHECKERR(windata->window_surface->Flip(windata->window_surface,NULL, DSFLIP_PIPELINE |DSFLIP_BLIT | DSFLIP_ONSYNC ));
//if (windata->gl_context) {
//SDL_DFB_CHECKERR(windata->surface->Flip(windata->surface,NULL, DSFLIP_ONSYNC));
//SDL_DFB_CHECKERR(windata->gl_context->context->Lock(windata->gl_context->context));
//}
return;
error:
......@@ -276,19 +289,58 @@ DirectFB_GL_DeleteContext(_THIS, SDL_GLContext context)
DirectFB_GLContext *ctx = (DirectFB_GLContext *) context;
DirectFB_GLContext *p;
ctx->context->Unlock(ctx->context);
ctx->context->Release(ctx->context);
if (ctx->is_locked)
SDL_DFB_CHECK(ctx->context->Unlock(ctx->context));
SDL_DFB_RELEASE(ctx->context);
p = _this->gl_data->firstgl;
while (p && p->next != ctx)
p = p->next;
for (p = _this->gl_data->firstgl; p && p->next != ctx; p = p->next)
;
if (p)
p->next = ctx->next;
else
_this->gl_data->firstgl = ctx->next;
SDL_DFB_FREE(ctx);
}
void
DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window)
{
DirectFB_GLContext *p;
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
if (p->sdl_window == window)
{
if (p->is_locked)
SDL_DFB_CHECK(p->context->Unlock(p->context));
SDL_DFB_RELEASE(p->context);
}
}
void
DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window)
{
DirectFB_GLContext *p;
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
if (p->sdl_window == window)
{
SDL_DFB_WINDOWDATA(window);
SDL_DFB_CHECK(windata->surface->GetGL(windata->surface,
&p->context));
if (p->is_locked)
SDL_DFB_CHECK(p->context->Lock(p->context));
}
}
void
DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window)
{
DirectFB_GLContext *p;
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
if (p->sdl_window == window)
DirectFB_GL_DeleteContext(_this, p);
}
#endif
......
......@@ -32,6 +32,9 @@ struct _DirectFB_GLContext
{
IDirectFBGL *context;
DirectFB_GLContext *next;
SDL_Window *sdl_window;
int is_locked;
};
/* OpenGL functions */
......@@ -48,6 +51,10 @@ extern int DirectFB_GL_GetSwapInterval(_THIS);
extern void DirectFB_GL_SwapWindow(_THIS, SDL_Window * window);
extern void DirectFB_GL_DeleteContext(_THIS, SDL_GLContext context);
extern void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window);
extern void DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window);
extern void DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window);
#endif /* SDL_DIRECTFB_OPENGL */
#endif /* _SDL_directfb_opengl_h */
......
This diff is collapsed.
......@@ -209,14 +209,11 @@ DirectFB_VideoInit(_THIS)
DirectFBSetOption("disable-module", "x11input");
}
#if USE_MULTI_API
devdata->use_linux_input = 1; /* default: on */
/* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */
devdata->use_linux_input = 0; /* default: on */
stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT);
if (stemp)
devdata->use_linux_input = atoi(stemp);
#else
devdata->use_linux_input = 0; /* no way to support this ... */
#endif
if (!devdata->use_linux_input)
DirectFBSetOption("disable-module", "linux_input");
......@@ -253,6 +250,7 @@ DirectFB_VideoInit(_THIS)
devdata->dfb = dfb;
devdata->firstwin = NULL;
devdata->grabbed_window = NULL;
_this->driverdata = devdata;
......
......@@ -78,49 +78,38 @@
#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */
#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */
#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { x->Release(x); x = NULL; } } while (0)
#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(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)
#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)
/* FIXME: do something with DEBUG */
#endif
#define SDL_DFB_CONTEXT "SDL_DirectFB"
#define SDL_DFB_ERR(x...) \
static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line, const char *src_code) {
if (ret != DFB_OK) {
fprintf(LOG_CHANNEL, "%s <%d>:\n\t", src_file, src_line );
fprintf(LOG_CHANNEL, "\t%s\n", src_code );
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) );
SDL_SetError( src_code, DirectFBErrorString (ret) );
}
return ret;
}
#define SDL_DFB_CHECK(x...) sdl_dfb_check( x, __FILE__, __LINE__, #x )
#define SDL_DFB_CHECKERR(x...) if ( sdl_dfb_check( x, __FILE__, __LINE__, #x ) != DFB_OK ) goto error
#define SDL_DFB_DEBUG(x...) \
do { \
fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \
SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \
fprintf(LOG_CHANNEL, x ); \
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__ ); \
fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
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_ERR(x...) SDL_DFB_DEBUG( x )
#define SDL_DFB_CALLOC(r, n, s) \
do { \
......@@ -158,9 +147,8 @@ struct _DFB_DeviceData
int use_linux_input;
int has_own_wm;
/* OpenGL */
void (*glFinish) (void);
void (*glFlush) (void);
/* window grab */
SDL_Window *grabbed_window;
/* global events */
IDirectFBEventBuffer *events;
......
This diff is collapsed.
......@@ -34,7 +34,6 @@ struct _DFB_WindowData
IDirectFBSurface *surface;
IDirectFBSurface *window_surface; /* only used with has_own_wm */
IDirectFBWindow *window;
DirectFB_GLContext *gl_context;
IDirectFBEventBuffer *eventbuffer;
SDL_Window *sdl_window;
DFB_WindowData *next;
......@@ -46,6 +45,7 @@ struct _DFB_WindowData
int is_managed;
int wm_needs_redraw;
IDirectFBSurface *icon;
IDirectFBFont *font;
DFB_Theme theme;
};
......@@ -69,7 +69,7 @@ extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
extern void DirectFB_AdjustWindowSurface(SDL_Window * window);
//extern void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window);
#endif /* _SDL_directfb_window_h */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment