Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Pot Noodle on July 18, 2011

Title: Somthing Strange
Post by: Pot Noodle on July 18, 2011
Hi Guys,
Would some one with BlitzMax & Opengl knowledge take a look at my code please, there is two problems.
(1) scroller does not start at the place.
(2) FPS is all over the place, starts out ok then after a few Min's the FPS start to jump up & down.

Thanks
Title: Re: Somthing Strange
Post by: Shockwave on July 18, 2011
Hi Potnoodle :)

It starts where it does because there are no blank spaces padding the beginning of the scroll.  It runs at about 3fps for me - Usually it happens on this card because it's an ATI card and it's intollerant of non power of two textures, but this time I think it has something to do with you binding the textures of each letter as you draw it.

I'd think that it would be better to have the letters as one long strip and use some kind of calculated offset to generate the texture co-ordinates for your scroll.
Title: Re: Somthing Strange
Post by: Pot Noodle on July 18, 2011
I was hoping not to have all them spaces in the text, Do you know of a way so the scroller will re start as soon as the last letter goes off screen  ;D please
Title: Re: Somthing Strange
Post by: Jim on July 18, 2011
I think it might be this GLTexFromPixmap that's slow and/or leaking memory.  Can you pre-calc that for all the letters outside the loop that prints the messages?

something like
Code: [Select]
for x = 32 to 127
letters[x] = GlTexFromPixmap(font[x])
next
then in your loop
Code: [Select]
font = letters[x]

Jim
Title: Re: Somthing Strange
Post by: Shockwave on July 18, 2011
I was hoping not to have all them spaces in the text, Do you know of a way so the scroller will re start as soon as the last letter goes off screen  ;D please

There are a few ways of doing that, here's some of them..

You could have a texture that you draw for the scroll each frame,  and just draw new letters on the right hand side of it every time you pass one letter width and simply draw this texture each frame.

or

You could have an array of letters that are displayed accross the screen, scroll an offset and when it goes further that the width of a letter, move them all over one place so the first becomes the second, the second becomes the third until you get to the end where the new one goes.


Finally (and probably useless for PC coding)
You could have a texture twice the width of a screen and scroll it the same amount each frame;

Code: [Select]
        | <- 1 Screen -> |
========================
 <<   |A        |B  <<
========================

have two points where you draw the letters (A+B), when you've scrolled one screen width, flip the screen back (a trick I used to use on the amiga with hardware scrolling under interrupt), because you have two copies of the scroll it will look like it's moving continuously.

All the above methods would do what you need.
Title: Re: Somthing Strange
Post by: Pot Noodle on July 18, 2011
Thanks Jim your idea works, I didn't think it was GLTexFromPixmap I think I tried everything else  ::)
Now to get the scroll to draw all the text as it ends before the end of the scroll text.
Cheers Shockwave I will test your ideas and see.
Thanks guys.