I have no idea where to start when it comes to drawing and plotting in 2D with OpenGL. I can open and setup a graphics window, as per the numerous excellent tutorials and examples on OpenGL with 3D stuff.
I'd like to know how to being and do this, as I have many things I'd like to try and do (mainly special effects) and see if they are any faster then using WritePixel and Pixel Maps. As I was under the impression that with BMAX everything was going to be much much quicker then previous flavours.
If you could help get me started with this, then that would be magic. One of the pitfulls I am gonig to get really perplexed over is converting Alpha. Red, Green and Blue colours into converting with open GL ones 0.0 - 1.0.
I take it I'd need to have an array of somekind to store image infromation, etc.
This is how Im currently doing things with WPF. And would like very much to do with OpenGL, to see if it is quicker. It's the main reason I bought BMAX. As im finding MAX2D very slow at doing effects.
Hugest of thanks,
THUMBZ
I'd like to know how to being and do this, as I have many things I'd like to try and do (mainly special effects) and see if they are any faster then using WritePixel and Pixel Maps. As I was under the impression that with BMAX everything was going to be much much quicker then previous flavours.
If you could help get me started with this, then that would be magic. One of the pitfulls I am gonig to get really perplexed over is converting Alpha. Red, Green and Blue colours into converting with open GL ones 0.0 - 1.0.
I take it I'd need to have an array of somekind to store image infromation, etc.
This is how Im currently doing things with WPF. And would like very much to do with OpenGL, to see if it is quicker. It's the main reason I bought BMAX. As im finding MAX2D very slow at doing effects.
' Write Pixel and LockImage drawing. ' bu Thumbz 2005 ' for this example greyscale filtered. Strict ' Screen setup. Const XRES=640 Const YRES=480 Graphics XRES,YRES HideMouse Local ImageFile$="media/insertimagenamehere.png" ' any size image you like upto the screen res. Global Image=LoadImage(ImageFile$,DynamicImage) ' the main image to be used for manipulating. Global IW=ImageWidth (Image) Global IH=ImageHeight(Image) Global Blank=CreateImage(XRES,YRES) Global Locked:TPixmap Global RGB[IW,IH] ' read and store colour information. Locked=LockImage(Image) For Local x=0 To IW-1 For Local y=0 To IH-1 RGB[x,y]=ReadPixel(Locked,x,y) Next Next UnlockImage(Image) ' main loop. While Not KeyHit(KEY_ESCAPE) ' Update the image and redraw. UpdateImage() DrawImage Blank,0,0 FlushMem Flip Cls Wend EndGraphics Function UpdateImage() Local Alp Local Red Local Grn Local Blu Local Col Local x,y Local average Locked=LockImage(Blank) ' Apply new settings. For y=0 To IH-1 For x=0 To IW-1 ' get colour info col = rgb [ x, y ] alp = (col Shr 24) & 255 Red = (col Shr 16) & 255 Grn = (col Shr 8) & 255 blu = (col Shr 0) & 255 ' the new colour settings. Average=(Red | Grn | Blu) / 3 Red=Average Blu=Average Grn=Average ' Colour Limits. If Red<000 Then Red=000 If Red>255 Then Red=255 If Grn<000 Then Grn=000 If Grn>255 Then Grn=255 If Blu<000 Then Blu=000 If Blu>255 Then Blu=255 col = (alp Shl 24) | (red Shl 16) | (grn Shl 8) | (blu Shl 0) ' write pixel draw If col<>000000 WritePixel (Locked,x,y,col) End If Next Next UnlockImage(Blank) End Function
Hugest of thanks,
THUMBZ