Post by GuppyB on May 27, 2005 15:56:58 GMT -5
okay, so it's Friday before a Holiday weekend (here in the states) and I am trying to avoid doing any real work so I threw together this demo.
Simulates a Kaleidoscope, pretty simple really.
Enjoy
...G
Simulates a Kaleidoscope, pretty simple really.
Enjoy
...G
dim texture, tx#(3), ty#(3), changex#(3), changey#(3), i
texture = LoadMipmapTexture ("Data/tim.bmp")
if texture = 0 then print "Failed to load texture": end: endif
glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
glOrtho (0, 1024, 0, 768, -1, 1)
glMatrixMode (GL_MODELVIEW)
glDisable (GL_DEPTH_TEST)
glClear (GL_COLOR_BUFFER_BIT)
glDrawBuffer(gl_back)
glEnable (GL_TEXTURE_2D)
tx#(0) = 0.0: ty#(0) = 0.0 : changex#(0) = 0.01 : changey#(0) = 0.01
tx#(1) = 1.0: ty#(1) = 0.0 : changex#(1) = -0.025 : changey#(1) = 0.01
tx#(2) = 0.0: ty#(2) = 1.0 : changex#(2) = 0.02 : changey#(2) = -0.005
while true
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glBindTexture(GL_TEXTURE_2D, texture)
glBegin(GL_TRIANGLE_FAN)
glTexCoord2f(tx#(0), ty#(0)): glVertex2f(512,384)
glTexCoord2f(tx#(1), ty#(1)): glVertex2f(0.0,384)
glTexCoord2f(tx#(2), ty#(2)): glVertex2f(0.0,0.0)
glTexCoord2f(tx#(1), ty#(1)): glVertex2f(512,0.0)
glTexCoord2f(tx#(2), ty#(2)): glVertex2f(1024,0.0)
glTexCoord2f(tx#(1), ty#(1)): glVertex2f(1024,384)
glTexCoord2f(tx#(2), ty#(2)): glVertex2f(1024,768)
glTexCoord2f(tx#(1), ty#(1)): glVertex2f(512,768)
glTexCoord2f(tx#(2), ty#(2)): glVertex2f(0.0,768)
glTexCoord2f(tx#(1), ty#(1)): glVertex2f(0.0,384)
glEnd()
for i = 0 to 2
tx#(i) = tx#(i) + changex#(i)
if tx#(i) > 1.0 or tx#(i) < 0.0 then changex#(i) = changex#(i) * -1.0 : endif
ty#(i) = ty#(i) + changey#(i)
if ty#(i) > 1.0 or ty#(i) < 0.0 then changey#(i) = changey#(i) * -1.0 : endif
next
SwapBuffers()
wend