for int 1000 glBindFramebuffer GL_FRAMEBUFFER framebuffer depthFillPro

 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
for (int i = 0; i < 1000; ++i) {
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
depthFillProg->use();
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, current, 0);
glDrawBuffer (GL_COLOR_ATTACHMENT0);
//glReadBuffer (GL_COLOR_ATTACHMENT0); // mb slow?
CHECK_FRAMEBUFFER_ERROR;
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable (GL_CULL_FACE);
glDisable (GL_DEPTH_TEST); // ?
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE);
glMatrixMode (GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
// glTranslated(objects[i].x, objects[i].y, objects[i].z);
glTranslated(0, 0, 0);
glutSolidCube(1.0);
glPopMatrix();
glDisable (GL_BLEND);
glEnable (GL_CULL_FACE);
glEnable (GL_DEPTH_TEST);
unionResultProg->use();
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D, current);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_2D, result);
status = unionResultProg->setUniformVariable("Texture0", 0);
if (status != true) {
OutputDebugStr ((LPCTSTR)("RUNTIME: Texture0 not bind.\n"));
}
status = unionResultProg->setUniformVariable("Texture1", 1);
if (status != true) {
OutputDebugStr ((LPCTSTR)("RUNTIME: Texture1 not bind.\n"));
}
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, interim, 0);
glDrawBuffer (GL_COLOR_ATTACHMENT0);
// glReadBuffer (GL_COLOR_ATTACHMENT0); // mb slow?
CHECK_FRAMEBUFFER_ERROR;
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
begin2D (width, height);
glPolygonMode (GL_FRONT, GL_FILL);
glBegin (GL_QUADS);
glTexCoord2d (0.0, 0.0);
glVertex2f (0.0, 0.0);
glTexCoord2d (0.0, 1.0);
glVertex2f (0.0, static_cast<GLfloat>(height));
glTexCoord2d (1.0, 1.0);
glVertex2f (static_cast<GLfloat>(width), static_cast<GLfloat>(height));
glTexCoord2d (1.0, 0.0);
glVertex2f (static_cast<GLfloat>(width), 0.0);
glEnd();
end2D();
swap (interim, result);
}