Alien-CSFML

 view release on metacpan or  search on metacpan

examples/csfml.pl  view on Meta::CPAN

    syswrite( $FH, <<'END')   || die '...'; close $FH;
#include <SFML/Audio.h>
#include <SFML/Graphics.h>

 int main()
 {
     sfVideoMode mode = {800, 600, 32};
     sfRenderWindow* window;
     sfTexture* texture;
     sfSprite* sprite;
     sfFont* font;
     sfText* text;
     sfMusic* music;
     sfEvent event;

     /* Create the main window */
     window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL);
     if (!window)
         return -1;

     /* Load a sprite to display */
     // https://en.wikipedia.org/wiki/JPEG#/media/File:JPEG_example_JPG_RIP_100.jpg
     texture = sfTexture_createFromFile("JPEG_example_JPG_RIP_100.jpg", NULL);
     if (!texture)
         return -1;
     sprite = sfSprite_create();
     sfSprite_setTexture(sprite, texture, sfTrue);

     /* Create a graphical text to display */
     // https://github.com/googlefonts/roboto/releases
     font = sfFont_createFromFile("Roboto-Regular.ttf");
     if (!font)
         return -1;
     text = sfText_create();
     sfText_setString(text, "Hello SFML");
     sfText_setFont(text, font);
     sfText_setCharacterSize(text, 50);

     /* Load a music to play */
     // https://en.wikipedia.org/wiki/File:Binbeat_sample.ogg
     music = sfMusic_createFromFile("Binbeat_sample.ogg");
     if (!music)
         return -1;

     /* Play the music */
     sfMusic_play(music);

examples/csfml.pl  view on Meta::CPAN

         /* Draw the text */
         sfRenderWindow_drawText(window, text, NULL);

         /* Update the window */
         sfRenderWindow_display(window);
     }

     /* Cleanup resources */
     sfMusic_destroy(music);
     sfText_destroy(text);
     sfFont_destroy(font);
     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,

t/0002_c_exe.t  view on Meta::CPAN

);
syswrite( $FH, <<'END') || BAIL_OUT("Failed to write to $SRC: $!"); close $FH;
#include <SFML/Audio.h>
#include <SFML/Graphics.h>

int main() {
     sfVideoMode mode = {800, 600, 32};
     sfRenderWindow* window;
     sfTexture* texture;
     sfSprite* sprite;
     sfFont* font;
     sfText* text;
     sfMusic* music;
     sfEvent event;

     /* Create the main window */
     window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL);
     if (!window)
         return -1;

     /* Load a sprite to display */
     // https://en.wikipedia.org/wiki/JPEG#/media/File:JPEG_example_JPG_RIP_100.jpg
     texture = sfTexture_createFromFile("JPEG_example_JPG_RIP_100.jpg", NULL);
     if (!texture)
         return -1;
     sprite = sfSprite_create();
     sfSprite_setTexture(sprite, texture, sfTrue);

     /* Create a graphical text to display */
     // https://github.com/googlefonts/roboto/releases
     font = sfFont_createFromFile("Roboto-Regular.ttf");
     if (!font)
         return -1;
     text = sfText_create();
     sfText_setString(text, "Hello SFML");
     sfText_setFont(text, font);
     sfText_setCharacterSize(text, 50);

     /* Load a music to play */
     // https://en.wikipedia.org/wiki/File:Binbeat_sample.ogg
     music = sfMusic_createFromFile("Binbeat_sample.ogg");
     if (!music)
         return -1;

     /* Play the music */
     sfMusic_play(music);

t/0002_c_exe.t  view on Meta::CPAN

         /* Draw the text */
         sfRenderWindow_drawText(window, text, NULL);

         /* Update the window */
         sfRenderWindow_display(window);
     }

     /* Cleanup resources */
     sfMusic_destroy(music);
     sfText_destroy(text);
     sfFont_destroy(font);
     sfSprite_destroy(sprite);
     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(



( run in 0.587 second using v1.01-cache-2.11-cpan-5735350b133 )