Bonjour à tous,

J'utilise ce code :

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
 
#ifndef H_WRITER
#define H_WRITER
#include "Define.h"
 
class Writer
{
	public:
		Writer();
 
		void PrintString (int numFont, char* s, int Left, int Top);
 
 
	protected:
 
	private:
        void* BitmapFonts[7];
 
 
};
 
 
 
#endif // H_WRITER

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
 
Writer::Writer()
{
 
    void* BitmapFonts[7] = {
        GLUT_BITMAP_9_BY_15,
        GLUT_BITMAP_8_BY_13,
        GLUT_BITMAP_TIMES_ROMAN_10,
        GLUT_BITMAP_TIMES_ROMAN_24,
        GLUT_BITMAP_HELVETICA_10,
        GLUT_BITMAP_HELVETICA_12,
        GLUT_BITMAP_HELVETICA_18
    };
}
 
void Writer::PrintString(int numFont, char* s, int Left, int Top)
{
    void *Font;
    Font=BitmapFonts[numFont];
    //void *Font=GLUT_BITMAP_9_BY_15;
    glRasterPos2i(Left, Top);
    if (s && strlen(s)) {
        while (*s) {
            glutBitmapCharacter(Font, *s);
            s++;
        }
    }
}
Lorsque j'utilise PrintString avec une instance de writer, je n'ai rien dans BitmapFonts.


Si j'utilise ce code à la place, il n'y a aucun problème :

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
 
#ifndef H_WRITER
#define H_WRITER
#include "Define.h"
 
class Writer
{
	public:
		Writer();
 
		void PrintString (int numFont, char* s, int Left, int Top);
 
 
	protected:
 
	private:
 
 
 
};
 
 
 
#endif // H_WRITER

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
 
Writer::Writer()
{
 
 
}
 
void Writer::PrintString(int numFont, char* s, int Left, int Top)
{
     void* BitmapFonts[7] = {
        GLUT_BITMAP_9_BY_15,
        GLUT_BITMAP_8_BY_13,
        GLUT_BITMAP_TIMES_ROMAN_10,
        GLUT_BITMAP_TIMES_ROMAN_24,
        GLUT_BITMAP_HELVETICA_10,
        GLUT_BITMAP_HELVETICA_12,
        GLUT_BITMAP_HELVETICA_18
    };
    void *Font;
    Font=BitmapFonts[numFont];
    //void *Font=GLUT_BITMAP_9_BY_15;
    glRasterPos2i(Left, Top);
    if (s && strlen(s)) {
        while (*s) {
            glutBitmapCharacter(Font, *s);
            s++;
        }
    }
}
Je débute en C++ et tout est encore flou. Si quelqu'un veut bien m'expliquer mon erreur.

Merci