for int glBindFramebuffer GL_FRAMEBUFFER fbo depthFillProg- use glFram

 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
for (int i = 0; i < 5; ++i) {
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
depthFillProg->use();
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, current, 0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
//glReadBuffer(GL_COLOR_ATTACHMENT0);
CHECK_FRAMEBUFFER_ERROR;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glPushMatrix();
// 0.5020 0.6235 0.0000 0.0000 = 0.5
// 0.5608 0.6863 0.0000 0.0000 = 1.0
// result: 0.4392 0.6235 0.0 0.0 ???
// real: 0.5020 0.6863 0.0 0.0
glTranslated (0.0, 0.0, 0.5);
// draw call 1
glutSolidCube(1);
glPopMatrix();
unionResultProg->use();
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, current);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_2D, result);
status = unionResultProg->setUniformVariable("Texture0", 0);
status = unionResultProg->setUniformVariable("Texture1", 1);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, interim, 0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
//glReadBuffer(GL_COLOR_ATTACHMENT0);
CHECK_FRAMEBUFFER_ERROR;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
begin2D(1024, 768);
// draw call 2
glPolygonMode(GL_FRONT, GL_FILL);
glBegin (GL_QUADS);
glTexCoord2d(0, 0); glVertex2f(0.0, 0.0);
glTexCoord2d(0, 1); glVertex2f(0.0, 768.0);
glTexCoord2d(1, 1); glVertex2f(1024.0, 768.0);
glTexCoord2d(1, 0); glVertex2f(1024.0, 0.0);
glEnd();
end2D();
swap (interim, result);
}