Been working with kthakore in the IRC channel and he asked I send this to the mailing list.
I'm working on a checkerboard program. The first version was ridiculous with memory leaks, so I scrapped it and am rewriting. I'm currently doing some testing with the way SDL(x) works to make sure I decrease the amount of memory leaks possible. What I'm trying to do is take 2 surfaces (one for each square color), do a draw_rect() on to the surface in the specific color for that square, blit these onto another surface in an alternating 8x8 pattern, then blit that surface to the display. Unfortunately, I'm just getting a black screen. I can get this to display if I do a draw_rect() instead of the first blit() commands. I highlighted the sections of code where I comment out the different lines, this is in the createBoardBackground() sub. It is seeming to be a problem with blitting a blitted surface. #!usr/bin/perl > use strict; > use warnings; > > use SDL; > use SDLx::Surface; > use SDLx::App; > use SDLx::Sprite; > > use constant SQUARE_SIZE => 40; > > my $app = SDLx::App->new( > w => (SQUARE_SIZE * 8), > h => (SQUARE_SIZE * 8), > exit_on_quit => 1, > ); > > my $yellowSquare = SDLx::Surface->new( > h => SQUARE_SIZE, > w => SQUARE_SIZE, > ); > my $orangeSquare = SDLx::Surface->new( > h => SQUARE_SIZE, > w => SQUARE_SIZE, > ); > $yellowSquare->draw_rect([0,0,SQUARE_SIZE,SQUARE_SIZE], 0xFFCC33FF); > $orangeSquare->draw_rect([0,0,SQUARE_SIZE,SQUARE_SIZE], 0xCC9900FF); > > my $newSurface = SDLx::Surface->new( > h => 320, > w => 320, > ); > > sub createBoardBackground > { > for (0..7) > { > my $h = $_; > for (0..7) > { > my $v = $_; > if (($h+$v) % 2 == 0) > { > * $newSurface->draw_rect([($h * SQUARE_SIZE), ($v * > SQUARE_SIZE), SQUARE_SIZE, SQUARE_SIZE], 0xFFCC33FF);** > #$yellowSquare->blit($newSurface, > [0,0,SQUARE_SIZE,SQUARE_SIZE], [($h * SQUARE_SIZE), ($v * SQUARE_SIZE), > SQUARE_SIZE, SQUARE_SIZE]);* > } > else > { > *$newSurface->draw_rect([($h * SQUARE_SIZE), ($v * > SQUARE_SIZE), SQUARE_SIZE, SQUARE_SIZE], 0xCC9900FF);** > #$orangeSquare->blit($newSurface, > [0,0,SQUARE_SIZE,SQUARE_SIZE], [($h * SQUARE_SIZE), ($v * SQUARE_SIZE), > SQUARE_SIZE, SQUARE_SIZE]);* > } > } > } > $newSurface->update(); > } > > sub drawBoardV2 > { > $newSurface->blit($app, [0,0,320,320], [0,0,320,320]); > $app->update(); > } > > createBoardBackground(); > > $app->add_show_handler(\&drawBoardV2); > $app->run(); >