PerlGameDev / SDL

Rehashing the old perl SDL binding on cpan.org
http://search.cpan.org/dist/SDL
GNU General Public License v2.0
81 stars 29 forks source link

SDLx::App->new() does not work on frame buffer console #266

Open ppisar opened 10 years ago

ppisar commented 10 years ago

SDLx::App::new() defaults depth to 16 bpp. I propose 0. The 0 value, I think, means best available depth for the SDL.

The reason is that on Linux frame buffer, it's not possible to reconfigure the console depth by SDL and the depth is usually 32, so 16 will fail.

The same applies to width and height.

A test can be found on [https://bugzilla.redhat.com/attachment.cgi?id=909484]. Patch follows:

From 29b2cb2365c93b66db4d8444b6d651f58d025aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 17 Jun 2014 10:20:21 +0200
Subject: [PATCH] Defaults SDLx::App video to 0x0 at 0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This allows SDL to use the best available graphics mode. And to use the only available mode on Linux frame buffer console.

Signed-off-by: Petr Písař <ppisar@redhat.com>

---
 lib/SDLx/App.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/SDLx/App.pm b/lib/SDLx/App.pm
index b5dc05c..67c556e 100644
--- a/lib/SDLx/App.pm
+++ b/lib/SDLx/App.pm
@@ -54,9 +54,9 @@ sub new {
    my $t   = $options{title}            || $options{t}   || $0;
    my $it  = $options{icon_title}       || $options{it}  || $t;
    my $ic  = $options{icon}             || $options{i}   || "";
-   my $w   = $options{width}            || $options{w}   || 800;
-   my $h   = $options{height}           || $options{h}   || 600;
-   my $d   = $options{depth}            || $options{d}   || 16;
+   my $w   = $options{width}            // $options{w}   // 0;
+   my $h   = $options{height}           // $options{h}   // 0;
+   my $d   = $options{depth}            // $options{d}   // 0;
    my $f   = $options{flags}            || $options{f}   || SDL::Video::SDL_ANYFORMAT;
    my $r   = $options{red_size}         || $options{r}   || 5;
    my $g   = $options{green_size}       || $options{g}   || 5;
-- 
1.9.3