Bonjour a tous,
j'essais d'afficher du texte dans un programme ogl. Comme j'utilise la sdl je m'en sere pour créer une "image texte" comme ca :
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
 
 
 
void CTexte::createTextureFromText()
 
{
 
 
 
    SDL_Surface *texte_surface,*gl_surface,*gl_fliped_surface; 
 
    Uint32 rmask, gmask, bmask, amask;
 
    SDL_Color textColor = { 255, 255, 255 };
 
    texte_surface = TTF_RenderText_Solid(font,texte,textColor);
 
	width = texte_surface->w;
 
    height = texte_surface->h;
 
 
 
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
 
 
 
    rmask = 0xff000000;
 
    gmask = 0x00ff0000;
 
    bmask = 0x0000ff00;
 
    amask = 0x000000ff;
 
#else
 
 
 
    rmask = 0x000000ff;
 
    gmask = 0x0000ff00;
 
    bmask = 0x00ff0000;
 
    amask = 0xff000000;
 
#endif
    SDL_Surface * good_text;
 
 
 
    good_text =  SDL_CreateRGBSurface(SDL_SWSURFACE, texte_surface->w,texte_surface->h, 32,
 
                                  rmask,gmask,bmask,amask);
 
    SDL_BlitSurface(texte_surface,NULL,good_text,NULL);
 
 
 
 
 
 
 
    SDL_PixelFormat format = *(good_text->format);
 
    format.BitsPerPixel = 32;
 
    format.BytesPerPixel = 4;
 
    format.Rmask = rmask;
 
    format.Gmask = gmask;
 
    format.Bmask = bmask;
 
    format.Amask = amask;
 
 
 
    gl_surface = SDL_ConvertSurface(good_text,&format,SDL_SWSURFACE);
 
 
 
    gl_fliped_surface = flipSurface(gl_surface);
 
 
 
    glBindTexture(GL_TEXTURE_2D,textureTexte);
 
 
 
    glTexImage2D(GL_TEXTURE_2D, 0, 4, gl_fliped_surface->w,
 
                     gl_fliped_surface->h, 0, GL_RGBA,GL_UNSIGNED_BYTE,
 
                     gl_fliped_surface->pixels);
 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
 
 
 
 
 
    SDL_FreeSurface(good_text);
 
    SDL_FreeSurface(gl_surface);
 
    SDL_FreeSurface(gl_fliped_surface);
 
    SDL_FreeSurface(texte_surface);
 
}
Le code marche, mais si je met un espace dans le texte sa m'affiche segmentation fault :/ !
Merci de votre aide !