Alien-CSFML
view release on metacpan or search on metacpan
- Fixing Windows broke *BSD and macOS in CI
v0.0.3 2022-10-21T03:43:22Z
- Aim to use prebuilt libs on Windows (MSVC and GCC)
v0.0.2 2022-10-19T18:41:44Z
- Document dependencies on FreeBSD
- Describe modules provided by ldflags()
v0.0.1 2022-10-19T02:09:45Z
- Hi, planet.
_ -.-. .... .- -. --. . ... _________________________________________
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
my $OBJ = $CC->compile( 'C++' => 1, source => $SRC, include_dirs => [ $SF->include_dirs ] );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => ' -lstdc++ ' . $SF->ldflags(qw[graphics system window])
);
print system(
(
$^O eq 'MSWin32' ? '' :
'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path(1) ) . ' '
) .
'./' . $EXE
) ? 'Aww...' : 'Yay!';
END { unlink grep defined, $SRC, $OBJ, $EXE; }
# Constructor
my $AS = Alien::CSFML->new( );
Per-object configuration options are set in the constructor and include:
- `C++`
Specifies that the source file is a C++ source file and sets appropriate
compile and linker flags.
# Methods
After creating a new [Alien::CSFML](https://metacpan.org/pod/Alien%3A%3ACSFML) object, use the following
methods to gather information:
## `include_dirs`
my @include_dirs = $AS->include_dirs( );
Returns a list of the locations of the headers installed during the build
process and those required for compilation.
## `library_path`
my $lib_path = $AS->library_path( );
Returns the location of the private libraries we made and installed during the
build process.
## `cflags`
my $cflags = $AS->cflags( );
Returns additional C compiler flags to be used.
## `cxxflags`
my $cxxflags = $AS->cxxflags( );
Returns additional flags to be used to when compiling C++.
## `ldflags`
my $ldflags = $AS->ldflags( );
Returns additional linker flags to be used.
my $ldflags = $AS->ldflags(qw[audio window system]);
By default, all modules are linked but you may request certain modules
individually with the following values:
- `audio` - hardware-accelerated spatialised audio playback and recording
- `graphics` - hardware acceleration of 2D graphics including sprites, polygons and text rendering
- `network` - TCP and UDP network sockets, data encapsulation facilities, HTTP and FTP classes
- `system` - vector and Unicode string classes, portable threading and timer facilities
- `window` - window and input device management including support for joysticks, OpenGL context management
examples/csfml.pl view on Meta::CPAN
sfSprite_destroy(sprite);
sfTexture_destroy(texture);
sfRenderWindow_destroy(window);
return 0;
}
END
my $OBJ = $CC->compile( source => $SRC, include_dirs => [ $SF->include_dirs ] );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => $SF->ldflags(qw[graphics system window audio])
);
print system(
(
$^O eq 'MSWin32' ? '' :
'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path() ) . ' '
) .
'./' . $EXE
) ? 'Aww...' : 'Yay!';
END { unlink grep defined, $SRC, $OBJ, $EXE; }
}
examples/opengl.pl view on Meta::CPAN
// release resources...
return 0;
}
END
my $OBJ = $CC->compile( 'C++' => 1, source => $SRC, include_dirs => [ $SF->include_dirs ] );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => ' -lstdc++ ' . $SF->ldflags(qw[graphics system window]) .
# Linux:
' -lX11 -lXxf86vm -lXrandr -lpthread -ldl -lXinerama -lXcursor -lGLEW -lGL -lm -lXi'
);
print system(
( $^O eq 'MSWin32' ? '' : 'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path(1) ) . ' ' ) .
'./' . $EXE ) ? 'Aww...' : 'Yay!';
print system( './' . $EXE ) ? 'Aww...' : 'Yay!';
END { unlink grep defined, $SRC, $OBJ, $EXE; }
examples/sfml.pl view on Meta::CPAN
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
END
my $OBJ = $CC->compile( 'C++' => 1, source => $SRC, include_dirs => [ $SF->include_dirs ] );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => ' -lstdc++ ' . $SF->ldflags(qw[graphics system window audio])
);
print system(
(
$^O eq 'MSWin32' ? '' :
'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path() ) . ' '
) .
'./' . $EXE
) ? 'Aww...' : 'Yay!';
END { unlink grep defined, $SRC, $OBJ, $EXE; }
}
lib/Alien/CSFML.pm view on Meta::CPAN
canonpath( catdir( dist_dir('Alien-CSFML'), 'sfml', 'include' ) ),
( $s->{'C++'} ? () : canonpath( catdir( dist_dir('Alien-CSFML'), 'csfml', 'include' ) ) )
);
}
sub library_path {
my ($s) = @_;
return ( canonpath( catdir( dist_dir('Alien-CSFML'), 'sfml', 'lib' ) ),
( $s->{'C++'} ? () : canonpath( catdir( dist_dir('Alien-CSFML'), 'csfml', 'lib' ) ) ) );
}
sub cflags {''}
sub cxxflags {''}
sub ldflags {
my ( $s, @args ) = @_;
@args = qw[graphics window audio network system] if !scalar @args;
CORE::state $pre;
$pre //= { # Windows dependencies
graphics => [
( ( $s->{'C++'} ? '' : 'c' ) . 'sfml-window' ),
( ( $s->{'C++'} ? '' : 'c' ) . 'sfml-system' ),
qw[opengl32 freetype]
],
window => [ ( ( $s->{'C++'} ? '' : 'c' ) . 'sfml-system' ), qw[opengl32 winmm gdi32] ],
lib/Alien/CSFML.pm view on Meta::CPAN
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
my $OBJ = $CC->compile( 'C++' => 1, source => $SRC, include_dirs => [ $SF->include_dirs ] );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => ' -lstdc++ ' . $SF->ldflags(qw[graphics system window])
);
print system(
(
$^O eq 'MSWin32' ? '' :
'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path(1) ) . ' '
) .
'./' . $EXE
) ? 'Aww...' : 'Yay!';
END { unlink grep defined, $SRC, $OBJ, $EXE; }
lib/Alien/CSFML.pm view on Meta::CPAN
my $AS = Alien::CSFML->new( );
Per-object configuration options are set in the constructor and include:
=over
=item C<C++>
Specifies that the source file is a C++ source file and sets appropriate
compile and linker flags.
=back
=head1 Methods
After creating a new L<Alien::CSFML|Alien::CSFML> object, use the following
methods to gather information:
=head2 C<include_dirs>
lib/Alien/CSFML.pm view on Meta::CPAN
Returns a list of the locations of the headers installed during the build
process and those required for compilation.
=head2 C<library_path>
my $lib_path = $AS->library_path( );
Returns the location of the private libraries we made and installed during the
build process.
=head2 C<cflags>
my $cflags = $AS->cflags( );
Returns additional C compiler flags to be used.
=head2 C<cxxflags>
my $cxxflags = $AS->cxxflags( );
Returns additional flags to be used to when compiling C++.
=head2 C<ldflags>
my $ldflags = $AS->ldflags( );
Returns additional linker flags to be used.
my $ldflags = $AS->ldflags(qw[audio window system]);
By default, all modules are linked but you may request certain modules
individually with the following values:
=over
=item C<audio> - hardware-accelerated spatialised audio playback and recording
=item C<graphics> - hardware acceleration of 2D graphics including sprites, polygons and text rendering
t/0002_c_exe.t view on Meta::CPAN
sfTexture_destroy(texture);
sfRenderWindow_destroy(window);
return 0;
}
END
my $OBJ = $CC->compile( source => $SRC, include_dirs => [ $SF->include_dirs ] );
ok( $OBJ, 'Compile' );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => $SF->ldflags(qw[graphics system window audio])
);
ok( $EXE, 'Link exe' );
ok(
!system(
(
$^O eq 'MSWin32' ? '' :
( 'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path(1) ) . ' ' )
) .
$EXE
),
t/0003_cxx_exe.t view on Meta::CPAN
window.display();
break;
}
return 0;
}
END
my $OBJ = $CC->compile( 'C++' => 1, source => $SRC, include_dirs => [ $SF->include_dirs() ], );
ok( $OBJ, 'Compile' );
my $EXE = $CC->link_executable(
objects => $OBJ,
extra_linker_flags => ' -lstdc++ ' . $SF->ldflags(qw[graphics system window])
#' -lsfml-audio -lsfml-network
);
ok( $EXE, 'Link exe' );
ok(
!system(
(
$^O eq 'MSWin32' ? '' :
( 'LD_LIBRARY_PATH=' . join( ':', '.', $SF->library_path(1) ) . ' ' )
) .
( run in 1.868 second using v1.01-cache-2.11-cpan-94b05bcf43c )