Den Mon, 22 Jun 2009 18:41:25 +0200
skrev Sylvain Beucler :
I did try the “get your operating system to deny these video modes
for that display” but I personaly didn’t found out how
Hmm, actually there is a way to get the aspect ratio right without
modifying the code:
xrandr --output LVDS --set PANEL_FITTING full_aspect
Admittedly obscure, but there’s one. Maybe it requires a recent distro
though.
Which makes me think it may not be something to fix at the SDL level
eventually.
That’s nice, and I’m happy you solved the problem for yourself.
However, this is far from a universal solution. As I’ve explained
before (at length), there’s just so many monitors / graphics cards /
drivers with all kinds of problems that in the end you can’t be sure
that the display will be shown with the correct aspect ratio unless you
do it “manually” (ie by working with both a physical, a logical, and
optionally a scaled resolution.)
Also, fwiw, your xrandr magic doesn’t work here, and I do have a recent
Xorg server and gfx driver (nvidia). I can tell the driver to do
aspect-ratio scaling in the driver settings, but that still screws up
at some resolutions (eg 800x600 actually sets the videomode to around
700x525 and only shows the top left part of the screen for some reason,
with some flickering added at the bottom for good measure). This is
obviously not SDL’s fault, but again, the point is that there’s just so
much broken stuff out there that you can’t count on it working.
So I’d rather have SDL select a physical 800x640 resolution, center
the screen in it, and return a 640x480 logical surface - which SDL
would do if the 640x480 stretched mode weren’t available.
[…] but you’d be restricted to software rendering.
Are you sure? What prevents a hardware rendering from filling the
screen with black, and return a subsurface (same pitch, different
’->pixels’ origin) instead of the full surface?
SDL 1.3 uses textures for hardware rendering, and the screen is, well,
the screen. It’s not a texture or a surface. Textures can’t
(currently) be rendered to other textures. The surfaces that
you’re used to from 1.2 are always software surfaces.
Anyway, that reply was for the case in which SDL stays as it is, and
you implement the black bars in your own code or maybe an add-on
library. There are things you can do to keep hardware acceleration
even then – eg if SDL uses the opengl backend, you could easily use
glViewport to add black bars, but since SDL “owns” the screen it can
(at least in theory, haven’t actually checked this) set its own
viewport at any time, removing the bars again. There’s also all the
other backends to consider, if you want to support more than just
opengl – and if not, you might as well just use opengl directly for
less hassle and more features…
If SDL had render target support (another feature on my personal wish
list), you could render to a texture in stead, and then draw that to
the screen with all the borders and scaling you wanted (if any). But it
doesn’t, at least not yet.
Anyway, even if SDL does get render target support, black bars or even
screen scaling doesn’t necessarily need that. To use opengl as an
example again, rendering to a texture requires an extension, but adding
black borders can be done with a simple glViewport call, which has been
part of opengl since the beginning. Scaling of the screen can be also
be done practically for free simply by changing the values passed to
glOrtho when setting up the projection (though this only actually
scales coordinates, not pixels, but this should be good enough for
most purposes, specially since SDL manage the coordinates used … for
the cases where it’s not good enough, you’ll need render target
support anyway)
As I understand it, SDL 1.2 is complete, and no new API will be
added to it.
I don’t think a piece of software can be complete. When SDL 1.2 was
first released, there was essentially no need to deal with 16:10
screens, while they are widespread nowadays. The world evolves,
software must adapt, nothing is static, everything is falling app…
well you got me
Yes, I think complete was the wrong word there. Frozen might be a
better one. As in, all new stuff go into 1.3.