Triangles on fire:
The secret is to create a very very small texture
Sub textureA(sys n)
===================
static long v[16]
v<= 0, 0, 0, 0, 0, -1, 0x88ffffff, 0,
0, 0x88ffffff, -1, 0, 0, 0, 0, 0
MakeTexture @v, 4, 4, n
End Sub
Then deploy the texture in blended quad particles
includepath "$\inc\"
$ FileName "t.exe"
'include "RTL32.inc"
'include "RTL64.inc"
title="Smoke"
include "OpenglSceneFrame.inc"
sys texn[16]
type tParticle
===============
float x,y,z
float size,speed,angle
float fade
float r,g,b
end type
'RANDOMISER
===========
'
sys seed
'
Function Rnd() as float
Static As float f, d=1/0x7fffffff
mov eax,seed
inc eax
rol eax,7
imul eax,eax,13
mov seed,eax
push eax
fild dword [esp]
add esp,4
fmul dword d
fstp dword f
return f
End Function
'ABS RANDOMISER
===============
'
Function arnd() as float
return Abs(Rnd)
End Function
Sub textureA(sys n)
===================
static long v[16]
v<= 0, 0, 0, 0, 0, -1, 0x88ffffff, 0,
0, 0x88ffffff, -1, 0, 0, 0, 0, 0
MakeTexture @v, 4, 4, n
End Sub
function QuadTex(float x,y,z)
=============================
glBegin GL_QUADS
glTexCoord2f 0.0,0.0 : glVertex3f -x,-y, z
glTexCoord2f 1.0,0.0 : glVertex3f x,-y, z
glTexCoord2f 1.0,1.0 : glVertex3f x, y, z
glTexCoord2f 0.0,1.0 : glVertex3f -x, y, z
glend
end function
Function DrawParticle (tparticle*p)
===================================
glPushMatrix
glTranslatef p.x, p.y, p.z
glColor4f 1,.5,.0,.7-p.y/2 ' The particle will fade out
p.angle+=Rnd()
glscalef 1, p.angle*.0004+1, 1 'itr
glRotatef p.angle, 0, 0, 1
QuadTex p.size,p.size,0
glPopMatrix
End Function
Function ReNewParticle(tparticle*p,sys i,e)
===========================================
p(i).x = Rnd()*.5
p(i).y = 0
p(i).z = -e*.1 / i 'z layers
p(i).size = .025+aRnd()*0.05
p(i).Speed= .5+aRnd()
p(i).Angle= aRnd()*360
End Function
Function RenderParticles(tparticle*p,sys e)
===========================================
sys i
for i = 1 to e
if p(i).y > 1 or p(i).speed=0
ReNewParticle(p,i,e)
else
p(i).size += 0.1*.0167
p(i).x += 0.1*.0167
p(i).y = p(i).y + p(i).Speed *.00167 'assume framerate 60
drawParticle p(i)
end if
Next
End Function
sub Triangle
============
glBegin GL_TRIANGLES
glColor4f 1.0, 0.0, 0.0, 0.99 : glVertex3f 0.0, 1.0, 0.0
glColor4f 0.0, 1.0, 0.0, 0.99 : glVertex3f -1.0, -1.0, 0.0
glColor4f 0.0, 0.0, 1.0, 0.99 : glVertex3f 1.0, -1.0, 0.0
glEnd
end sub
sub Quads
=========
glBegin GL_QUADS
glColor4f 1.0, 0.0, 0.0, 0.99 : glVertex3f -1.0, -1.0, 0.0
glColor4f 0.0, 1.0, 0.0, 0.99 : glVertex3f 1.0, -1.0, 0.0
glColor4f 0.0, 0.0, 1.0, 0.99 : glVertex3f 1.0, 1.0, 0.0
glColor4f 0.5, 0.5, 0.5, 0.99 : glVertex3f -1.0, 1.0, 0.0
glEnd
end sub
sub initialize(sys hWnd)
'=======================
seed=0x12345678
SetTimer hWnd,1,10,NULL
glGenTextures 1, texn
textureA texn[1]
end sub
tparticle p[50]
sys count
sub scene(sys hWnd)
'==================
'
static single s1,s2,s3,s4,ang1,angi1=1,ra,ri
'
glLoadIdentity
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glEnable GL_DEPTH_TEST
glClearColor 0.5, 0.5, 0.7, 0
'glClearColor 0.0, 0.0, 0.0, 0
'
float fcolor[4]={.5, .5, .7, .99}
glfogi GL_FOG_MODE,GL_EXP
glfogf GL_FOG_DENSITY,0.1
glfogfv GL_FOG_COLOR, fcolor
glfogf GL_FOG_INDEX, 0
glfogf GL_FOG_START, -1.0
glfogf GL_FOG_END, -100.0
glEnable GL_FOG
'
glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
glEnable GL_BLEND
'
glPushMatrix
gltranslatef 6.0, 0.0, -16.0
glrotatef ang1,0,1,0
Triangle
glPopMatrix
'
glPushMatrix
gltranslatef 2.0, 0.0, -8.0
glrotatef ang1,0,1,0
Triangle
glPopMatrix
'
glPushMatrix
gltranslatef 0.0, 0.0, -4.0
glrotatef ang1,0,1,0
Triangle
glPopMatrix
'
glEnable GL_TEXTURE_2D
glBindTexture GL_TEXTURE_2D,texn[1]
glPushMatrix
gltranslatef 0.0, 0.0, -2.0
RenderParticles p,40
glPopMatrix
glDisable GL_TEXTURE_2D
'
ang1+=angi1
if ang1>360 then ang1-=360
'
end sub
sub Release(sys hwnd)
'====================
killTimer hwnd, 1
glDeleteTextures 1, texn
end sub
X