Beispiel #1
0
function courses_render($course)
{
    $id = $course['Course_id'];
    //h3("<a href='index.php?option=store&view=delete&v1=$id'>Remove Course</a>");
    h2("Course number:" . $course['Course_number'] . " Name:" . $course['Name']);
    p("<h3>Description: " . $course['Description'] . "</h3>");
    //if (users_loggedIn()) {
    //p("<a href='index.php?option=courses&view=delete&v1=$id'>Remove Course</a>");
    //Course number:".$course['Course_number']." Name:".$course['Name'].";
    //}
}
Beispiel #2
0
function users_render($user)
{
    $role = $user['role'];
    if ($role == "Professor") {
        h2("<hr><b>Professors</b>");
        p("User name:" . $user['username']);
        p("User role:" . $role);
        p("User email:" . $user['email']);
    } else {
        h2("<b>Students</b>");
        p("User name:" . $user['username']);
        p("User role:" . $role);
        p("User email:" . $user['email']);
    }
    //h3("<a href='index.php?option=store&view=details&v1=$id'>Course number:".$course['Course_number']." Name:".$course['Name']."</a>");
    //p("Description: ".$course['Description']);
    //if (users_loggedIn()) {
    //books_renderEnrollForm($course);
    //}
}
Beispiel #3
0
function view($data)
{
    startOfPage("students list vieww");
    startContent();
    siteTitle("Blackboard");
    p("Welcome to Blackboard - Please Log in !");
    $students = $data["users"];
    if (!empty($students)) {
        h2("List of students:");
        foreach ($students as $student) {
            students_render($student);
        }
        h2("List of professors:");
        foreach ($students as $student) {
            professors_render($student);
        }
    }
    endContent();
    endOfPage();
}
Beispiel #4
0
/**
*######################################################################
*#  takeaway heading
*######################################################################
*/
function takeaway_heading($atts)
{
    if (isset($atts['type'])) {
        switch ($atts['type']) {
            case 'h1':
                return h1($atts);
                break;
            case 'h2':
                return h2($atts);
                break;
            case 'h3':
                return h3($atts);
                break;
            case 'h4':
                return h4($atts);
                break;
            case 'h5':
                return h5($atts);
                break;
        }
    }
    return '';
}
    The current texture is not automatic, you need to treat it like you do the other input variables, and explicitly set it from your C++ program. Since each entity can have a different
    texture, and worse, there might be no way for you to get it and pass it to the shader, SFML provides a special overload of the <code>setParameter</code> function that
    does this job for you.
</p>
<pre><code class="cpp">shader.setParameter("texture", sf::Shader::CurrentTexture);
</code></pre>
<p>
    This special parameter automatically sets the texture of the entity being drawn to the shader variable with the given name. Every time you draw a new entity, SFML will update the shader
    texture variable accordingly.
</p>
<p>
    If you want to see nice examples of shaders in action, you can have a look at the Shader example in the SFML SDK.
</p>

<?php 
h2('Using a sf::Shader with OpenGL code');
?>
<p>
    If you're using OpenGL rather than the graphics entities of SFML, you can still use <?php 
class_link("Shader");
?>
 as a wrapper around an OpenGL program object and use it
    within your OpenGL code.
</p>
<p>
    To activate a <?php 
class_link("Shader");
?>
 for drawing (the equivalent of <code>glUseProgram</code>), you have to call the <code>bind</code> static function:
</p>
<pre><code class="cpp">sf::Shader shader;
Beispiel #6
0
</p>
<pre><code class="cpp">sound.setVolume(50);
</code></pre>
</p>
    The <em>loop</em> attribute controls whether the sound/music automatically loops or not. If it loops, it will restart playing from the beginning when it's finished,
    again and again until you explicitly call <code>stop</code>. If not set to loop, it will stop automatically when it's finished.
</p>
<pre><code class="cpp">sound.setLoop(true);
</code></pre>
<p>
    More attributes are available, but they are related to spatialization and are explained in the
    <a class="internal" href="./audio-spatialization.php" title="Spatialization tutorial">corresponding tutorial</a>.
</p>

<?php 
h2('Common mistakes');
?>

<h3>Destroyed sound buffer</h3>
<p>
    The most common mistake is to let a sound buffer go out of scope (and therefore be destroyed) while a sound still uses it.
</p>
<pre><code class="cpp">sf::Sound loadSound(std::string filename)
{
    sf::SoundBuffer buffer; // this buffer is local to the function, it will be destroyed...
    buffer.loadFromFile(filename);
    return sf::Sound(buffer);
} // ... here

