README-directfb.txt
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 7241 28602f5ca96d
permissions -rw-r--r--
Fixed bug 1968 - SDL_RenderCopy stretch loses proportion on viewport boundaries for 3D renderers

driedfruit

SDL_RenderCopy clips dstrect against the viewport. Then it adjusts the
srcrect by "appropriate" amount of pixels. This amount is actually
wrong, quite a lot, because of the rounding errors introduced in the "*
factor / factor" scale.

real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;

For example:

I have a 32 x 32 srcrect and a 64 x 64 dstrect. So far the
stretching is done perfectly, by a factor of 2.

Now, consider dstrect being clipped against the viewport, so it becomes
56 x 64. Now, the factor becomes 1.75 ! The adjustment to "srcrect"
can't handle this, cause srcrect is in integers.

And thus we now have incorrect mapping, with dstrect not being in the
right proportion to srcrect.

The problem is most evident when upscaling stuff, like displaying a 8x8
texture with a zoom of 64 or more, and moving it beyond the corners of
the screen. It *looks* really really bad.

Note: RenderCopyEX does no such clipping, and is right to do so. The fix would be to remove any such clipping from RenderCopy too. And then fix the software renderer, because it has the same fault, independently of RenderCopy.

[attached patch]
this leaves Software Renderer buggy, as it does it's own clipping later on
     1 SDL on DirectFB
     2 
     3 Supports:
     4 
     5 - Hardware YUV overlays
     6 - OpenGL - software only
     7 - 2D/3D accelerations (depends on directfb driver)
     8 - multiple displays
     9 - windows
    10 
    11 What you need:
    12 
    13 DirectFB 1.0.1, 1.2.x, 1.3.0
    14 Kernel-Framebuffer support: required: vesafb, radeonfb .... 
    15 Mesa 7.0.x	   - optional for OpenGL
    16 
    17 /etc/directfbrc
    18 
    19 This file should contain the following lines to make
    20 your joystick work and avoid crashes:
    21 ------------------------
    22 disable-module=joystick
    23 disable-module=cle266
    24 disable-module=cyber5k
    25 no-linux-input-grab
    26 ------------------------
    27 
    28 To disable to use x11 backend when DISPLAY variable is found use
    29 
    30 export SDL_DIRECTFB_X11_CHECK=0
    31 
    32 To disable the use of linux input devices, i.e. multimice/multikeyboard support,
    33 use
    34 
    35 export SDL_DIRECTFB_LINUX_INPUT=0
    36 
    37 To use hardware accelerated YUV-overlays for YUV-textures, use:
    38 
    39 export SDL_DIRECTFB_YUV_DIRECT=1
    40 
    41 This is disabled by default. It will only support one 
    42 YUV texture, namely the first. Every other YUV texture will be
    43 rendered in software.
    44 
    45 In addition, you may use (directfb-1.2.x)
    46 
    47 export SDL_DIRECTFB_YUV_UNDERLAY=1
    48 
    49 to make the YUV texture an underlay. This will make the cursor to
    50 be shown.
    51 
    52 Simple Window Manager
    53 =====================
    54 
    55 The driver has support for a very, very basic window manager you may
    56 want to use when running with "wm=default". Use
    57 
    58 export SDL_DIRECTFB_WM=1
    59 
    60 to enable basic window borders. In order to have the window title rendered,
    61 you need to have the following font installed:
    62 
    63 /usr/share/fonts/truetype/freefont/FreeSans.ttf
    64 
    65 OpenGL Support
    66 ==============
    67 
    68 The following instructions will give you *software* OpenGL. However this
    69 works at least on all directfb supported platforms.
    70 
    71 As of this writing 20100802 you need to pull Mesa from git and do the following:
    72 
    73 ------------------------
    74 git clone git://anongit.freedesktop.org/git/mesa/mesa
    75 cd mesa 
    76 git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
    77 ------------------------
    78 
    79 Edit configs/linux-directfb so that the Directories-section looks like
    80 ------------------------
    81 # Directories
    82 SRC_DIRS     = mesa glu 
    83 GLU_DIRS     = sgi
    84 DRIVER_DIRS  = directfb
    85 PROGRAM_DIRS = 
    86 ------------------------
    87 
    88 make linux-directfb
    89 make
    90 
    91 echo Installing - please enter sudo pw.
    92 
    93 sudo make install INSTALL_DIR=/usr/local/dfb_GL
    94 cd src/mesa/drivers/directfb
    95 make
    96 sudo make install INSTALL_DIR=/usr/local/dfb_GL
    97 ------------------------
    98 
    99 To run the SDL - testprograms:
   100 
   101 export SDL_VIDEODRIVER=directfb
   102 export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
   103 export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
   104 
   105 ./testgl
   106