Post by xteraco on Feb 25, 2005 14:49:02 GMT -5
here's some fire i did based on tom's flame demo.. .i think it runs a little faster.. heh
const width = 64
const height = 64
dim a1(height-1)(width-1)
dim a2(height-1)(width-1)
dim x, y, c1, c2, nohs, i, j, tex
glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
gluOrtho2D (0, 2, 0, 1)
tex = glGenTexture ()
glBindTexture (GL_TEXTURE_2D, tex)
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
FOR x = 0 TO width - 1
C1 = (RND() % 25) + 50
C2 = (RND() % 25) + 50
a1(height-2)(x) = c1
a1(height-1)(x) = c2
next
while true
nohs = INT(RND() % 1) + 8
FOR i = 1 TO nohs
x = INT(RND() % (width - 3)) + 1
a1(height-3)(x-1) = 255
a1(height-3)(x ) = 255
a1(height-3)(x+1) = 255
a1(height-2)(x-1) = 255
a1(height-2)(x ) = 255
a1(height-2)(x+1) = 255
a1(height-1)(x-1) = 255
a1(height-1)(x ) = 255
a1(height-1)(x+1) = 255
NEXT
for x = 1 to width - 2
for y = 1 to height - 2
a2 (y-1)(x) = (a1(y)(x-1) + a1(y)(x+1) + a1(y-1)(x) + a1(y+1)(x)) / 4 - 3
next
NEXT
FOR j = 0 TO height - 1
FOR i = 0 TO width - 1
if a2(j)(i) < 1 then a2(j)(i) = 1 endif
a1(j)(i) = a2(j)(i)
NEXT
NEXT
glTexImage2D (GL_TEXTURE_2D, 0, 1, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, a1)
glClearColor (0, 0,0, 0)
glDisable (GL_DEPTH_TEST)
glEnable (GL_TEXTURE_2D)
glClear (GL_COLOR_BUFFER_BIT)
glColor3f (0, 130, .3)
glBegin (GL_QUADS)
glTexCoord2f (0, 1): glVertex2f (0, 0)
glTexCoord2f (1, 1): glVertex2f (2, 0)
glTexCoord2f (1, 0): glVertex2f (2, .5)
glTexCoord2f (0, 0): glVertex2f (0, .5)
glEnd ()
SwapBuffers ()
wend