Uh.. sortof works.
Not exactly interested in fixing everything.
Not exactly interested in fixing everything.
Const XRES=640 Const YRES=480 Const RRES= 32 bglCreateContext(XRES,YRES,RRES,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER) HideMouse Global texname:Int Global ParticleList:TList = New TList ' ' Create the Fireworks as a type. ' Type Fireworks Field x#,y#,z# Field vy# Field xd#,yd#,zd# Field r#,g#,b# Field alpha# End Type Global ParticleCount InitOpenGL() glDisable(GL_CULL_FACE) Print glGetError() While Not KeyHit(KEY_ESCAPE) If MouseHit(1) Then CreateFireworks() RenderOpenGL() bglSwapBuffers() Wend Function RenderOpenGL() Local Update:Fireworks glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ' Clear The Screen And The Depth Buffer glLoadIdentity () glTranslatef(0,0,-20) For Update = EachIn ParticleList glPushMatrix() glColor4f( Update.r, Update.g, Update.b, Update.Alpha) glTranslatef (Update.x,Update.y,Update.z) glBegin (GL_QUADS) 'Draw using Quads. glVertex2f(-1.0, 1.0) 'Top Left. glVertex2f( 1.0, 1.0) 'Top Right. glVertex2f( 1.0,- 1.0) 'Bottom Right. glVertex2f(-1.0,- 1.0) 'Bottom Left. glEnd() 'Done Drawing The Quad. ' Update.Alpha = Update.Alpha - .001 If Update.Alpha <0 ParticleList.Remove Update End If ' ' update.x = update.x + update.xd * 10 ' update.y = update.y + update.yd * 10 ' update.z = update.z + update.zd * 10 ' ' update.y = update.y + update.vy ' update.vy = update.vy + 0.02 glPopMatrix() Next End Function Function CreateFireworks() ' ' Here we go For starters. ' Local x#=Rand( -5, 5 ) Local y#=Rand( -5, 5 ) Local z#=-20 ' ' Colour scheme For this New batch of fireworks, ' Local r#=Rand( 2 ) Local g#=Rand( 2 ) Local b#=Rand( 2 ) Local create:Fireworks For Local amount=1 To 100 Local speed# = .00001 Local ang1# = Rand( 360 ) Local ang2# = Rand( 360 ) create = New Fireworks create.x = Rnd(-5,5) create.y = Rnd(-5,5) create.z = Rnd(-5,5) ' create.xd = Cos( ang1# ) * Cos( ang2# ) * speed# ' create.yd = Cos( ang1# ) * Sin( ang2# ) * speed# ' create.zd = Sin( ang1# ) * speed# create.r = Rnd(1) create.g = Rnd(1) create.b = Rnd(1) create.alpha = Rnd(1,1.5) ParticleList.Addlast Create Next End Function Function InitOpenGL() LoadGLTextures () glEnable (GL_TEXTURE_2D) ' Enable Texture Mapping glShadeModel (GL_SMOOTH) ' Enable Smooth Shading glClearColor (0.0, 0.0, 0.0, 0.0) ' Black Background glClearDepth (1.0) ' Depth Buffer Setup glDisable (GL_DEPTH_TEST) ' Disable Depth Testing glEnable (GL_BLEND) ' Enable Blending glBlendFunc (GL_SRC_ALPHA,GL_ONE) ' Type Of Blending To Perform glDepthFunc (GL_LEQUAL) ' The Type Of Depth Testing To Do glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) ' Really Nice Perspective Calculations glViewport (0,0,XRES,YRES) ' Set viewport glMatrixMode (GL_PROJECTION) ' Select The Projection Matrix glLoadIdentity () ' Reset The Projection Matrix gluPerspective (45.0,Float(XRES)/Float(YRES),0.1,100.0) ' Calculate Aspect Ratio glMatrixMode (GL_MODELVIEW) ' Select The Modelview Matrix glLoadIdentity () End Function Function LoadGLTextures() Local TextureImage:TPixmap TextureImage:TPixmap=LoadPixmap("media/Spark.png") ' Load Particle Texture If TextureImage <> Null Then Print "Failed to load media/spark.png" Return EndIf glGenTextures (1, Varptr Texname) ' Create One Texture glBindTexture (GL_TEXTURE_2D, Texname) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) glTexImage2D (GL_TEXTURE_2D, 0, 3, TextureImage.width, TextureImage.height,.. 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.pixels) End Function