bonjour, je voudrais faire un reflet à une scène mais je n'arrive pas à gérer la transparence. Voici le 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
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
 
void realize(GtkWidget *widget, gpointer data)
{
	donnees *d=(donnees *) data;
	GdkGLContext *glcontext=gtk_widget_get_gl_context(widget);
	GdkGLDrawable *gldrawable=gtk_widget_get_gl_drawable(widget);
	GLfloat light_position[] = {0.0, 50.0,-50.0, 1.0};
	GLfloat light_diffuse[] = {0.0, 1.0, 1.0, 1.0};
 
	if(!gdk_gl_drawable_gl_begin(gldrawable,glcontext))
		return;
 
	/* début openGL */
 
	glClearColor(0.0,0.0,0.0,0.0);
	glClearDepth (1.0);
 
	glViewport (0, 0, widget->allocation.width, widget->allocation.height);
 
	glClear(GL_COLOR_BUFFER_BIT |  GL_DEPTH_BUFFER_BIT);
 
	glLightfv (GL_LIGHT0, GL_POSITION, light_position);
	glLightfv (GL_LIGHT0, GL_DIFFUSE, light_diffuse);
	glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.1);
	glEnable (GL_LIGHTING);
	glEnable (GL_LIGHT0);
 
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
 
	glEnable (GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
 
	glEnable(GL_NORMALIZE);
	glEnable(GL_AUTO_NORMAL);
 
	glShadeModel(GL_SMOOTH);
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
 
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
	/* fin OpenGL */
	gdk_gl_drawable_gl_end(gldrawable);
}
 
void scene_base_GL(donnees *d,GLdouble sens,GLdouble translation, GLdouble scale)
{
	GLUquadricObj *quad;
 
	if (!sens)
		sens=1.0;
	else
		sens/=sens;
 
	/* pour gérer seulement la sph  (push et pop) */
	glPushMatrix();
	glColor4f(0.1,0.2,1.0,1.0);
	glTranslatef(0.0,translation,0.0);
	glRotatef(d->spin*d->spin,0.0, 0.0, 1.0);
	glScaled(sens*0.5,0.5,0.5);
	glScaled(scale,scale,scale);
	quad=gluNewQuadric(); 
	gluQuadricNormals(quad, GLU_SMOOTH);
	gluQuadricOrientation(quad, GLU_OUTSIDE); 
	gluSphere(quad,1.0,20,20);
	glPopMatrix();
	gluDeleteQuadric(quad);
 
	glPushMatrix(); 
	glTranslatef(0.0,translation,0.0);
	glRotatef(-d->spin,0.0, 1.0, 0.0);
	glScaled(sens*1.0,1.0,1.0);
	glScaled(scale,scale,scale);
	glColor4f(1.0,0.0,1.0,1.0);
	glRectf(-0.5,-0.5,0.5,0.5);
	glPopMatrix();
 
	glPushMatrix(); 
	glTranslatef(0.2,0.15+translation,0.0);
	glRotatef(d->spin,0.0, 0.0, 1.0);
	glScaled(sens*1.0,1.0,1.0);
	glScaled(scale,scale,scale);
	glColor4f(1.0,1.0,0.0,1.0);
	glRectf(-0.5,-0.5,0.5,0.5);
	glPopMatrix();
 
	glPushMatrix();
	glColor4f(1.0,1.0,1.0,1.0);
	glRotatef(50.0,1.0, 0.0, 0.0);
	glTranslatef(0.0,0.0,0.4);
	glRectf(-50.0,-50.0,50.0,50.0);
	glPopMatrix();
 
}
 
void scene_GL(donnees *d)
{
	glClear(GL_COLOR_BUFFER_BIT |  GL_DEPTH_BUFFER_BIT);
 
	scene_base_GL(d,1.0,0.0,0.5);
	scene_base_GL(d,-1.0,-1.1,0.5);
}
Le plan que je veux rendre transparent correspond au code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
	glPushMatrix();
	glColor4f(1.0,1.0,1.0,1.0);
	glRotatef(50.0,1.0, 0.0, 0.0);
	glTranslatef(0.0,0.0,0.4);
	glRectf(-50.0,-50.0,50.0,50.0);
	glPopMatrix();
PS : s'il éxiste une façon de faire des réflexion simplement, je suis preneur.