Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: Pot Noodle on June 03, 2011
-
Hi Guys,
I was wondering if some one could help me out with this problem I have converting bb code to bm.
There is no doublebuffer command in bm so I must confess I don't know how to work around this
Any help would be most appreciated as I have just spent the last 2 nights working on this
-
Hi,
What you need to do is define a screen with a backbuffer something like this;
SetGraphicsDriver GLMax2DDriver()
Const xres = 1024
Const yres = 768
Graphics xres,yres,32,60,GRAPHICS_BACKBUFFER
Then all drawing by default is on the back buffer, you just need to use this command in your main loop to swap the buffers;
Flip(-1)
Hopt that helps!
-
Thanks for the speedy reply I have done as you said but I am still stuck, Basicly I have read my png font data in to an Array using Readpixel this works ok but I just can not get my head around the Writepixel command I would like to write the data back to the backbuffer then flip it in to view. WritePixel(BACKBUFFER, draw_x, draw_y, font(font_x, y))
What would go where I have Backbuffer? Thanks for your help.
-
Sorry, I see.. I hadn't understood the question.
Well, I can't run the program as it can't find your font file so I'll take a look at this tomorrow :) Maybe I'll build something that draws a scroller pixelwise like you are trying to do.
Bearing in mind that I've used Blitz Max for about 20 minutes in total so don't hold your breath.
In the meantime, maybe someone else whow uses Bmax regularly will help - there are a few people here who use it a lot.
-
I haven't used BlitzMax for along time. I came up with with a kind of wpf method using pixel maps. http://www.dbfinteractive.com/forum/index.php?topic=4101.msg54918#msg54918
-
Thanks Shockwave for your offer and your time I will wait and see if you come up with something.
The plasma effect is brill thanks for that, I think my problem is I never paid attention in maths at school and now
I am paying for it I do know that Out of bound errors are caused by bad maths :clap:
-
If you could attach the font image to a post, then I'll take a look at it and see if I can figure out why its not working for you.
-
OK here it is, hope you have more luck than I have had :suicide: I can only think it's the pixmap setup that is wrong.
Thanks for you help.
-
Writepixel is not fast and you can make a sine text effect much easier and faster by using the command that draws part of an image onto the backbuffer. I have made an example of this which you can try here:
SuperStrict
Const GRAPHICS_W:Int = 800
Const GRAPHICS_H:Int = 600
Const FONT_W:Int = 32
Const FONT_H:Int = 32
Graphics GRAPHICS_W, GRAPHICS_H
Global font:TImage = LoadAnimImage("Fonts.png",32,32,0,60) ' load image as an animimage with 60 frames each 32x32 pixels
Global cnt:Float = 0.0
Global cntUpd:Int = MilliSecs()
While Not KeyHit(KEY_ESCAPE)
Cls
sineText(0,300,"SINE TEXT TEST",100,cnt,0.5)
If MilliSecs() > cntUpd+25 Then
cnt :+ 2.0
If cnt > 359.99 Then cnt :- 360.0
End If
Flip
Wend
Function sineText(x:Int,y:Int,text:String,amp:Int,sine:Float,add:Float=0.1)
For Local i:Int = 0 To Len(text)
Local char:Int = Asc(Mid(text,i,1))
' check to see if it is a valid character and if so, then draw it
If char > 31 And char < 92 Then
' go through each vertical line of the character
For Local ii:Int = 0 Until FONT_W
DrawSubImageRect(font,x,y+Sin(sine)*amp,1,FONT_H,ii,0,1,FONT_H,0,0,char-32)
sine :+ add
x :+ 1
Next
End If
Next
End Function
If you want to find out how to do fast pixel manipulation you can try and take a look at how I did it for a software framework I posted a while back on this forum. It shows how to do the manipulation directly on the data instead of using write-/read-pixel commands.
[edit] Here is a link to the old thread about my software framework. http://www.dbfinteractive.com/forum/index.php?topic=4193.0 (http://www.dbfinteractive.com/forum/index.php?topic=4193.0)
-
K+ for you Zawran :-)
-
Thank you, so much if I told you that I had been trying to produce that effect on and off for a number years now
I bet you would laugh, I can't thank you enough looking at the code "what there is of it" looks so simple
I guess the more you try the worst it gets, finding this site and your help has made my day :updance:
Thanks again.
-
You are very welcome. It can be done with pixel manipulation, it just does not make sense to do unless you need the pixel stuff for something else at the same time. So this is why its better to use the image drawing options already available. I have made a ton of different old school effects using both blitzplus and blitzmax, and I does not mind answering questions, so if there are anything you are struggling with and want help with then please feel free to ask on this forum and together we will try and find a solution.
-
Zawran made a pretty awesome library for Blitzmax some time ago.
You might look that up it, had some great raster effects it could do.
-
Thanks I will try and find it.
-
Sorry Pixel_Outlaw I have looked for the library but with no luck, If any one can point me in the right direction to the download I would be greatfull.
-
There is a link to the framework in my post further up where I also posted that example.
-
Thanks found it and ran the example code, this will help me no end :goodpost: