Voila j'ai implémenté le picking OpenGl et ça marche tant que je n'effectu pas de rotation de ma caméra.??

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
	x=e->x();
				y=e->y();
				GLuint selectBuffer[BUFSIZE];
				GLint hits;
				GLint viewport[4];
 
			//************ PICKING
				glGetIntegerv(GL_VIEWPORT,viewport);
 
				glSelectBuffer(BUFSIZE,selectBuffer);
				(void) glRenderMode(GL_SELECT);
 
				glInitNames();
				glPushName(0);
 
				//récupération de la matrice de projection active
				GLfloat v_Matrix_Projection[16];
				glGetFloatv(GL_PROJECTION_MATRIX,v_Matrix_Projection);
 
				glMatrixMode(GL_PROJECTION);
 
				glPushMatrix();
 
				glLoadIdentity();
 
				// crée une région de 5x5 pixels proche de l'emplacement du curseur
				gluPickMatrix((GLfloat) x, (GLfloat)(viewport[3]-y),20.f,20.f,viewport);
				glMultMatrixf(v_Matrix_Projection);
 
				Draw_for_select();
			//	ground->Affiche_Select();
 
				glFlush();
				glPopMatrix();
 
				glMatrixMode(GL_MODELVIEW);
				glLoadIdentity();
 
				hits=glRenderMode(GL_RENDER);
				processHits(hits,selectBuffer);
			//Fin du Picking, _picking contien l'indice de l'element selectionné
 
 
 
 
void Camera_Persp::SetProjection(int w,int h)
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0,(GLfloat)w/(GLfloat)h,0.01,1000.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

[Balises CODE rajoutées par Loulou24, merci d'y penser à l'avenir]