Change screenmode

BlitzMax Forums/BlitzMax Beginners Area/Change screenmode

xlsior(Posted 2005) [#1]
I was trying to implement a change-over between Windowed mode and Full screen mode, and was seeing some really weird things...

May be obvious in hindsight, but I should probably bring it up anyway and maybe safe someone else some hair-pulling moments.

I found that when I ended the current graphics mode and switched to a new graphics mode (in particular between windowed and full screen) that the sprites I had loaded were gone. I knew that that would be the case, I had a function to reload them.

However, what kind of threw me off is that this worked only intermittently:

Going from full screen to windowed mode would require the sprite loading routine to be called TWICE to have any effect, while the other way around (windowed to full screen) would only work if I called it ONCE.

Switching from full screen to windowed and only loading the sprites once would return in a white screen, and then switching back to full screen would require the sprites to be reloaded twice in a row before anything other than a white screen would be drawn...

Extremely confusing...

The fix turned out to be to explicitely de-reference all existing sprites FIRST (mysprite=NULL, flushmem) and then do the loading... I was under the impression that it should be able to simply load & overwrite the old info on the fly, and the confusing part was that this DID work, but only part of the time.

Is this a bug, or a 'feature'? Might be worth mentioning some of these situations in the manual somewhere...


xlsior(Posted 2005) [#2]
Also, I can reload all sprites without problems, but how does one reload the default font? After changing the screenmode, any text printed in the default font (no specific font or size was explicitely delared at any time) will simply show up as white rectangles.

I guess it would be really helpful if there were some kind of text re-initialization function that will restore/reload the defaults.


Steve Elliott(Posted 2005) [#3]
Bumping this thread as I have the 'white rectangle' problem.

I thought I'd got around the problem using this code.

Local DefaultFont:TImageFont
DefaultFont = GetImageFont()

change mode

SetImageFont(Defaultfont)


But this only seems to work once for fonts - even using global. Has anybody got some code that works no matter how many changes of the graphics mode?


xlsior(Posted 2005) [#4]
Very strange... it does only work the first time it's called indeed.


Steve Elliott(Posted 2005) [#5]
Bump. :-(


Grisu(Posted 2005) [#6]
Already mentioned that bug a month ago, but no fix out yet.
http://www.blitzbasic.com/Community/posts.php?topic=43626

For my program I coded an ini file, where the user can set screen mode.. :/


Steve Elliott(Posted 2005) [#7]
Hmm that's strange Squatting Neville's example works perfectly. But in a real program it doesn't - my program works for one change only before getting the blank rectangles instead of text - and not at all without the code I mentioned.

Perhaps an alpha problem?

Screenshot1 is how should look. www.elliottproductions.co.uk/temp/screenshot1.jpg

Screenshot2 is how it looks after 2 changes of graphics mode. www.elliottproductions.co.uk/temp/screenshot2.jpg


Grisu(Posted 2005) [#8]
btw: is there a way to get rid of the console window behind the blitz window in windowed mode?

Link broken! add .jpg!

THATS EXACTLY MY BUG! HAVE THE SAME HERE!


Steve Elliott(Posted 2005) [#9]
The links fixed.

The last update removed the console window Grisu - haven't tried it in Windowed mode though - but Mark said the work on a completed Windowed mode is to be finished.


xlsior(Posted 2005) [#10]
btw: is there a way to get rid of the console window behind the blitz window in windowed mode?


In 1.05. enable 'Build GUI App' in the Program menu.


Grisu(Posted 2005) [#11]
As long as I code within the ide, its no longer present.

But when making an exe and running it alone, I get this:
[removed]


Grisu(Posted 2005) [#12]
Ahh, just saw the other post. Thanks a lot... that did it!


Steve Elliott(Posted 2005) [#13]
So just the font problem now eh Grisu?


Grisu(Posted 2005) [#14]
yepp, but i gave up by now and read an inifile on startup... not my liking... but I such stuff drives me crazy.


Steve Elliott(Posted 2005) [#15]
For what it's worth I've reported it as a bug.


Grisu(Posted 2005) [#16]
Already did that ages ago, no fix by now... :(

Sent u something via e-mail! :D


Steve Elliott(Posted 2005) [#17]
So did I! I thought I'd solved it until I tried to change modes again. ;-)

Got your email - but I don't have rar - a zip version would be good.


Grisu(Posted 2005) [#18]
Uploading zip version.. COMPLETE!

Same link as before, but with ".zip"!

btw: Your email took looooooooooooooooooooooooong!


MrCredo(Posted 2005) [#19]
What we need is a autoreloading of image's/font's

this is so easy... blitzmax should save pathname from a image, that was loaded with LOADIMAGE etc... after changing GFX-mode, bbmax can start a subroutine, that reload all images again that was loaded and exist now...


Grisu(Posted 2005) [#20]
what we need is bmax handle all data on default when changing screen modes. This works wonderful with bp... so why not implement this for bmx as well?


Steve Elliott(Posted 2005) [#21]
I couldn't wait any longer (it was bugging me) so I wrote my own drawtext function and designed a font. So I can change modes as often as I like now. :-D

If you load a font graphic in with loadanimimage (contains all letters etc in ascii order from 32) then use something like...

For Local loop = 0 To text.length-1

  DrawImage(gfx_font,x+font_size,y,text$[loop]-32)
  x :+ font_size

Next




skidracer(Posted 2005) [#22]
Hopefully this will be fixed next week. I think the solution is that there needs to be a deafult OpenGL context created when the app starts and then any windows and fullscreen modes you create will inherit / share this context and all textures loaded will be retained.


Steve Elliott(Posted 2005) [#23]
That's good news - I know it's a beta version but sometimes it can be frustrating when things don't work.

Glad to hear you're working on the problem.


Grisu(Posted 2005) [#24]
Thanks a lot skidracer!

*grisu makes the dragon dance*


Steve Elliott(Posted 2005) [#25]
Steve looks at his calender. ;-)


Grisu(Posted 2005) [#26]
Release dates are always pain... ;)