sf::Sound sound = loadSound("s.wav");
sound.play(); // ERROR: the sound's buffer no longer exists, the behavior is undefined
h2("LatLngBounds class: maximum bounds in GMaps");
$bounds3 = new LatLngBounds(new LatLng(-85.051128779807, -180), new LatLng(85.051128779807, 180));
h3("Constructor (new LatLng(-85.051128779807, -180), new LatLng(85.051128779807, 180))");
p($bounds3->toString());
h3("getCenter()");
p($bounds3->getCenter()->toString());
h3("getSouthWest()");
p($bounds3->getSouthWest()->toString());
h3("getNorthEast()");
p($bounds3->getNorthEast()->toString());
h3('contains(moscow)');
p($bounds3->contains($moscow));
h3('contains(sydney)');
p($bounds3->contains($sydney));
h3('contains(buenosaires)');
p($bounds3->contains($buenosaires));
h2('Spherical geometry static class');
h3('computeArea(london, donostia, newyork)');
p(float_to_string(SphericalGeometry::computeArea(array($london, $donostia, $newyork))));
h3('computeSignedArea(london, donostia, newyork)');
p(float_to_string(SphericalGeometry::computeSignedArea(array($london, $donostia, $newyork))));
h3('computeDistanceBetween(london, newyork)');
p(float_to_string(SphericalGeometry::computeDistanceBetween($london, $newyork)));
h3('computeHeading(london, newyork)');
p(float_to_string(SphericalGeometry::computeHeading($london, $newyork)));
h3('computeLength(london, newyork, moscow, sydney)');
p(float_to_string(SphericalGeometry::computeLength(array($london, $newyork, $moscow, $sydney))));
h3('computeOffset(london, 5576353.232683, -71.669371)');
p(SphericalGeometry::computeOffset($london, 5576353.232683, -71.669371)->toString());
h3('interpolate(newyork, sydney, 0.7)');
p(SphericalGeometry::interpolate($newyork, $sydney, 0.7)->toString());
Beispiel #8
0
var_dump($out_f5);
// int(10)
$out_f5 = f5();
var_dump($out_f5);
// int(11) [**]
/*
 * actual_paramter ::= '&' VARIABLE
 *
 * Note the discrepency between this and the previous test. 
 * - If a function _returns_ a symbol table entry, the associated assignment
 *   must also be =& (and not just =; cf. test above)
 * - For a function to _accept_ a symbol table entry, there is a choice:
 *   either you add the & to the formal parameter, or you add the & to the
 *   actual parameter (both is allowed too). 
 */
function h1($in_h1)
{
    $in_h1++;
}
$out_h1 = 5;
h1(&$out_h1);
var_dump($out_h1);
// Outputs 6
function h2(&$in_h2)
{
    $in_h2++;
}
$out_h2 = 5;
h2(&$out_h2);
var_dump($out_h2);
// Outputs 6
{
    // collision!
}
</code></pre>
<p>
    La fonction est nommée <code>getGlobalBounds</code> car elle renvoie la boîte englobante de l'entité dans le système de coordonnées global, c'est-à-dire avec toutes
    ses transformations (position, rotation, échelle) appliquées.
</p>
<p>
    Il existe une autre fonction, qui renvoie la boîte englobante de l'entité dans son système de coordonnées <em>local</em> (sans les transformations) :
    <code>getLocalBounds</code>. Cette fonction peut être utilisée pour récupérer la taille initiale de l'entité, par exemple, ou bien pour effectuer des calculs
    plus spécifiques.
</p>

<?php 
h2('Les hiérarchies d\'objets (scenegraph)');
?>
<p>
    Avec les transformations persos vues précédemment, il est maintenant facile d'implémenter une hiérarchie d'objets, où les enfants sont transformés relativement à leur
    parent. Tout ce que vous avez à faire est de passer la transformation combinée du parent aux enfants lorsque vous les dessinez, jusqu'à ce que vous atteignez les
    entités dessinables finales (sprites, textes, formes, vertex arrays ou bien vos propres 'drawables').
</p>
<pre><code class="cpp">// la classe de base abstraite
class Node
{
public:

    // ... fonctions pour transformer le noeud

