Found out something disappointing...

BlitzMax Forums/BlitzMax Module Tweaks/Found out something disappointing...

Grey Alien(Posted 2006) [#1]
If you use DrawImage and specify floating point x and y the image get's nicely antialiased and placed correctly. This means that my framework can move stuff across the screen and it looks very smooth because you don't get any rounding to Integer errors which cause minor jerks every so often.

However if you do the same with DrawText it doesn't look good at all. Even though DrawText anti-aliases the text with SetBlend AlphaBlend, it doesn't accept floating point coordinates and thus if you try to move text nice and smoothly onto the screen, it will suffer rounding errors and minor jerks every so often. This is a bummer and it took me ages to figure out that this was what was going on and that my timing code wasn't stuffed.

Of course a solution is to pre-draw the text to the screen first, then grab it into an image, and then move the image onto the screen with DrawImage and using floating point coords. Fine, shame GrabImage is so slow.

Maybe a BlitzMax module tweak could be made to get the text drawn at floating point coords or is that really a video card issue, any ideas?


Eikon(Posted 2006) [#2]
Here's some example code that demonstrates the issue. The third drawing method should appear the smoothest.




Grey Alien(Posted 2006) [#3]
Great little bit of test code! Totally demonstrates my point. I'm going to have to prerender my text to get it looking good (or fix/alter the modules).

At least BlitzMax doesn't have bankers rounding (round to nearest even number) like BlitzPlus, phew. Banker's rounding may result in better averages for financial programs but it stinks for smooth moving objects. This was what I'd have done in Blitz Plus:

DrawText "Testing", Floor(x+0.5), Floor(y+0.5) + 60
but in the demo it does just the same as the first testing line, showing that Max isn't doing bankers rounding - good!


TartanTangerine (was Indiepath)(Posted 2006) [#4]
That is another reason why I implemented this module : http://modules.indiepath.com/forum/viewtopic.php?t=15


Grey Alien(Posted 2006) [#5]
Yeah I made one of those for BlitzPlus, looks like I'll need to make it for BlitzMax too (why not buy yours? I'm sure it's fine but mind needs to be part of the framework really). Mind you I'm checking out the BRL modules right now for a possible tweak ...


GfK(Posted 2006) [#6]
I've done my own bitmap font routines for Blitzmax. The beauty of it is, it works with FONText output.


Grey Alien(Posted 2006) [#7]
I think I've got that program kicking around somewhere...


Grey Alien(Posted 2006) [#8]
Hmm, in imagefont.bmx TImageFont.Draw is accepting floats and passing them on to image.frame(0).draw and from then on it's doing the same stuff as DrawImage is. I can't figure out why one is anti-aliased (drawimage) and one isn't (drawtext)...


TartanTangerine (was Indiepath)(Posted 2006) [#9]
Jake, It's free!


Robert Cummings(Posted 2006) [#10]
What do you have that has fonts flying around the screen anyway?


Grey Alien(Posted 2006) [#11]
Indiepath: cool! but there's licensing issues of course for my framework.

One Eyed Jack: High score table, sliding the lines into place, lines look jerky if drawtext used, fine if drawimage used on prerendered fonts. I know I can do bitmap fonts etc, but I'd really like to see if the modules can be tweaked to get it to work "natively" ... I'm too tired now though, been on dad duty for 2 days as Helen is away. Plus tomorrow, god what time will they get up :-(


GW(Posted 2006) [#12]
unfortunatly when you create your own font the module blows up with array index bounds error.


Robert Cummings(Posted 2006) [#13]
I'm going the bitmap font path anyway. You would hate software rendering in SDL as it is all "jerky" and integer coordinates with no rotations :)


Grey Alien(Posted 2006) [#14]
lol, yeah probably, so I won't bother with it. It's gonna be 3D card or nothing with my game. I'm gonna make a TBitmapFont as well. Still would like to see DrawText working at non-integer values, though, but I really don't have a clue why it's not doing it.


popcade(Posted 2006) [#15]
Bitmap fonts looks nice and can do many effects, however I have a few problem to implementing unicode support on it, the font image will be pretty big.


wedoe(Posted 2006) [#16]
Jake, It's free!
Like in "use it for whatever you like (commercial or not)"-royaltyfree ?

Lots of good modulestuff there Indiepath :)


Grey Alien(Posted 2006) [#17]
Like in "use it for whatever you like (commercial or not)"-royaltyfree ?
yeah, if that's the case I'll take it! :-D I just don't want to enter into complex license agreements when selling my framework - I want to keep it simple.


skidracer(Posted 2006) [#18]
The default imagefont does not include mip/filtered flags but any loaded ones do by default. There does seem to be something a little wrong with the glyph boundary pixels (Y scrolls perfectly crossbar of t doesn't), will investigate...
Graphics 640,480

SetBlend alphablend

SetImageFont LoadImageFont("c:\windows\fonts\verdana.ttf",48)

Local tickerx#=440

text$="Yo to all the Apple, Windows and Linux BlitzMax programmers in the house! "
text:+"Game development is the most fun, most advanced and definitely most cool "
text:+"software programming there is!"

While Not KeyHit(KEY_ESCAPE)
	Cls
	DrawText "Scrolling Text Demo",0,0

	DrawText text,tickerx#,200
	DrawText text,Int(tickerx),400

	tickerx=tickerx-0.01
	If tickerx<-TextWidth(text) tickerx=640
	Flip	

Wend

End



TartanTangerine (was Indiepath)(Posted 2006) [#19]
yeah, if that's the case I'll take it! :-D I just don't want to enter into complex license agreements when selling my framework - I want to keep it simple.
Yes use it but don't try and sell it as your own.

What does that mean? If you want to include it then make sure people know where it came from and where to come to get more great stuff.


popcade(Posted 2006) [#20]
Maybe skid will implement it with similar params as load image in the next release, we may need to wait for a while.


Grey Alien(Posted 2006) [#21]
skidracer: Interesting demo. I see what you mean. Basically I was scrolling some fairly large text and noticed that it appeared to jerk a lot as if it was rounding to integers, but perhaps it's a slightly different issue, the one that you have identified.

Yes use it but don't try and sell it as your own.
You are a star! I'll add it to the code with full comments about the source and also add it to the framwork FAQ and sales blurb that it contains an Indiepath module and I'll link to your others :-)


Grey Alien(Posted 2006) [#22]
Just made a moving light source and simulated shadow on text and buttons. It's really nice and smooth on the buttons but jerky on the text. A fix for this would be great!


Grey Alien(Posted 2006) [#23]
Shall I move this to the bugs forum? Is it a bug or just a limitation? Any progress Skidracer?


skidracer(Posted 2006) [#24]
Try replacing the LoadGlyph function in brl.mod/max2d.mod/imagefont.bmx[58] with the following:

	Function FixPixmap:TPixmap( src:TPixmap )	
		Local dest:TPixmap=TPixmap.Create( src.width+2,src.height+2,src.format )
		If dest.capacity MemClear(dest.pixels,dest.capacity)
		For Local y=0 Until src.height
			CopyPixels src.PixelPtr(0,y),dest.PixelPtr(1,y+1),src.format,src.width
		Next
		Return dest
	End Function
		
	Method LoadGlyph:TImageGlyph( index )

		Assert index>=0 And index<_glyphs.length

		Local glyph:TImageGlyph=_glyphs[index]
		If glyph Return glyph
		
		glyph:TImageGlyph=New TImageGlyph
		_glyphs[index]=glyph
		
		Local src_glyph:TGlyph=_src_font.LoadGlyph( index )
		
		glyph._advance=src_glyph.Advance()
		src_glyph.GetRect glyph._x,glyph._y,glyph._w,glyph._h
			
		Local pixmap:TPixmap=TPixmap( src_glyph.Pixels() )
		If Not pixmap Return glyph
			

'		glyph._image=TImage.Load( pixmap.Copy(),_imageFlags,0,0,0 )
		glyph._image=TImage.Load( FixPixmap (pixmap),_imageFlags,0,0,0 )
		
		Return glyph
		
	End Method



Grey Alien(Posted 2006) [#25]
EXCELLENT WORK THANKS! :-D Really looks good now, totally smooth. Means I don't need to make a TBitmapFont ... yet. Will this be included in the next update as default?


ImaginaryHuman(Posted 2006) [#26]
Probably :-D


Grey Alien(Posted 2006) [#27]
Just worries me when something get's moved to module tweaks as if it's "optional" whether you want to apply it. In this case I can't think why you would *not* want to apply it. I'm probably being paranoid, but it's nice to know for sure.


Smurftra(Posted 2006) [#28]
Indiepath, i'm interested in your bitmap font module but i can't find a link other than to download an example.

How do we get the free modules to play around with?

Thanks,

Smurftra


Grey Alien(Posted 2006) [#29]
Smurftra: I'll be adding a bitmap font type to my framework soon so you'll get that as part of the upgrade.


Smurftra(Posted 2006) [#30]
I'd still like to take a look at all of indiepath's free modules but still cant find a way to download anything other than examples.


SillyPutty(Posted 2006) [#31]
was this put into the very recent syncmods ? I hope all these fixes are going in there.


Grey Alien(Posted 2006) [#32]
No it wasn't. I checked today! before a syncmods I actually back up my old mods. Anyway I checked the list of the newly downloaded mods and imagefont was not one of them. That's why I'm confused as to if this will be and "official" change or not, it certainly should be logicially, and perhaps I'm just being paranoid. However, Skidracer hasn't replied yet ...


marksibly(Posted 2006) [#33]
Hi,

Skid's fix is in! Syncmods away...


Grey Alien(Posted 2006) [#34]
This is great news thanks.