IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

DirectX Discussion :

[Delphi et DirectX] Tableau de vertices


Sujet :

DirectX

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut [Delphi et DirectX] Tableau de vertices
    Bonjour, j'ai un probleme qui me bloque pas mal. J'arrive a créer et afficher un tableau de vertices lorsque je le crée moi meme en CONSTANTE mais lorsque je met ce meme tableau de vertice en variable, le programme plante, plus rien ne marche... je ne c pas comment faire. Merci davance pour vos reponse

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    voila un peu de code... c'est vraiment bizarre comme probleme... Ne serais ce pas a cause du D3DPOOL_DEFAULT... moi je sèche...

    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
     
    type
      TCustomVertex = packed record
        x, y, z: Single; // The transformed position for the vertex
        color: DWORD;         // The vertex color
      end;
     
    var
      g_pVB: IDirect3DVertexBuffer9 = nil; // Buffer to hold vertices
      g_pIB: IDirect3DIndexBuffer9 = nil;
     
      vertices  : array [0..3] of TCustomVertex;
      index     : array [0..5] of Integer;
     
      for y := 0 to HAUTEUR do
      begin
        for x := 0 to LARGEUR do
        begin
          vertices[x + y * (LARGEUR + 1)].x := x * 10 ;
          vertices[x + y * (LARGEUR + 1)].y := y * 10;    //height
          vertices[x + y * (LARGEUR + 1)].z := -11;
          vertices[x + y * (LARGEUR + 1)].color := $00000000;				//color
        end;
      end;
     
      i := 0;
      // Les indices associés
      for y := 0 to HAUTEUR do
      begin
        for x := 0 to LARGEUR do
        begin
          index[i] := x + y * (LARGEUR + 1);					  inc(i);//v1
          index[i] := x + 1 + y * (LARGEUR + 1);		 		inc(i);//v2
          index[i] := x + 1 + (y + 1) * (LARGEUR + 1);  inc(i);//v4
     
          index[i] := x + y * (LARGEUR + 1);					  inc(i);//v1
          index[i] := x + 1 + (y + 1) * (LARGEUR + 1);	inc(i);//v4
          index[i] := x + (y + 1) * (LARGEUR + 1);			inc(i);//v3
        end;
      end;
     
     
      if FAILED(g_pd3dDevice.CreateVertexBuffer(4*SizeOf(TCustomVertex),
                                                0, D3DFVF_CUSTOMVERTEX,
                                                D3DPOOL_DEFAULT, g_pVB, nil))
      then Exit;
     
      if FAILED(g_pVB.Lock(0, SizeOf(vertices), pVertices, 0))
      then Exit;
     
      CopyMemory(pVertices, @vertices, SizeOf(vertices));
      g_pVB.Unlock;
     
      if FAILED(g_pd3dDevice.CreateIndexBuffer(sizeof(integer) * 6,D3DUSAGE_WRITEONLY,
                                                                             D3DFMT_INDEX32,
                                                                             D3DPOOL_MANAGED,
                                                                             g_pIB, nil))
      then Exit;
     
      g_pIB.Lock(0,SizeOf(index), pIndex, 0);
      CopyMemory(pIndex, @index, SizeOf(index));
      g_pIB.Unlock;
    Alors que comme ca ca marche parfaitement
    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
     
    const
     
      vertices: array[0..3] of TCustomVertex = (
        (x:   -10.0; y:  -10.0; z:  0; color: $00000000), // x, y, z, rhw, color),
        (x:   -10.0; y:   10.0; z:  0; color: $00000000),
        (x:    10.0; y:  -10.0; z:  0; color: $00000000),
        (x:    10.0; y:   10.0; z:  0; color: $00000000)
      );
      index: array[0..5] of integer = ( 0,1,2,3,1,2 );
    var
      pVertices: Pointer;
      pIndex: Pointer;
    begin
      Result:= E_FAIL;
     
      if FAILED(g_pd3dDevice.CreateVertexBuffer(4*SizeOf(TCustomVertex),
                                                0, D3DFVF_CUSTOMVERTEX,
                                                D3DPOOL_DEFAULT, g_pVB, nil))
      then Exit;
     
    vertex
     
      if FAILED(g_pVB.Lock(0, SizeOf(vertices), pVertices, 0))
      then Exit;
     
      CopyMemory(pVertices, @vertices, SizeOf(vertices));
      g_pVB.Unlock;
     
      if FAILED(g_pd3dDevice.CreateIndexBuffer(sizeof(integer) * 6,D3DUSAGE_WRITEONLY,
                                                                             D3DFMT_INDEX32,
                                                                             D3DPOOL_MANAGED,
                                                                             g_pIB, nil))
      then Exit;
     
      g_pIB.Lock(0,SizeOf(index), pIndex, 0);
      CopyMemory(pIndex, @index, SizeOf(index));
      g_pIB.Unlock;
     
     
      Result:= S_OK;
    PS: j'ai bien vérifié en debuggant, mes tableaux sont bien crée dans le premier code.

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    quoi personne?!! Eh bé

  4. #4
    Inactif  

    Homme Profil pro
    Ingénieur test de performance
    Inscrit en
    Décembre 2003
    Messages
    1 986
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur test de performance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 986
    Points : 2 605
    Points
    2 605
    Par défaut
    Tu auras peut-être plus de chance d'être aider sur un forum delphi.

    Est-il vrai que le support de delphiX a été abandonné?

    A quel endroit ton programme plante.

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Ca plante au moment de la sortie de la fonction qui charge les vertices... jy comprend rien....

  6. #6
    Inactif  

    Homme Profil pro
    Ingénieur test de performance
    Inscrit en
    Décembre 2003
    Messages
    1 986
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur test de performance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 986
    Points : 2 605
    Points
    2 605
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    for y := 0 to HAUTEUR do
      begin
        for x := 0 to LARGEUR do
        begin
          vertices[x + y * (LARGEUR + 1)].x := x * 10 ;
          vertices[x + y * (LARGEUR + 1)].y := y * 10;    //height
          vertices[x + y * (LARGEUR + 1)].z := -11;
          vertices[x + y * (LARGEUR + 1)].color := $00000000;            //color
        end;
      end;
    Quelles sont les valeurs de HAUTEUR et LARGEUR, je soupçonne un débordement de tableau. Si LARGEUR est supérieur à 0, alors tu écris à tous les coups en dehors des indices.

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Bah non Largeur et Hauteur sont a 1 pour l'instant ce qui fait
    que je m'arrete a la case 3 pour le tableau de vertices et a 6 pour les indices. Enfin j espere que je ne me trompe pas...

  8. #8
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Mais quel abrut* je fais... désolé de vous avoir dérangé pour rien... il y a bel et bien un dépassement de tableau mais comme en débuggant ca me disait rien je n'y croyais pas... Voyons voir si ca marche maintenant et encore désolé...

  9. #9
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    en fait c'est ca que j'ai du mal à traduire en Delphi.. je ne comprends pas trop ce qui ce passe... la syntaxe m'echappe un peu, quelqu'un pourrait il me le dire?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    for(y = 0;y < TERRAIN_Y;++y)
     {
     for(unsigned x = 0;x < TERRAIN_X;++x)
      {
      *pIndexData++ = x + y * (TERRAIN_X + 1);
      *pIndexData++ = x + 1 + y * (TERRAIN_X + 1);
      *pIndexData++ = x + 1 + (y + 1) * (TERRAIN_X + 1);
     
      *pIndexData++ = x + y * (TERRAIN_X + 1);
      *pIndexData++ = x + 1 + (y + 1) * (TERRAIN_X + 1);
      *pIndexData++ = x + (y + 1) * (TERRAIN_X + 1);
      }
     }

  10. #10
    Candidat au Club
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Alala désolez pour le multi-post. Sujet résolu, il suffisait juste d'aller jusqu'à
    HAUTEUR - 1 et LARGEUR - 1

    Merci à tous et surtout a toi Moldavi de m'avoir aiguillé

Discussions similaires

  1. [delphi 7] [String] [Tableau d'octets]
    Par mkiba dans le forum Débuter
    Réponses: 7
    Dernier message: 17/03/2008, 17h12
  2. Equivalent GLSCENE (OpenGl-Delphi) en DirectX-C# ?
    Par Graffito dans le forum Windows Forms
    Réponses: 5
    Dernier message: 07/01/2008, 12h00
  3. Tableau : texte vertical dépasse du cadre !
    Par AltGr dans le forum Tableaux - Graphiques - Images - Flottants
    Réponses: 1
    Dernier message: 13/06/2007, 14h35
  4. Tableau en vertical
    Par Eric06 dans le forum Tableaux - Graphiques - Images - Flottants
    Réponses: 2
    Dernier message: 10/01/2007, 11h32
  5. [Delphi] et directx
    Par ffomnislash dans le forum DirectX
    Réponses: 1
    Dernier message: 02/11/2005, 11h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo