Post by lal7777 on May 17, 2011 18:02:55 GMT -5
In the scene posted below you'll see 2 pyramids both of which are rotating around a center point of (0,0,-10). One pyramid is slightly darker than the other. That triangle is the center one.
Even though that scene sounds like it has no issues, it has 1 very large issue.
The pyramid in the middle is supposed to be transparent, so when the other pyramid rotates around it YOU CAN STILL SEE IT. However that doesn't happen. Instead you see the transparent pyramid without seeing anything through it.
This poses many problems, especially when some things need to be see-through.(colored glass, colored liquids, Materials in .obj loaders,etc.)
Anyway here's the code below...
I hope someone can tell me what i'm missing.
please post.
Even though that scene sounds like it has no issues, it has 1 very large issue.
The pyramid in the middle is supposed to be transparent, so when the other pyramid rotates around it YOU CAN STILL SEE IT. However that doesn't happen. Instead you see the transparent pyramid without seeing anything through it.
This poses many problems, especially when some things need to be see-through.(colored glass, colored liquids, Materials in .obj loaders,etc.)
Anyway here's the code below...
I hope someone can tell me what i'm missing.
please post.
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glDepthMask(GL_true)'FALSE) 'maybe used to determine which quad is closest to you? keeps quad order for rendering? (doesn't render quads further away before the ones closest to you.)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_GREATER, 0.0)
dim d as double
dim a
while 1
glclear(gl_color_buffer_bit or gl_depth_Buffer_bit)
glloadidentity()
gltranslatef(0,0,-10)
glpushmatrix()
glrotatef(d,0,1,0)
gosub pyramid
glpopmatrix()
glrotatef(d,0,1,0)
gltranslatef(0,0,-3)
a= 1
gosub pyramid
a=0
gltranslatef(0,0,-.2)
'glBegin(GL_TRIANGLES) ' Drawing using triangles
glColor4f(1.0,0.0,0.0,.3) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (front)
glColor4f(0.0,1.0,0.0,.3) ' Green
glVertex3f(-1.0,-1.0, 2.0) ' Left of triangle (front)
glColor4f(0.0,0.0,1.0,.3) ' Blue
glVertex3f( 1.0,-1.0, 2.0)
glend()
swapbuffers()
d=d+4
waittimer(1000/60)'6
' gosub pyramid
wend
end
pyramid:
glDisable (GL_TEXTURE_2D)
glBegin(GL_TRIANGLES) ' Drawing using triangles
if a = 1 then
glColor3f(1.0,0.0,0.0) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (front)
glColor3f(0.0,1.0,0.0) ' Green
glVertex3f(-1.0,-1.0, 1.0) ' Left of triangle (front)
glColor3f(0.0,0.0,1.0) ' Blue
glVertex3f( 1.0,-1.0, 1.0) ' Right of triangle (front)
glColor3f(1.0,0.0,0.0) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (right)
glColor3f(0.0,0.0,1.0) ' Blue
glVertex3f( 1.0,-1.0, 1.0) ' Left of triangle (right)
glColor3f(0.0,1.0,0.0) ' Green
glVertex3f( 1.0,-1.0, -1.0) ' Right of triangle (right)
glColor3f(1.0,0.0,0.0) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (back)
glColor3f(0.0,1.0,0.0) ' Green
glVertex3f( 1.0,-1.0, -1.0) ' Left of triangle (back)
glColor3f(0.0,0.0,1.0) ' Blue
glVertex3f(-1.0,-1.0, -1.0) ' Right of triangle (back)
glColor3f(1.0,0.0,0.0) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (left)
glColor3f(0.0,0.0,1.0) ' Blue
glVertex3f(-1.0,-1.0,-1.0) ' Left of triangle (left)
glColor3f(0.0,1.0,0.0) ' Green
glVertex3f(-1.0,-1.0, 1.0) ' Right of triangle (left)
else
glColor4f(1.0,0.0,0.0,.3) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (front)
glcolor4f(0.0,1.0,0.0,.3) ' Green
glVertex3f(-1.0,-1.0, 1.0) ' Left of triangle (front)
glcolor4f(0.0,0.0,1.0,.3) ' Blue
glVertex3f( 1.0,-1.0, 1.0) ' Right of triangle (front)
glcolor4f(1.0,0.0,0.0,.3) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (right)
glcolor4f(0.0,0.0,1.0,.3) ' Blue
glVertex3f( 1.0,-1.0, 1.0) ' Left of triangle (right)
glcolor4f(0.0,1.0,0.0,.3) ' Green
glVertex3f( 1.0,-1.0, -1.0) ' Right of triangle (right)
glcolor4f(1.0,0.0,0.0,.3) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (back)
glcolor4f(0.0,1.0,0.0,.3) ' Green
glVertex3f( 1.0,-1.0, -1.0) ' Left of triangle (back)
glcolor4f(0.0,0.0,1.0,.3) ' Blue
glVertex3f(-1.0,-1.0, -1.0) ' Right of triangle (back)
glcolor4f(1.0,0.0,0.0,.3) ' Red
glVertex3f( 0.0, 1.0, 0.0) ' Top of triangle (left)
glcolor4f(0.0,0.0,1.0,.3) ' Blue
glVertex3f(-1.0,-1.0,-1.0) ' Left of triangle (left)
glcolor4f(0.0,1.0,0.0,.3) ' Green
glVertex3f(-1.0,-1.0, 1.0) ' Right of triangle (left
endif
glEnd() ' Finished Drawing The Triangle
return