README-porting.txt
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Aug 2013 09:15:36 -0700
changeset 7563 c128ed448c30
parent 7222 2435b221d77d
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
slouken@7222
     1
slouken@7222
     2
* Porting To A New Platform
slouken@7222
     3
slouken@7222
     4
  The first thing you have to do when porting to a new platform, is look at
slouken@7222
     5
include/SDL_platform.h and create an entry there for your operating system.
slouken@7222
     6
The standard format is __PLATFORM__, where PLATFORM is the name of the OS.
slouken@7222
     7
Ideally SDL_platform.h will be able to auto-detect the system it's building
slouken@7222
     8
on based on C preprocessor symbols.
slouken@7222
     9
slouken@7222
    10
There are two basic ways of building SDL at the moment:
slouken@7222
    11
slouken@7222
    12
1. The "UNIX" way:  ./configure; make; make install
slouken@7222
    13
slouken@7222
    14
   If you have a GNUish system, then you might try this.  Edit configure.in,
slouken@7222
    15
   take a look at the large section labelled:
slouken@7222
    16
	"Set up the configuration based on the target platform!"
slouken@7222
    17
   Add a section for your platform, and then re-run autogen.sh and build!
slouken@7222
    18
slouken@7222
    19
2. Using an IDE:
slouken@7222
    20
slouken@7222
    21
   If you're using an IDE or other non-configure build system, you'll probably
slouken@7222
    22
   want to create a custom SDL_config.h for your platform.  Edit SDL_config.h,
slouken@7222
    23
   add a section for your platform, and create a custom SDL_config_{platform}.h,
slouken@7222
    24
   based on SDL_config.h.minimal and SDL_config.h.in
slouken@7222
    25
slouken@7222
    26
   Add the top level include directory to the header search path, and then add
slouken@7222
    27
   the following sources to the project:
slouken@7222
    28
	src/*.c
slouken@7222
    29
	src/atomic/*.c
slouken@7222
    30
	src/audio/*.c
slouken@7222
    31
	src/cpuinfo/*.c
slouken@7222
    32
	src/events/*.c
slouken@7222
    33
	src/file/*.c
slouken@7222
    34
	src/haptic/*.c
slouken@7222
    35
	src/joystick/*.c
slouken@7222
    36
	src/power/*.c
slouken@7222
    37
	src/render/*.c
slouken@7222
    38
	src/stdlib/*.c
slouken@7222
    39
	src/thread/*.c
slouken@7222
    40
	src/timer/*.c
slouken@7222
    41
	src/video/*.c
slouken@7222
    42
	src/audio/disk/*.c
slouken@7222
    43
	src/audio/dummy/*.c
slouken@7222
    44
	src/video/dummy/*.c
slouken@7222
    45
	src/haptic/dummy/*.c
slouken@7222
    46
	src/joystick/dummy/*.c
slouken@7222
    47
	src/main/dummy/*.c
slouken@7222
    48
	src/thread/generic/*.c
slouken@7222
    49
	src/timer/dummy/*.c
slouken@7222
    50
	src/loadso/dummy/*.c
slouken@7222
    51
slouken@7222
    52
slouken@7222
    53
Once you have a working library without any drivers, you can go back to each
slouken@7222
    54
of the major subsystems and start implementing drivers for your platform.
slouken@7222
    55
slouken@7222
    56
If you have any questions, don't hesitate to ask on the SDL mailing list:
slouken@7222
    57
	http://www.libsdl.org/mailing-list.php
slouken@7222
    58
slouken@7222
    59
Enjoy!
slouken@7222
    60
	Sam Lantinga				(slouken@libsdl.org)
slouken@7222
    61