Building nonroot-dga sdl?

is there a document or information describing how loki has recently
built SDL to be able to run dga without needing root permissions? i
believe it involves statically linking several libraries together? i
suppose requiring SDL to be statically linked to the game?

is there a document or information describing how loki has recently
built SDL to be able to run dga without needing root permissions? i
believe it involves statically linking several libraries together? i
suppose requiring SDL to be statically linked to the game?

Heheh, it was a patch that I wrote. It’s attached.

-Sam Lantinga, Software Engineer, Blizzard Entertainment

-------------- next part --------------
diff -u -r1.14 XF86DGA2.c
— XF86DGA2.c 2000/05/23 04:47:35 1.14
+++ XF86DGA2.c 2000/08/29 15:53:10
@@ -23,6 +23,9 @@
#include “extutil.h”
#include <stdio.h>

+#if defined(linux) /* Needed for framebuffer console support */
+#include <linux/fb.h>
+#endif

/* If you change this, change the Bases[] array below as well */
#define MAX_HEADS 16
@@ -909,7 +912,31 @@
if (!name)
name = DEV_MEM;
if ((pMap->fd = open(name, O_RDWR)) < 0)
+#if defined(linux)

  • { /* /dev/fb0 fallback added by Sam Lantinga */
  •    /* Try to fall back to /dev/fb on Linux - FIXME: verify the device */
    
  •    struct fb_fix_screeninfo finfo;+
    
  •    if ((pMap->fd = open("/dev/fb0", O_RDWR)) < 0) {
    
  •        return False;
    
  •    }
    
  •    /* The useable framebuffer console memory may not be the whole
    
  •       framebuffer that X has access to. :-(
    
  •     */
    
  •    if ( ioctl(pMap->fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
    
  •        close(pMap->fd);
    
  •        return False;
    
  •    }
    
  •    /* Warning: On PPC, the size and virtual need to be offset by:
    
  •       (((long)finfo.smem_start) -
    
  •       (((long)finfo.smem_start)&~(PAGE_SIZE-1)))
    
  •     */
    
  •    base = 0;
    
  •    size = finfo.smem_len;
    
  • }
    +#else
    return False;
    +#endif
    pMap->virtual = mmap(NULL, size, PROT_READ | PROT_WRITE,
    MAP_FILE | MAP_SHARED, pMap->fd, (off_t)base);
    if (pMap->virtual == (void *)-1)

Heheh, it was a patch that I wrote. It’s attached.

I suppose some explanation is in order.
It’s a patch to the XFree86 DGA library. You need to get the source
to XFree86 to use it. Once you’ve applied the patch and built the DGA
library, you then need to remove the .so version of the library (if you
have it) and then link SDL with it. Any applications using this version
of SDL will be able to use DGA on systems that have framebuffer console,
without requiring root permissions.

The binary RPM on the website has been built this way.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Running as root won’t even necessarily enable DGA. The availability of
DGA (to the best of my semi-knowledge) is a function of your X
configuration and the permissions on your framebuffer device.

You can compile your program in any way you feel like and it won’t make
a lick of difference if the framebuffer can’t be directly accessed by
the user executing your program.

Of course, one simpler way around this would probably be to have your
install script configure your game to run as root no matter what user
executes it. Course, that’s really… really dangerous. Especially if
you’re writing an online game because you leave the client open to all
sorts of potential nastiness.

Check the XFree documentation. You might find your answer there.

Oh, and be prepared for pain. In my experience messing around with
enabling DGA can result in all sorts of control-losing crashes. :)On Wed, 2002-01-09 at 15:40, Pete Shinners wrote:

is there a document or information describing how loki has recently
built SDL to be able to run dga without needing root permissions? i
believe it involves statically linking several libraries together? i
suppose requiring SDL to be statically linked to the game?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

End of Rant.

Jimmy
JimmysWorld.org