Graphics command used more than once?

BlitzMax Forums/BlitzMax Programming/Graphics command used more than once?

Warren(Posted 2005) [#1]
This code doesn't work although I suspect it should. Anyone want to venture a guess? It will draw the first image just fine, but when I press a key and it tries to reinitialize the graphics window, load the image again and display it - it just draws a white quad.

Is the graphics command not designed to be issued more than once?


Graphics 640,480,0

Local img:TImage = LoadImage( "images/email.png" )
DrawImage( img, 16, 16 )
Flip
WaitKey

Graphics 640,480,0

Local img2 = LoadImage( "images/email.png" )
DrawImage( img2, 64,64 )
Flip
WaitKey



ImaginaryHuman(Posted 2005) [#2]
An extension to this question, for me, is, is it possible to open multiple contexts at the same time and somehow switch between them?


Warren(Posted 2005) [#3]
Am I the only one curious about this?


marksibly(Posted 2005) [#4]
Should work...possibly a Max bug.


Warren(Posted 2005) [#5]
OK, fair enough. I'll wait for the next update then, I guess...

Thanks!


Dreamora(Posted 2005) [#6]
ends up in blank white quads for me ( the same behavior when you minimize the window )


tonyg(Posted 2005) [#7]
I get the same issue but no idea why. It might have something to do with Blitzmax opening a new window for the second graphics command (which is very ugly)while B3D seems to use the same one.


Yan(Posted 2005) [#8]
It probably won't make the slightest bit of difference, but has anyone tried the EndGraphics command before the second Graphics call?


tonyg(Posted 2005) [#9]
Yep... same problem.


Warren(Posted 2005) [#10]
Yeah, I tried that as well. Nada.


Yan(Posted 2005) [#11]
Ah well, t'was just a thought.


ImaginaryHuman(Posted 2005) [#12]
Just a possibility - I had a problem with blank white quads showing and it was happening where I was trying to do direct OpenGL commands along with blitzMax 2d commands. Because Max2D keeps track of some internal variables, some states for example need to be tracked and with certain OpenGL calls it messes with Max's system. I got white rectangles come up and I needed to surround my OpenGL code with:

GLDisable GLTexture2D
'then do the OpenGL code
GLEnable GLTexture2D

I'm not exactly sure why I needed to do it this way around, you might think you should be enabling it first. Anyway, it worked, and I only had this problem on my iMac, not on my iBook. So it was weird.

So basically, try putting something like GLDisable GLTexture2D after your second "Graphics" command and see if it will display the texture instead of a white blank (or use the other command if that doesn't work). Maybe that'll work for you.


Warren(Posted 2005) [#13]
Yeah, but my code sample above isn't doing any OpenGL calls...


Panno(Posted 2005) [#14]
same "Error" here win32


Dreamora(Posted 2005) [#15]
to me it looks like the Max2D system loses the contact to the own media when you minimize or use graphics a second time ( even if endgraphics was in front of it ) on windows


ImaginaryHuman(Posted 2005) [#16]
oh, try it anyway?


tonyg(Posted 2005) [#17]
Not sure whether I have done this correct but it seems to work adding...
glEnable GL_TEXTURE_2D
after the second graphics command.
<edit> It seems a lower resolution (or maybe smoother) but the second image isn't so clear. Could it enable default gl values?


Warren(Posted 2005) [#18]
AngelDaniel

I'll try it again when the time comes. I just don't like working around things because once Mark fixes it, the hack will probably then start screwing things up and I'll have to debug the problem all over again.

I prefer to keep things clean.