35 |
"3D filleting" |
"3D filleting" |
36 |
def __init__(self): |
def __init__(self): |
37 |
self.depthTexture = GL.createTexture() |
self.depthTexture = GL.createTexture() |
38 |
|
self.tmpTexture = GL.createTexture() |
39 |
self.direct = 0 |
self.direct = 0 |
40 |
rect = 1 |
rect = 1 |
41 |
targ = "TEXTURE_RECTANGLE_NV" |
targ = "TEXTURE_RECTANGLE_NV" |
46 |
"INT") |
"INT") |
47 |
else: |
else: |
48 |
self.depthTexture.loadNull2D("TEXTURE_RECTANGLE_NV", 0, "RGBA8", |
self.depthTexture.loadNull2D("TEXTURE_RECTANGLE_NV", 0, "RGBA8", |
49 |
1024, 768, 0, "BGRA", |
1024, 768, 0, "BGRA", |
50 |
"UNSIGNED_INT_8_8_8_8") |
"UNSIGNED_INT_8_8_8_8") |
51 |
|
|
52 |
|
self.tmpTexture.loadNull2D("TEXTURE_RECTANGLE_NV", 0, "RGB8", |
53 |
|
1024, 768, 0, "RGB", |
54 |
|
"INT") |
55 |
if not rect: |
if not rect: |
56 |
self.depthTexture.setTexParameter(targ, |
self.depthTexture.setTexParameter(targ, |
57 |
"TEXTURE_MAX_LEVEL", 0) |
"TEXTURE_MAX_LEVEL", 0) |
139 |
vs.put(getDListNocoords(""" |
vs.put(getDListNocoords(""" |
140 |
BindProgram VERTEX_PROGRAM_ARB 0 |
BindProgram VERTEX_PROGRAM_ARB 0 |
141 |
Disable VERTEX_PROGRAM_ARB |
Disable VERTEX_PROGRAM_ARB |
142 |
BindTexture TEXTURE_RECTANGLE_NV %s |
""")) |
|
Enable TEXTURE_RECTANGLE_NV |
|
|
""" % self.depthTexture.getTexId())) |
|
143 |
|
|
144 |
if self.direct: |
# Now, draw the edges |
145 |
|
|
146 |
# Now, draw the edges |
if self.direct: |
147 |
|
vs.put(getDListNocoords(""" |
148 |
|
BindTexture TEXTURE_RECTANGLE_NV %s |
149 |
|
""" % self.depthTexture.getTexId())) |
150 |
vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV", |
vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV", |
151 |
0, 0, 0, 1024, 768), 0) |
0, 0, 0, 1024, 768), 0) |
152 |
|
|
153 |
elif 1: |
elif 1: |
154 |
|
# Copy the color buffer to a texture |
155 |
|
vs.put(getDListNocoords(""" |
156 |
|
BindTexture TEXTURE_RECTANGLE_NV %s |
157 |
|
""" % self.tmpTexture.getTexId())) |
158 |
|
vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV", |
159 |
|
0, 0, 0, 1024, 768), 0) |
160 |
|
|
161 |
|
# Copy stencil&depth to color |
162 |
vs.put(getDListNocoords(""" |
vs.put(getDListNocoords(""" |
163 |
PushAttrib ENABLE_BIT |
PushAttrib ENABLE_BIT |
164 |
Disable ALPHA_TEST |
Disable ALPHA_TEST |
171 |
0, |
0, |
172 |
csdest, |
csdest, |
173 |
) |
) |
174 |
|
|
175 |
|
# Read the depth to a texture |
176 |
|
vs.put(getDListNocoords(""" |
177 |
|
BindTexture TEXTURE_RECTANGLE_NV %s |
178 |
|
""" % self.depthTexture.getTexId())) |
179 |
vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV", |
vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV", |
180 |
0, 0, 0, 1024, 768), 0) |
0, 0, 0, 1024, 768), 0) |
181 |
|
|
182 |
|
# Copy the color back from the backup texture |
183 |
|
vs.put(getDListNocoords(""" |
184 |
|
BindTexture TEXTURE_RECTANGLE_NV %s |
185 |
|
Enable TEXTURE_RECTANGLE_NV |
186 |
|
""" % self.tmpTexture.getTexId())) |
187 |
|
vs.put(getDList(""" |
188 |
|
Color 1 1 1 |
189 |
|
Begin QUAD_STRIP |
190 |
|
TexCoord 0 0 |
191 |
|
Vertex 0 %(h)s |
192 |
|
|
193 |
|
TexCoord 0 %(h)s |
194 |
|
Vertex 0 0 |
195 |
|
|
196 |
|
TexCoord %(w)s 0 |
197 |
|
Vertex %(w)s %(h)s |
198 |
|
|
199 |
|
TexCoord %(w)s %(h)s |
200 |
|
Vertex %(w)s 0 |
201 |
|
End |
202 |
|
""" % { "w" : 1024, "h" : 768 }), 0) |
203 |
|
|
204 |
vs.put(getDListNocoords(""" |
vs.put(getDListNocoords(""" |
205 |
PopAttrib |
PopAttrib |
206 |
""")) |
""")) |
207 |
else: |
else: |
208 |
|
|
217 |
BindProgram FRAGMENT_PROGRAM_NV %s |
BindProgram FRAGMENT_PROGRAM_NV %s |
218 |
Enable FRAGMENT_PROGRAM_NV |
Enable FRAGMENT_PROGRAM_NV |
219 |
Enable BLEND |
Enable BLEND |
220 |
""" % light3d.edgefp.getProgId())) |
BindTexture TEXTURE_RECTANGLE_NV %s |
221 |
|
""" % (light3d.edgefp.getProgId(), |
222 |
|
self.depthTexture.getTexId()))) |
223 |
|
|
224 |
vs.put(quad(), vs.orthoCS(0, "A", -100, 0, 0, 1024,768)) |
vs.put(quad(), vs.orthoCS(0, "A", -100, 0, 0, 1024,768)) |
225 |
|
|