Salut à tous

J'ai un soucis avec DirectX, c'est que sur une scène ou je tourne à environ 600 FPS, si j'ai le malheur d'afficher 4 pauvres lignes de texte, les FPS chutent à 80 !
Si j'en affiche plus je tombe à 20 et c'est ingérable.

J'ai pourtant créé une classe BitmapFont perso, justement pour éviter d'utiliser GDI avec la classe D3D.Font par défaut de DirectX...

J'ai essayé de tout désactiver (Recherches informations Char, arreter la modification du VertexBuffer, Shader simplifié au maximum... Bref au final apres avoir tout désactiver au lieu d'afficher un texte j'avais une série de carré noir superposés.), rien à faire, au mieux je passe de 80 a 95 FPS...

J'en déduis donc que la chute de FPS vient du fait que ma fonction DrawString appelle une boucle de fonction DrawChar, et que ca lui plait pas...

Voici le code du DrawString:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
public Point DrawString(string Text, int x, int y, Color color, int StartX)
{
    Point carret = new Point(x, y);
 
    for (int i = 0; i < Text.Length; i++)
    {
        if (Text[i] != '\n')
        {
            //Char Info
            FontChar fcChar = _chars[Text[i]];
            //DrawChar
            DrawChar(Text[i], fcChar.XOffset + carret.X, fcChar.YOffset + carret.Y, color);
            carret.X += fcChar.Advance;
         }
    }
    return carret;
}
et du DrawChar
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
public void DrawChar(char c, float x, float y, Color color)
{
    FontChar fcChar = _chars[c];
    float u, v;
 
    //Update Quad
    u = (float)fcChar.TX / (float)_textureWidth;
    v = (float)fcChar.TY / (float)_textureHeight;
    Quad[0] = new CustomVertex.TransformedTextured(x, y, 0f, 1f, u, v);
 
    u = (float)(fcChar.TX + fcChar.TWitdh) / (float)_textureWidth;
    v = (float)fcChar.TY / (float)_textureHeight;
    Quad[1] = new CustomVertex.TransformedTextured(x + fcChar.TWitdh, y, 0f, 1f, u, v);
 
    u = (float)fcChar.TX / (float)_textureWidth;
    v = (float)(fcChar.TY + fcChar.THeight) / (float)_textureHeight;
    Quad[2] = new CustomVertex.TransformedTextured(x, y + fcChar.THeight, 0f, 1f, u, v);
 
    u = (float)(fcChar.TX + fcChar.TWitdh) / (float)_textureWidth;
    v = (float)(fcChar.TY + fcChar.THeight) / (float)_textureHeight;
    Quad[3] = new CustomVertex.TransformedTextured(x + fcChar.TWitdh, y + fcChar.THeight, 0f, 1f, u, v);
 
    //Update VB
    vb.SetData(Quad, 0, LockFlags.None);
 
    //Dessin
    //
    effect.SetValue("objectDiffuse", _texture);
    effect.SetValue("color", new Vector4((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, 0));
    int numPasses = effect.Begin(0);
    for (int a = 0; a < numPasses; a++)
    {
        effect.BeginPass(a);
 
        _device.SetStreamSource(0, vb, 0);
        _device.VertexFormat = CustomVertex.TransformedTextured.Format;
        _device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
 
        effect.EndPass();
    }
    effect.End();
}
Une idée ?
Merci d'avance !

PS: QUand je dis 4 pauvres lignes, c'est vraiment ça:
"Entrer dans le jeu
Configuration
Infos
Quitter"
Et ca me fait perdre 520 FPS !