I have attached two patches that should allow resizing of GL windows. One
patch is for DirectFBGL and the other is for Mesa.
I reset the drawable size and cliprect coordinates in set_drawable_flag().
The Mesa patch will make sure that Mesa resets the viewport according to
the new drawable size.
I also added a listener to resize the depth buffer surface. There's no way
to know if the dfb_surface_reformat() succeeded in the listener but the
next dfb_surface_hardware_lock() should fail if the reallocation failed...
I think :)
Apart from considerable flashing during resizing seems to work fine. I'm
not sure what to do about the flashing...
I've also ported freeglut to DirectFBGL. freeglut is a full featured GLUT
implementation and it draws menus and text using OpenGL so it's mostly
windowing system independent. The window resize stuff is required to make
freeglut menus behave correctly.
I was too lazy to generate a patch right now so I dumped the tarball to
http://www.sci.fi/~syrjala/gl/. Use "./configure --enable-directfb" to
enable DirectFBGL support.
--
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
Index: src/dfbdri.c
===================================================================
RCS file: /cvs/directfb/DirectFBGL/src/dfbdri.c,v
retrieving revision 1.19
diff -u -r1.19 dfbdri.c
--- src/dfbdri.c 16 Jul 2003 03:11:44 -0000 1.19
+++ src/dfbdri.c 28 Aug 2003 19:03:48 -0000
@@ -90,6 +90,8 @@
__DRIcontext context;
__GLXvisualConfig *config;
+
+ Reaction depth_reaction;
};
/******************************************************************************/
@@ -107,6 +109,8 @@
/******************************************************************************/
+static ReactionResult depth_listener( const void *msg_data, void *ctx );
+
static void set_drawable_flag ( CoreDRI *core,
__DRIdrawable *drawable,
CoreSurface *surface,
@@ -254,6 +258,9 @@
DFBFREE( context );
return ret;
}
+
+ dfb_surface_attach( surface, depth_listener,
+ context->depth_buffer, &context->depth_reaction );
/* Initialize context. */
context->core = core;
@@ -463,6 +470,8 @@
context->drawable.destroyDrawable( &core->driScreen,
context->drawable.private );
+ dfb_surface_detach( context->surface, &context->depth_reaction );
+
dfb_surface_unref( context->depth_buffer );
dfb_surface_unref( context->surface );
@@ -474,6 +483,26 @@
/******************************************************************************/
+static ReactionResult
+depth_listener( const void *msg_data, void *ctx )
+{
+ const CoreSurfaceNotification *notification = msg_data;
+ CoreSurface *surface = notification->surface;
+ CoreSurface *depth = ctx;
+
+ if (notification->flags & CSNF_DESTROY)
+ return RS_REMOVE;
+
+ if (notification->flags & CSNF_SIZEFORMAT) {
+ dfb_surface_reformat( depth,
+ surface->width,
+ surface->height,
+ depth->format );
+ }
+
+ return RS_OK;
+}
+
static void
set_drawable_flag( CoreDRI *core,
__DRIdrawable *drawable,
@@ -500,6 +529,13 @@
fullscreen, where matroxfb uses less pitch than DirectFB. */
pdp->depthPitch = MIN( depth->back_buffer->video.pitch,
surface->back_buffer->video.pitch );
+
+ pdp->w = surface->width;
+ pdp->h = surface->height;
+ pdp->pClipRects[0].x1 = 0;
+ pdp->pClipRects[0].y1 = 0;
+ pdp->pClipRects[0].x2 = surface->width;
+ pdp->pClipRects[0].y2 = surface->height;
core->driverContext.pSAREA->drawableTable[pdp->index].stamp++;
core->driverContext.pSAREA->drawableTable[pdp->index].flags = 1;
--- Mesa/src/drv/mga/mga_xmesa.c 2003-05-22 05:11:56.000000000 +0300
+++ Mesa/src/drv/mga/mga_xmesa.c 2003-08-28 21:45:04.000000000 +0300
@@ -617,7 +617,8 @@
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
- if (!mmesa->glCtx->Viewport.Width)
+ if (mmesa->glCtx->Viewport.Width != driDrawPriv->w ||
+ mmesa->glCtx->Viewport.Height != driDrawPriv->h)
_mesa_set_viewport(mmesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);