Here's an attempted fader, as you'll witness the colours dont really fade very well.
And I've not had much luck with doing a blurring effect based on this approach. Any ideas?
Humble Thankyous,
THUMBZ
And I've not had much luck with doing a blurring effect based on this approach. Any ideas?
' ' OPENGL 2D Drawing Test Example ' Const XRES=640 Const YRES=480 bglCreateContext(XRES,YRES,32,0,BGL_BACKBUFFER|BGL_DEPTHBUFFER|BGL_FULLSCREEN) ' ' setup OpenGL for 2D Drawing ' glMatrixMode (GL_PROJECTION) glLoadIdentity () gluOrtho2D (0, XRES, YRES, 0) glClearColor (0.0, 0.0, 0.0, 0.0) glMatrixMode (GL_MODELVIEW) glLoadIdentity () glDisable (GL_DEPTH_TEST) ' 'Image Properties ' Global Locked:TPixmap Global Image =LoadImage("../media/imagery.png", DynamicImage ) Global IW =ImageWidth ( Image ) Global IH =ImageHeight( Image ) Global ImageData# [ IW,IH,4] Global RedData# [ IW, IH ] Global GrnData# [ IW, IH ] Global BluData# [ IW, IH ] create2DImage() ' ' Clear the images. ' Image =Null Locked =Null ' ' the main loop ' While Not KeyHit(KEY_ESCAPE) Draw2D() UpdateColours() bglSwapBuffers FlushMem Wend Function Draw2D() ' ' Start point drawing. ' glBegin (GL_Points) For Local y= 0 To IH-1 For Local x=0 To IW-1 glcolor3f ( RedData[x,y] , GrnData[x,y], BluData[x,y] ) glVertex2f( x, y ) Next Next glEnd() End Function ' ' Read in image and store pixel colourings. ' Function Create2DImage() Locked=LockImage(Image) For Local y=0 To IH-1 For Local x=0 To IW-1 Local RGB=ReadPixel(Locked,x,y) ' ' convert to 0-255 colours ' Local Red=(RGB Shr 16) & 255 Local Grn=(RGB Shr 8) & 255 Local Blu=(RGB Shr 0) & 255 ' ' convert to OpenGL values ' Local Red2#= (1.0 / 255.0) * Red Local Grn2#= (1.0 / 255.0) * Grn Local Blu2#= (1.0 / 255.0) * Blu ' ' store the results. ' ImageData[x,y,1]=Red2 ImageData[x,y,2]=Grn2 ImageData[x,y,3]=Blu2 RedData[x,y]=Red2 GrnData[x,y]=Grn2 BluData[x,y]=Blu2 Next Next UnlockImage (Image) End Function ' ' Perform colour fade. ' Function UpdateColours() For y=0 To IH-1 For x=0 To IW-1 ' ' Decrease the R/G/B Values. ' RedData[x,y]=RedData[x,y]-.01 GrnData[x,y]=GrnData[x,y]-.01 BluData[x,y]=BluData[x,y]-.01 ' ' If Lower then 0.0 then reset the to starting value. ' If RedData[x,y]<0.0 Then RedData[x,y]=ImageData[x,y,1] If GrnData[x,y]<0.0 Then GrnData[x,y]=ImageData[x,y,2] If BluData[x,y]<0.0 Then BluData[x,y]=ImageData[x,y,3] Next Next End Function
Humble Thankyous,
THUMBZ