    // ... fonction pour gérer les enfants du noeud
Beispiel #10
0
</p>
<p>
    It's up to you to decide which solution is the best for you.
</p>
<p>
    Note : none of the SFML modules requires a library which is not already installed by default on Mac OS X,
    except the Audio module which requires the OpenAL and libsndfile libraries. So you'll have to provide them
    together with your applications (see the extlibs/bin directory of the downloaded disk image). If you use the 64-bit version
    of SFML, you don't have to provide the OpenAL framework. Note that you can find the
    OpenAL framework in the system's folders, however the version delivered with Mac OS X 10.4 is not working well,
    that's why we provide a recompiled version with SFML.
</p>

<?php 
h2('Compiling SFML (for advanced users)');
?>
<p>
    To compile the SFML frameworks and samples, you first have to download the full SDK
    (see the <a class="internal" href="../../download.php" title="Go to the download page">download page</a>).
</p>
<p>
    Go to the SFML-x.y/build/xcode directory and open the SFML.xcodeproj project (compatible with Xcode 2.4 and +).
    According to what you need, choose the target (Debug or Release), and launch the compile process. It can last
    a few minutes, depending on the power of your PC. You will then find the built frameworks in the
    SFML-x.y/lib directory (or SFML-x.y/lib64 if you chose to compile SFML for 64-bit processors with the
    "SFML with Intel 64-bit.xcodeproj" project).
</p>
<p>
    Similarly, if you want to create the raw dynamic libraries, you can use the SFML-bare.xcodeproj project.
    The compile process produces dynamic libraries (files with the "dylib" extension) in the same
Beispiel #11
0
    <li><a href="graphics-sprite.php" title="Sprites and textures">Sprites and textures</a></li>
    <li><a href="graphics-text.php" title="Text and fonts">Text and fonts</a></li>
    <li><a href="graphics-shape.php" title="Shapes">Shapes</a></li>
    <li><a href="graphics-vertex-array.php" title="Designing your own entities with vertex arrays">Designing your own entities with vertex arrays</a></li>
    <li><a href="graphics-transform.php" title="Position, rotation, scale: transforming entities">Position, rotation, scale: transforming entities</a></li>
    <li><a href="graphics-shader.php" title="Adding special effects with shaders">Adding special effects with shaders</a></li>
    <li><a href="graphics-view.php" title="Controlling the 2D camera with views">Controlling the 2D camera with views</a></li>
</ul>

<?php 
h2('Audio module');
?>
<ul>
    <li><a href="audio-sounds.php" title="Playing sounds and music">Playing sounds and music</a></li>
    <li><a href="audio-recording.php" title="Recording audio">Recording audio</a></li>
    <li><a href="audio-streams.php" title="Custom audio streams">Custom audio streams</a></li>
    <li><a href="audio-spatialization.php" title="Spatialization">Spatialization: Sounds in 3D</a></li>
</ul>

<?php 
h2('Network module');
?>
<ul>
    <li><a href="network-socket.php" title="Communication using sockets">Communication using sockets</a></li>
    <li><a href="network-packet.php" title="Using and extending packets">Using and extending packets</a></li>
    <li><a href="network-http.php" title="Web requests with HTTP">Web requests with HTTP</a></li>
    <li><a href="network-ftp.php" title="File transfers with FTP">File transfers with FTP</a></li>
</ul>

<?php 
require "footer.php";
Beispiel #12
0
$export_print = HtmlInput::print_window();
$export_csv = '<FORM METHOD="get" ACTION="export.php" style="display:inline">';
$export_csv .= HtmlInput::hidden('cat', $_GET['cat']);
$export_csv .= HtmlInput::hidden('act', 'CSV:fiche_balance');
$export_csv .= HtmlInput::hidden('start', $_GET['start']);
$export_csv .= HtmlInput::hidden('end', $_GET['end']);
$export_csv .= HtmlInput::hidden('histo', $_GET['histo']);
$export_csv .= HtmlInput::request_to_hidden(array('allcard'));
$export_csv .= dossier::hidden();
$export_csv .= HtmlInput::submit('CSV', 'Export en CSV');
$export_csv .= '</FORM>';
/*
 * Date is important is requested balance
 */
if (isDate($_REQUEST['start']) == null || isDate($_REQUEST['end']) == null) {
    echo h2('Date invalide !', 'class="error"');
    alert('Date invalide !');
    return;
}
/*************************************************************************************************************************
 * Balance agée tous
/*************************************************************************************************************************/
if ($_GET['histo'] == 6) {
    require_once NOALYSS_INCLUDE . '/class_balance_age.php';
    $bal = new Balance_Age($cn);
    $export_csv = '<FORM METHOD="get" ACTION="export.php" style="display:inline">';
    $export_csv .= HtmlInput::request_to_hidden(array('gDossier', 'ac', 'p_let', 'p_date_start'));
    $export_csv .= HtmlInput::hidden('p_date_start', $_GET['start']);
    $export_csv .= HtmlInput::hidden('act', 'CSV:balance_age');
    $export_csv .= HtmlInput::hidden('p_let', 'let');
    $export_csv .= HtmlInput::hidden('p_type', 'X');
Beispiel #13
0
head('jMList');
topheading('home');
open('div', array('id' => 'body'));
h2('Overview');
$_jMList = txttag('span', array('class' => 'jmlist'), 'jMList');
$_XML = acronym('XML', 'eXtensible Markup Language');
$_HTML = acronym('HTML', 'HyperText Markup Language');
$_XSL = acronym('XSL', 'eXtensible Stylesheet Language');
$_RDF = acronym('RDF', 'Resource Description Framework');
$_RSS = acronym('RSS', 'RDF Site Summary');
tag('p', array(), "{$_jMList} is a small utility that scans one or more given " . "directories for media files (currently only audio files) and " . "generates a {$_XML} listing of the whole directory tree with " . "information about each media file such as filesize, song length, " . "title, author, album, etc. A {$_XSL} stylesheet can be applied to " . "the output to transform into a different output, like tabular or " . "tree listings in plain text, {$_XML}, {$_HTML}, {$_RDF}, {$_RSS} or any " . "other {$_XML} format.");
$_MP3 = acronym('MP3', 'MPEG Layer-3');
$_FLAC = acronym('FLAC', 'Free Lossless Audio Codec');
tag('p', array(), "{$_jMList} is still in its earlier stages of developement, but it " . "already supports identification of {$_MP3} and OGG files and is capable " . "of extracting meta-information from ID3, ID3v2 and Vorbis tags.");
tag('p', array(), "{$_jMList} is released under the " . a('GNU', 'http://www.gnu.org/') . " " . a('General Public License', 'http://www.gnu.org/licenses/gpl.html') . ".");
h2('Features');
tag('p', array(), "The following features are currently supported by {$_jMList}:");
open('ol', array());
tag('li', array(), "Internally transform output through {$_XSL}.");
tag('li', array(), "Parsing information from MPEG Layer 1, 2 and 3 ({$_MP3}) files, both ID3 v1 and v2 tags.");
tag('li', array(), "Parsing information from Ogg Vorbis (OGG) files.");
tag('li', array(), "Full Unicode support.");
tag('li', array(), "Parsing data in UTF-8 and ISO8859-1 encondings from ID3 tags.");
close();
tag('p', array(), "The following features are planned to be supported:");
$_NLS = acronym('NLS', 'National Language Support');
$_i18n = acronym('i18n', 'internationalization');
open('ol');
tag('li', array(), "Detect and parse data from tags based on an user-provided list of possible character encodings.");
tag('li', array(), "Properly support files > 2GiB.");
tag('li', array(), "National Language ({$_NLS}, {$_i18n}) support");
Beispiel #14
0
    It is this simple "L" prefix in front of the string that makes it work by telling the compiler to produce a wide string. Wide strings are a strange beast
    in C++: the standard doesn't say anything about their size (16-bit? 32-bit?), nor about the encoding that they use (UTF-16? UTF-32?). However
    we know that on most platforms, if not all, they'll produce Unicode strings, and SFML knows how to handle them correctly.
</p>
<p>
    Note that the C++11 standard supports new character types and prefixes to build UTF-8, UTF-16 and UTF-32 string literals, but SFML doesn't support
    them yet.
</p>
<p>
    It may seem obvious, but you also have to make sure that the font that you use contains the characters that you want to draw. Indeed, fonts
    don't contain glyphs for all possible characters (there are more than 100000 in the Unicode standard!), and an arabic font won't be able to display japanese
    text, for example.
</p>

<?php 
h2('Making your own text class');
?>
<p>
    If <?php 
class_link('Text');
?>
 is too limited, or if you want to do something else with pre-rendered glyphs, <?php 
class_link('Font');
?>
 provides
    everything that you need.
</p>
<p>
    You can retrieve the texture which contains all the pre-rendered glyphs of a certain size:
</p>
<pre><code class="cpp">const sf::Texture&amp; texture = font.getTexture(characterSize);
echo "Done\n";
//*/
///*
echo "----- test using literals, constants, and arbitrary-complex expressions ----\n";
//$a =& 12;     // literals are disallowed
//$a =& CON;    // constants are disallowed
$b = 10;
$a =& $b;
echo "After '=&', \$a is {$a}, \$b is {$b}\n";
//$a =& 5 + $b; // arbitrary-complex expressions are disallowed
echo "After '=&', \$a is {$a}, \$b is {$b}\n";
function h1()
{
    $b = 10;
    return $b + 5;
    //  return 12;
    //  return CON;
}
echo "h1() is " . h1() . "\n";
//*/
///*
function &h2()
{
    $b = 10;
    //  return $b + 5;  // Only variable references should be returned by reference
    //  return 12;
    //  return CON;
}
h2();
echo "Done\n";
//*/
 *   along with NOALYSS; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// Copyright Author Dany De Bontridder danydb@aevalys.eu
/**\file
 * \brief display a form to change the name of a predefined operation
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
ob_start();
require_once NOALYSS_INCLUDE . '/class_pre_operation.php';
$op = new Pre_Operation($cn, $_GET['id']);
$array = $op->load();
echo HtmlInput::anchor_close('mod_predf_op');
echo h2(_('Modification du nom'), ' class="title"');
echo '
    <form method="POST" onsubmit="save_predf_op(this);return false;">';
$name = new IText('opd_name');
$name->value = $op->od_name;
$name->size = 60;
echo "Nom =" . $name->input();
$opd_description = new ITextarea('od_description');
$opd_description->style = ' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
$opd_description->value = $op->od_description;
echo '<p>';
echo _("Description (max 50 car.)");
echo $opd_description->input();
echo '</p>';
echo dossier::hidden() . HtmlInput::hidden('od_id', $_GET['id']);
echo "<hr>";
Beispiel #17
0
        <tt>/Library/Developer/Xcode/Templates</tt> (si besoin, créez d'abord l'arborescence de répertoires).
    </li>
</ul>
<p>
    SFML est fournie avec un script <tt>install.sh</tt> qui peut installer tous les composants pour vous.
    Il va faire attention à conserver les éventuelles anciennes version de SFML sur votre système, tout spécialement les frameworks,
    de sorte que vos applications puissent toujours s'exécuter sans modification.
    Vous avez seulement à ouvrir un terminal dans le répertoire du SDK téléchargé et lancer <code>./install.sh</code>.
    Le script va alors vous demander votre mot de passe et tout installer à la bonne place.
</p>
<p>
    À noter que <tt>/Library</tt> peut être nommé <tt>/Bibliothèque</tt> si votre système est en français.
</p>

<?php 
h2('Créer un premier programme SFML');
?>
<p>
    Nous fournissons deux templates pour Xcode. <tt>SFML CLT</tt> génère un projet pour une application terminal classique alors que <tt>SFML App</tt> crée un projet pour
    un bundle d'application. Nous allons utiliser ce dernier ici mais ils fonctionnent relativement similairement.
</p>
<p>
    Tout d'abord, choisissez <tt>File &gt; New Project...</tt> puis sélectionnez <tt>SFML</tt> dans la colonne de gauche et double cliquez sur <tt>SFML App</tt>.
</p>
<img class="screenshot" src="images/start-osx-new-project.png" alt="Sélection du template Xcode" title="Sélection du template Xcode" />
<p>
    Maintenant vous pouvez remplire les champs requis comme dans cette capture d'écran ; puis pressez <tt>next</tt>.
</p>
<img class="screenshot" src="images/start-osx-new-project-settings.png" alt="Formulaire du template Xcode" title="Formulaire du template Xcode" />
<p>
    Votre nouveau projet est maintenant configuré pour créer un
</p>
<pre><code class="cpp">sound.setVolume(50);
</code></pre>
</p>
    La propriété <em>loop</em> détermine si le son ou la musique boucle automatiquement ou non. S'il boucle, il recommencera à zéro dès qu'il se finira,
    encore et encore jusqu'à ce que vous appeliez explicitement <code>stop</code>. Sinon, il s'arrêtera automatiquement lorsqu'il est fini.
</p>
<pre><code class="cpp">sound.setLoop(true);
</code></pre>
<p>
    D'autres propriétés sont disponible, mais elles sont liées à la spacialisation et sont expliquées dans le
    <a class="internal" href="./audio-spatialization-fr.php" title="Tutoriel sur la spacialisation">tutoriel correspondant</a>.
</p>

<?php 
h2('Erreur courantes');
?>

<h3>Buffer audio détruit</h3>
<p>
    L'erreur la plus courante est de déclarer un buffer dans une portée réduite (telle qu'une fonction) et le laisser mourir à la fin alors qu'un son
    l'utilise toujours.
</p>
<pre><code class="cpp">sf::Sound loadSound(std::string filename)
{
    sf::SoundBuffer buffer; // ce buffer est local à la fonction, il sera détruit...
    buffer.loadFromFile(filename);
    return sf::Sound(buffer);
} // ... ici

sf::Sound sound = loadSound("s.wav");
}
</code></pre>
<p>
    Ces opérateurs renvoient une référence sur le paquet : cela permet de chaîner les appels.
</p>
<p>
    Maintenant que ces opérateurs sont définis, vous pouvez insérer/extraire un <code>Character</code> dans/depuis un paquet comme n'importe quel autre type primitif :
</p>
<pre><code class="cpp">Character bob;

packet &lt;&lt; bob;
packet &gt;&gt; bob;
</code></pre>

<?php 
h2('Les paquets personnalisés');
?>
<p>
    Les paquets offrent des fonctionnalités sympas par dessus vos données brutes, mais peut-on aller plus loin et ajouter vos propres fonctionnalités, comme par exemple
    compresser ou chiffrer automatiquement les données lors de l'envoi ? Cela peut être fait très facilement, en créant une classe dérivée de <?php 
class_link('Packet');
?>
    et en redéfinissant les fonctions suivantes :
</p>
<ul>
    <li><code>onSend</code>: appelée juste avant que la socket envoie les données</li>
    <li><code>onReceive</code>: appelée juste après que la socket a reçu les données</li>
</ul>
<p>
    Ces fonctions fournissent un accès direct aux données, de manière à ce que vous puissiez les transformer selon vos besoin.
</p>
Beispiel #20
0
while (window.pollEvent(event))
{
    ...

    // catch the resize events
    if (event.type == sf::Event::Resized)
    {
        // update the view to the new size of the window
        sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
        window.setView(sf::View(visibleArea));
    }
}
</code></pre>

<?php 
h2('Coordinates conversions');
?>
<p>
    When you use a custom view, or when you resize the window without using the code above, pixels displayed on the target no longer match units in the 2D world. For example,
    clicking on pixel (10, 50) may hit the point (26.5, -84) of your world. You end up having to use a conversion function to map your pixel coordinates to world coordinates:
    <code>mapPixelToCoords</code>.
</p>
<pre><code class="cpp">// get the current mouse position in the window
sf::Vector2i pixelPos = sf::Mouse::getPosition(window);

// convert it to world coordinates
sf::Vector2f worldPos = window.mapPixelToCoords(pixelPos);
</code></pre>
<p>
    By default, <code>mapPixelToCoords</code> uses the current view. If you want to convert the coordinates using view which is not the active one, you can pass it as an
    additional argument to the function.
<p>
    Utiliser un nombre réduit de textures est globalement une bonne stratégie, et la raison en est simple : changer la texture courante est une opération coûteuse pour la
    carte graphique. Dessiner plusieurs sprites qui utilisent la même texture donnera des performances optimales.
</p>
<p>
    De plus, utiliser une unique texture vous permettra si nécessaire de regrouper toute la géometrie statique en une seule entité (vous ne pouvez en effet utiliser
    qu'une seule texture par appel à la fonction <code>draw</code>), ce qui sera nettement plus performant que de dessiner un groupe de plusieurs entités.
    Regrouper la géometrie statique implique d'autres classes et est donc hors sujet dans ce tutoriel, pour plus de détails vous pouvez aller voir le tutoriel sur 
    <a href="./graphics-vertex-array-fr.php" title="Tutoriel sur les tableaux de vertex">les tableaux de vertex</a>.
</p>
<p>
    Gardez bien cela en tête lorsque vous créez vos textures d'animation ou de tuiles (<em>sprite sheets</em> et <em>tilesets</em>) : utilisez si possible une seule texture.
</p>

<?php 
h2('Utiliser sf::Texture dans du code OpenGL');
?>
<p>
    Si vous utilisez OpenGL plutôt que les entités graphiques de SFML, vous pouvez toujours utiliser <?php 
class_link("Texture");
?>
 comme encapsulation d'une texture OpenGL,
    et la faire intéragir avec vos entités OpenGL.
</p>
<p>
    Afin d'activer une <?php 
class_link("Texture");
?>
 pour le rendu (l'équivalent de <code>glBindTexture</code>), vous devez appeler la fonction statique
    <code>bind</code> :
</p>
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with NOALYSS; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// Copyright Author Dany De Bontridder danydb@aevalys.eu
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_default_menu.php';
global $cn, $g_failed, $g_succeed;
$a_default = new Default_Menu();
if (isset($_POST['save_menu_default'])) {
    $a_default->set('code_follow', $_POST['code_follow']);
    $a_default->set('code_invoice', $_POST['code_invoice']);
    try {
        $a_default->save();
        echo h2("Sauvé", 'class="notice"', $g_succeed);
    } catch (Exception $ex) {
        echo h2("Code menu invalide", 'class="notice"', $g_failed);
    }
}
echo '<form method="POST">';
echo HtmlInput::hidden('ac', $_REQUEST['ac']);
echo Dossier::hidden();
$a_default->input_value();
echo HtmlInput::submit('save_menu_default', _("Sauver"));
echo '</form>';
?>
 ci-dessus.
</p>
<pre><code class="cpp">if (!MyRecorder::isAvailable())
{
    // erreur...
}

MyRecorder recorder;
recorder.start();
...
recorder.stop();
</code></pre>

<?php 
h2('Attention aux threads');
?>
<p>
    Comme la capture est effectuée dans un thread, il est important de savoir ce qui se passe exactement, et où.
</p>
<p>
    <code>onStart</code> sera appelée directement par la fonction <code>start</code>, donc elle sera exécutée dans le thread qui l'a appelée. Par contre,
    <code>onProcessSample</code> et <code>onStop</code> seront toujours appelées depuis le thread de capture interne que SFML crée.
</p>
<p>
    Donc, si votre enregistreur utilise des données qui peuvent être accédées de manière <em>concurrente</em> (c'est-à-dire en même temps) à la fois par
    le thread appelant et par le thread d'enregistrement, il faudra les protéger (avec un mutex ou autre) afin d'éviter les accès concurrents, qui
    pourraient entraîner des comportements indéterminés -- données audio corrompues, crashs, etc.
</p>
<p>
    Si vous n'êtes pas suffisamment à l'aise avec les problèmes liés aux threads, vous pouvez faire un saut par le
Beispiel #24
0
    <li>The header: a set of fields with key and value</li>
    <li>The body of the response</li>
</ul>
<pre><code class="cpp">sf::Http::Response response = http.sendRequest(request);
std::cout &lt;&lt; "status: " &lt;&lt; response.getStatus() &lt;&lt; std::endl;
std::cout &lt;&lt; "HTTP version: " &lt;&lt; response.getMajorHttpVersion() &lt;&lt; "." &lt;&lt; response.getMinorHttpVersion() &lt;&lt; std::endl;
std::cout &lt;&lt; "Content-Type header:" &lt;&lt; response.getField("Content-Type") &lt;&lt; std::endl;
std::cout &lt;&lt; "body: " &lt;&lt; response.getBody() &lt;&lt; std::endl;
</code></pre>
<p>
    The status code can be used to check whether the request was successfully processed or not: codes 2xx represent success, codes 3xx represent a redirection, codes 4xx represent client
    errors, codes 5xx represent server errors, and codes 10xx represent SFML specific errors which are <em>not</em> part of the HTTP standard.
</p>

<?php 
h2('Example: sending scores to an online server');
?>
<p>
    Here is a short example that demonstrates how to perform a simple task: Sending a score to an online database.
</p>
<pre><code class="cpp">#include &lt;SFML/Network.hpp&gt;
#include &lt;sstream&gt;

void sendScore(int score, const std::string&amp; name)
{
    // prepare the request
    sf::Http::Request request("/send-score.php", sf::Http::Request::Post);

    // encode the parameters in the request body
    std::ostringstream stream;
    stream &lt;&lt; "name=" &lt;&lt; name &lt;&lt; "&amp;score=" &lt;&lt; score;
    If you want to use C++11 features in your application on Mac OS X, you have to use clang (Apple's official compiler) and libc++. Moreover, you will need to build SFML with
    these tools to work around any incompatibility between the standard libraries and compilers.
</p>
<p>
    Here are the settings to use to build SFML with clang and libc++:
</p>
<ul>
    <li>Choose "Specify native compilers" rather than "Use default native compilers" when you select the generator.</li>
    <li>Set <code>CMAKE_CXX_COMPILER</code> to /usr/bin/clang++ (see screenshot).</li>
    <li>Set <code>CMAKE_C_COMPILER</code> to /usr/bin/clang (see screenshot).</li>
    <li>Set <code>CMAKE_CXX_FLAGS</code> and <code>CMAKE_C_FLAGS</code> to "-stdlib=libc++".</li>
</ul>
<img class="screenshot" src="./images/cmake-osx-compilers.png" alt="Screenshot of the compiler configuration on OS X" title="Screenshot of the compiler configuration on OS X" />

<?php 
h2('Building SFML');
?>
<p>
    Let's begin this section with some good news: you won't have to go through the configuration step any more, even if you update your working copy of
    SFML. CMake is smart: It adds a custom step to the generated makefiles/projects, that automatically regenerates the build files whenever
    something changes.
</p>
<p>
    You're now ready to build SFML. Of course, how to do it depends on what makefiles/projects you've generated. If you created
    a project/solution/workspace, open it with your IDE and build SFML like you would any other project. We won't go into the details here,
    there are simply too many different IDEs and we have to assume that you know how to use yours well enough to perform this simple task on your own.
</p>
<p>
    If you generated a makefile, open a command shell and execute the make command corresponding to your environment. For example, run "nmake" if
    you generated an NMake (Visual Studio) makefile, "mingw32-make" if you generated a MinGW (GCC) makefile, or simply "make" if you generated a Linux
    makefile.<br />
Beispiel #26
0
    <li><a href="graphics-sprite-fr.php" title="Sprites et textures">Sprites et textures</a></li>
    <li><a href="graphics-text-fr.php" title="Texte et polices">Texte et polices</a></li>
    <li><a href="graphics-shape-fr.php" title="Dessiner des formes">Dessiner des formes</a></li>
    <li><a href="graphics-vertex-array-fr.php" title="Concevoir ses entités avec les tableaux de vertex">Concevoir ses entités avec les tableaux de vertex</a></li>
    <li><a href="graphics-transform-fr.php" title="Position, rotation, échelle : transformer des entités">Position, rotation, échelle : transformer des entités</a></li>
    <li><a href="graphics-shader-fr.php" title="Effets spéciaux avec les shaders">Effets spéciaux avec les shaders</a></li>
    <li><a href="graphics-view-fr.php" title="CContrôler la caméra 2D avec les vues">Contrôler la caméra 2D avec les vues</a></li>
</ul>

<?php 
h2('Module audio');
?>
<ul>
    <li><a href="./audio-sounds-fr.php" title="Jouer des sons et des musiques">Jouer des sons et des musiques</a></li>
    <li><a href="./audio-recording-fr.php" title="Effectuer des captures audio">Effectuer des captures audio</a></li>
    <li><a href="./audio-streams-fr.php" title="Flux audio personnalisés">Flux audio personnalisés</a></li>
    <li><a href="./audio-spatialization-fr.php" title="Spacialisation : les sons en 3D">Spacialisation : les sons en 3D</a></li>
</ul>

<?php 
h2('Module réseau');
?>
<ul>
    <li><a href="./network-socket-fr.php" title="Communiquer avec les sockets">Communiquer avec les sockets</a></li>
    <li><a href="./network-packet-fr.php" title="Utiliser et étendre les paquets">Utiliser et étendre les paquets</a></li>
    <li><a href="./network-http-fr.php" title="Requêtes web avec HTTP">Requêtes web avec HTTP</a></li>
    <li><a href="./network-ftp-fr.php" title="Transferts de fichiers avec FTP">Transferts de fichiers avec FTP</a></li>
</ul>

<?php 
require "footer-fr.php";
<p>
    Puis nous pouvons insérer notre code SFML :
</p>
<pre><code class="cpp">// On efface la vue
SFMLView.Clear();

// On affiche un sprite
SFMLView.Draw(Sprite);

// On rafraîchit la vue à l'écran
SFMLView.Display();
</code></pre>
<p>
    N'oubliez pas de libérer vos ressources X11 avant de quitter l'application :
</p>
<pre><code class="cpp">// On ferme la connection avec le serveur X
XCloseDisplay(Disp);
</code></pre>

<?php 
h2('Conclusion');
?>
<p>
    Intégrer la SFML à une interface X11 n'est pas très compliqué, et si vous avec l'habitude de la programmation
    avec Xlib cela ne vous demandera pas plus d'efforts que n'importe quelle autre application SFML.<br/>
    Voyons maintenant comment réaliser l'intégration dans des
    <a class="internal" href="./graphics-wxwidgets-fr.php" title="Aller au tutoriel suivant">interfaces wxWidgets</a>.
</p>

<?php 
require "footer-fr.php";
Beispiel #28
0
    <a class="internal" href="./start-linux.php" title="Building SFML in Linux">this tutorial</a> if you're not sure how to do it.
</p>
<p>
    Once the RubySFML archive has been extracted to your hard drive, go into the ruby/RubySFML directory, and run
    "ruby extconf-linux.rb". This will automatically create a makefile for compiling RubySFML.
</p>
<p>
    Run "make" to build the RubySFML files.
</p>
<p>
    After that, everything should be ready to use RubySFML. If Ruby complains about undefined modules or classes,
    make sure that all the RubySFML files are into an appropriate location so that Ruby can find them.
</p>

<?php 
h2('Writing your first RubySFML program');
?>
<p>
    Unlike the C++ libraries, RubySFML gathers all the SFML classes into a single module ("SFML"). As Ruby doesn't support
    native threading, and has its own networking classes, only some classes of the System, Window, Graphics and Audio
    modules are exposed in RubySFML.
</p>
<p>
    Here is a very simple piece of SFML code that opens a window and displays some text :
</p>

<pre><code class="no-highlight"># Include the RubySFML extension
require "RubySFML"
include SFML

# Create the main window
Beispiel #29
0
<p class="important">
    There are multiple variants of GCC for Windows, which are incompatible with each other (different exception management,
    threading model, etc.). Make sure you select the package which corresponds to the version that you use. If you are unsure, check which of
    the libgcc_s_sjlj-1.dll or libgcc_s_dw2-1.dll files is present in your MinGW/bin folder. If MinGW was installed along with Code::Blocks,
    you probably have an SJLJ version.
    <br />
    If you feel like your version of GCC can't work with the precompiled SFML libraries, don't hesitate to
    <a class="internal" href="./compile-with-cmake.php" title="How to compile SFML">build SFML yourself</a>, it's not complicated.
</p>
<p>
    You can then unpack the SFML archive wherever you like. Copying headers and libraries to your installation of MinGW is not recommended, it's better
    to keep libraries in their own separate location, especially if you intend to use several versions of the same library, or several compilers.
</p>

<?php 
h2('Creating and configuring a SFML project');
?>
<p>
    The first thing to do is choose what kind of project to create. Code::Blocks offers a wide variety of project types, including an
    "SFML project". <strong>Don't use it!</strong> It hasn't been updated in a long time and is likely incompatible with recent versions of SFML. Instead, create an Empty project. If you want to get rid of the
    console, in the project properties, go to the "Build targets" tab and select "GUI application" in the combo box instead of "Console application".
</p>
<p>
    Now we need to tell the compiler where to find the SFML headers (.hpp files), and the linker where to find the SFML libraries (.a files).
</p>
<p>
    In the project's "Build options", "Search directories" tab, add:
</p>
<ul>
    <li>The path to the SFML headers (<em>&lt;sfml-install-path&gt;/include</em>) to the Compiler search directories</li>
    <li>The path to the SFML libraries (<em>&lt;sfml-install-path&gt;/lib</em>) to the Linker search directories</li>
    Il est important de noter que le vecteur "up" de l'écouteur est fixé à (0, 1, 0), en d'autres termes sa tête est orientée le long de l'axe +Y.
</p>
<p>
    Enfin, l'écouteur permet d'ajuster le volume global de l'environnement audio :
</p>
<pre><code class="cpp">sf::Listener::setGlobalVolume(50.f);
</code></pre>
<p>
    La valeur du volume est comprise entre 0 et 100, ainsi la mettre à 50 réduit le volume de moitié.
</p>
<p>
    Toutes ces propriétés peuvent bien entendu être relues via les fonctions <code>get</code> correspondantes.
</p>

<?php 
h2('Les sources audio');
?>
<p>
    Toutes les sources audio fournies par SFML (sons, musiques, flux) définissent les mêmes propriétés pour la spatialisation.
</p>
<p>
    La propriété principale est la position de la source audio.
</p>
<pre><code class="cpp">sound.setPosition(2.f, 0.f, -5.f);
</code></pre>
<p>
    Cette position est absolue par défaut, mais elle peut devenir relative à l'écouteur si nécessaire.
</p>
<pre><code class="cpp">sound.setRelativeToListener(true);
</code></pre>
<p>