bonjour, je suis en train de programmer en c++ un programme qui charge des fichier BSP. et lors que je charge les texture j'ai une erreur de segmentation. je suis ubuntu 64bit j'utilise SFML pour le fenetrage et openGL.
voila la fonction qui charge les fichier BSP:
voila la fonction qui charge les texture( je les déja utiliser et elle marcher):
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 BSP::BSP(string name) { ifstream fichier(name.c_str(), ios::in | ios::binary); if(!fichier) { string temp="impossible d'ouvrir le fichier \""+name+"\"!"; throw runtime_error(temp); } BSPHeader header = {0}; fichier.read((char *)&header,sizeof(BSPHeader)); if(header.strID!="IBSP" &&header.version!=0x2e) { string temp="le fichier \""+name+"\" n'est pas dans un format supporter!"; throw runtime_error(temp); } BSPLump lumps[kMaxLumps] = {0}; fichier.read((char*)&lumps,sizeof(BSPLump)*kMaxLumps); nbrSommet=lumps[kVertices].length / sizeof(BSPSommet); sommets = new BSPSommet[nbrSommet]; nbrFace=lumps[kFaces].length / sizeof(BSPFace); faces=new BSPFace[nbrFace]; nbrTexture= lumps[kTextures].length / sizeof(BSPTexture); BSPTexture *pTextures = new BSPTexture [nbrTexture]; textures= new GLuint[nbrTexture]; fichier.seekg(lumps[kVertices].offset); for(uint i(0); i < nbrSommet; i++) { fichier.read((char*)&sommets[i],sizeof(BSPSommet)); float temp = sommets[i].Position.y; sommets[i].Position.y = sommets[i].Position.z; sommets[i].Position.z = -temp; sommets[i].TextureCoord.y *= -1; } fichier.seekg(lumps[kFaces].offset); for(uint i(0);i<nbrFace;i++) { fichier.read((char*)&faces[i],sizeof(BSPFace)); } fichier.seekg(lumps[kTextures].offset); string textureName; for(uint i(0);i<nbrTexture;i++) { fichier.read((char*)&pTextures[i],sizeof(BSPTexture)); textureName=pTextures[i].strName+(string)".jpg"; textures[i]=chargerTexture(textureName); } delete[] pTextures; }
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 GLuint chargerTexture(string name) { sf::Image image; GLuint texture=0; if(image.LoadFromFile(name)) { glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.GetWidth(), image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, image.GetPixelsPtr());//<--erreur selon le programme valgrind glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } return texture; }
Partager