Salut à tous,
J'ai un problème lors de l'utilisation d'un framebuffer, la texture générée par le framebuffer est vide, ou noire. J'ai pourtant suivit à la lettre plusieurs tutoriel, et observé les codes de la plus parte des samples qu'on trouve sur le net, qui eux fonctionnent. Quand je ne bind pas le framebuffer pour voir ce que c'est censé faire, mon rendu fonctionne, mais dès que je le met dans le framebuffer, ma texture apparait noire. Je précise que j'ai bien les shader et les framebuffer disponible.

Voici mon 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
 
// Initialisation
int width = 800;
int height = 600;
 
GLuint fbo;
GLuint tex;
GLuint dbo;
 
 
// DepthBuffer
glGenRenderbuffersEXT(1, &dbo);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dbo);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
 
// Texture
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
 
// FrameBuffer
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
 
// Binds
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);  
 
if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
       printf("FrameBuffer cree avec succes");
 
 
// Dans la boucle d'affichage :
 
// Réinitialisation des matrices pour le frambuffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
 
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(Position.x, Position.y, Position.z, Target.x, Target.y, Target.z, 0, 1, 0 );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90, 800.0/600.0, 0.1, 1000);
 
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
 
 
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0,0,width, height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
RadialPrg.Use(); // Juste un simple program GLSL
       // Ci-dessous, un simple rendu
       glColor3f(255, 255 ,255);
       Sky.DrawSun(Camera);
       glColor3f(0,0,0);
       Terrain.Draw();
       Scene.Draw();
srl::Program::DUse();
 
glPopAttrib();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 
 
// Un autre rendu qui utilise la texture du framebuffer
// Réinitialisation des matrices pour le rendu
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(Position.x, Position.y, Position.z, Target.x, Target.y, Target.z, 0, 1, 0 );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90, 800.0/600.0, 0.1, 1000);
 
       glBindTexture(GL_TEXTURE_2D, tex);
       for (int i = 0; i < 4; i++) {
          glBegin(GL_QUADS);
          glTexCoord2d(0,1);
          glVertex3d(1,1,1);
          glTexCoord2d(0,0);
          glVertex3d(1,1,-1);
          glTexCoord2d(1,0);
          glVertex3d(-1,1,-1);
          glTexCoord2d(1,1);
          glVertex3d(-1,1,1);
          glEnd();
          glRotated(90,0,0,1);
       }
Merci d'avance,
A toute