Bonjour,

Je travail sur un doom-like (pseudo-3D) et lors de l'execution j'ai une erreur du type :
10 [main] game 80344 _cygtls::handle_exceptions: Error while dumping state
(probably corrupted stack)
Segmentation fault (core dumped)

Je suis sur Vista Pro SP1 et travail avec cygwin 1.5.25-15 entièrement installé.
Le hic s'est que sur linux pas d'erreur d'execution...
Cette erreur est apparue après implémentation des bitmaps je pense.

Ah oui encore une chose je ne sais pas débugger... Alors j'avance pas.

Voilà déjà mon main si quelqu'un peut m'aider ça serait vraiment gentil
Merci d'avance !

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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/**
* \file main.cpp
* \brief Game Doom-like.
* \author Serge Metrailler et Martin Page
* \version 1.0
* \date 25.11.07
*
* Jeu video conçu en 3D isometrique.
*
*/
//#include "includes.h"
//#include <vector>
//#include "bmpfile.h"
#include "perso.h"
 
/**
* \fn int main ()
* \brief Entrée du programme.
*
* \return EXIT_SUCCESS - Arrêt normal du programme.
*/
int main()
{
    Niveau n;
    n.chargeNiveau();
    Personnage h(V2(30,30),V2(15,15));
    Personnage m(V2(160,50),V2(21.2132,0));
 
    Drawable d;
    Display *display;
    int ww = 500, wh = 500;
    Window window, windowmap;
    GC gc;
 
 
    //! Connection au serveur X
    const char *serverName = getenv("DISPLAY");
    display = XOpenDisplay(serverName ? serverName : ":0.0");
    if(display == NULL)
    {
        fprintf(stderr, "Cannot connect to X server\n");
    }
 
    //! Recuperation de l'ecran principal
    int screen = DefaultScreen(display);
 
    //! Creation d'une fenetre
    window = XCreateSimpleWindow(display, RootWindow(display, screen),
                                 0, 0, ww, wh, 0, 0, 0xffffff);
    windowmap = XCreateSimpleWindow(display, RootWindow(display,
                                    screen),0, 0, ww, wh, 0, 0, 0xffffff);
    //! Selectionne les evenements qui nous interessent
    //! Ici on ne prend que les touches clavier
    XSelectInput(display, window, KeyPressMask | KeyReleaseMask | 
                 ButtonPressMask | ButtonReleaseMask | PointerMotionMask | 
                 ExposureMask);
 
    //! Affiche la fenetre
    XMapWindow(display, window);
    XMapWindow(display, windowmap);
 
    //! Obtient un contexte d'affichage
    gc = XCreateGC(display, window, 0, NULL);
 
    Pixmap pixmap = XCreatePixmap(display, window, ww, wh, 24);
    Pixmap pixmap1 = XCreatePixmap(display, window, ww, wh, 24);
 
    //! Cree l'image (le XImage)
    unsigned int *px = new unsigned int[ww * wh];
    XImage *img = XCreateImage(display, //! Connection
                               DefaultVisual(display, screen), //! Visuel
                               24, //! Profondeur
                               ZPixmap, //! Type
                               0, //! Offset du debut de ligne
                               (char*)px, //! Donnees
                               ww, wh, //! Dimensions
                               8, //! Padding en bits (8,16 ou 32)
                               ww * 4); //! Taille d'une scanline
 
    //! Ordre des octets
    img->byte_order = LSBFirst;
 
    char *key = new char[2];
    bool running = true;
    KeySym sym;
 
    h.a = false;
    h.b = false;
    h.c = false;
    h.d = false;
 
    while(running)
    {
        XSetForeground(display, gc, 0xffffff);
        XFillRectangle(display, pixmap, gc, 0, 0, ww, wh);
        XFillRectangle(display, pixmap1, gc, 0, 0, ww, wh);
 
        //! Gestion des evenements (boucle active)
        XEvent evt;
        while(XPending(display))
        {
            //! Recoit l'evenement.
            XNextEvent(display, &evt);
            switch(evt.type)
            {
 
                case KeyPress:
                    XLookupString((XKeyPressedEvent *) &evt, key, 1, &sym,
                                  NULL);
 
                    switch(sym)
                    {
 
                        //! Quitte quand on presse q.
                        case 113:
                            running = 0;
                            break;
 
                        //! Avance quand on presse UP ARROW
                        case 119:
                            h.a = true;
                            break;
 
                        //! Recule quand on presse DOWN ARROW
                        case 115:
                            h.b = true;
                            break;
 
                        //! Tourne a droite quand on presse RIGHT ARROW
                        case 100:
                            h.c = true;
                            break;
 
                        //! Tourne a gauche quand on presse LEFT ARROW
                        case 97:
                            h.d = true;
                            break;
                    }
                    break;
                case KeyRelease:
                    XLookupString((XKeyReleasedEvent *) &evt, key, 1, &sym,
                                 NULL);
 
                    switch(sym)
                    {
 
                        //! Relachement de UP ARROW
                        case 119:
                            h.a = false;
                            break;
 
                        //! Relachement de DOWN ARROW
                        case 115:
                            h.b = false;
                            break;
 
                        //! Relachement de RIGHT ARROW
                        case 100:
                            h.c = false;
                            break;
 
                        //! Relachement de LEFT ARROW
                        case 97:
                            h.d = false;
                            break;
                    }
                    break;
                }
                //! Deplacements
                if(h.a == true)
                {
                    h.pos = h.pos + h.dir/20;
                }
                if(h.b ==true)
                {
                    h.pos = h.pos - h.dir/20;
                }
                if(h.c == true)
                {
                    h.dir = V2(h.dir.x*cos(2*3.1415/360)-h.dir.y*
                               sin(2*3.1415/360),
                               h.dir.x*sin(2*3.1415/360)+h.dir.y*cos(2*3.1415
                               /360));
                    h.dirUni = h.dir/h.dir.norme();
                }
                if(h.d == true)
                {
                    h.dir = V2( h.dir.x*cos(-2*3.1415/360)-h.dir.y*
                                sin(-2*3.1415/360),
                                h.dir.x*sin(-2*3.1415/360)+h.dir.y*
                                cos(-2*3.1415/360));
                    h.dirUni = h.dir/h.dir.norme();
                }
            }
        //! Appel des fonctions d'affichage et de proximite
        //! Monstre
        m.proximiteMur(n.listeMur1);
        m.proximitePersonnage(h);
        XSetForeground(display, gc, 0x000000);
        //! Petite sale apres deuxieme teleportation
        if(h.teleportation)
        {
            for(int i=0; i<n.listeMur2.size(); ++i)
            {
                n.listeMur2[i].afficheMur(display,pixmap1,gc);
            }
            h.affiche3D(n.listeMur2, n.listeObjet, display, pixmap, gc, ww, 
                        wh);
            h.proximiteMur(n.listeMur2);
        }
        //! Map principale
        else
        {
            for(int i=0; i<n.listeMur1.size(); ++i)
            {
                n.listeMur1[i].afficheMur(display,pixmap1,gc);
            }
            h.affiche3D(n.listeMur1, n.listeObjet, display, pixmap, gc, ww,
                        wh);
            h.proximiteMur(n.listeMur1);
        }
        //! Humain et monstre sur la carte
        XSetForeground(display, gc, 0x000000);
        XDrawLine(display, pixmap1 , gc, (int)h.pos.x,(int)h.pos.y,
                      (int)h.pos.x+(int)h.dir.x, (int)h.pos.y+(int)h.dir.y);
        if(!h.teleportation)
        {
            XDrawLine(display, pixmap1, gc, (int)m.pos.x, (int)m.pos.y,
                         (int)m.pos.x+(int)m.dir.x, (int)m.pos.y+(int)m.dir.y);
        }
        //! Pixmap
        XCopyArea(display, pixmap, window, gc, 0, 0, ww, wh, 0, 0);
        XCopyArea(display, pixmap1, windowmap, gc, 0, 0, ww, wh, 0, 0);
        XFlush(display);
        usleep(100000);
    }
 
    //! Libere le contexte d'affichage
    XFreeGC(display, gc);
    //! Detruit la fenetre
    XUnmapWindow(display, window);
    XDestroyWindow(display, window);
 
    //! Deconnection du serveur X
    XCloseDisplay(display);
 
    return EXIT_SUCCESS;
}