detecting when graphics begin exactly
Blitz3D Forums/Blitz3D Beginners Area/detecting when graphics begin exactly
| ||
How do you tell exactly when graphics have begun? There seems to be a lag at the beginning when you are initializing graphics. If I display a logo for one second at the beginning of my game, by the time graphics are actually being displayed to the screen that second is passed and the logo is no longer being drawn. How do I code things so that the logo will actually be displayed onscreen for one second? |
| ||
I have noticed that different monitors take different amounts of time to switch resolutions. What works on one (timewise), doesn't necessarily work on another. I have tried performing a Flip, thinking that the game won't advance until the Flip is finished, but that method doesn't work. Apparantly the screen can Flip, even if the resolution hasn't completed changing yet. So far, all I've found to be able to do is set a Delay for 1 or 2 seconds before my game begins. I've also chosen to do this because WinXP has an annoying habit of redrawing the taskbar at the bottom of the screen for the first half-second or so after my game switches to fullscreen (even though it shouldn't be writing to the screen anymore). |
| ||
Anyone else? I've seen games written in Blitz which have an accurate 1 second logo at the beginning of the game so I know this is possible; anybody who's written a game with a logo screen at the beginning feel like enlightening me? |
| ||
would a check for graphicswidth() do it? |
| ||
That doesn't seem to work. I tried adding While GraphicsWidth()<>xres Wend before the 1 second delay starts but that didn't help ("xres" is a variable storing the X resolution I used in the call to Graphics3D.) Any other thoughts? |
| ||
Would timing how long graphics take to initialize be of any use? Something like:gstart = MilliSecs() Graphics3D 640,480,16 gend=MilliSecs() gtime=gend-gstart EndGraphics Graphics3D 640,480,16 Delay gtime Print "hello" Delay 1000 Flip WaitKey() End [edit] Sorry, scrap that - that code is clearly rubbish! :P |
| ||
That works for me, but of course it takes twice as long to get the graphics mode running. |
| ||
So far, all I've found to be able to do is set a Delay for 1 or 2 seconds before my game begins. This worked for me, displaying a logo for as long as I Delayed it. I don't quite understand why this is no good for you? |
| ||
some way of detecting WM_DISPLAYCHANGE might solve it: the WM_DISPLAYCHANGE message is sent to all windows when the display resolution has changed. WM_DISPLAYCHANGE cBitsPerPixel = wParam; cxScreen = LOWORD(lParam); cyScreen = HIWORD(lParam); Parameters cBitsPerPixel Specifies the new image depth of the display in bits per pixel. cxScreen Specifies the new horizontal resolution of the screen. cyScreen Specifies the new vertical resolution of the screen. probably going to have to be through a userlib |
| ||
Graphics mode change should be instant. If it's not, then it is the monitor's fault. Being the monitor's fault, there may be no way to detect when it's finally begun displaying the image. But if there is any way, the only way I can think of might be to check the scanline that the monitor is currently displaying. It might be worthwhile to write a program to print the current scanline it detects to a logfile both before and after a graphics mode change and see if it gets stuck at 0 for a little while. If that is the case then maybe you could wait until it's not 0 to begin displaying graphics. I'm highly doubtful that this will work, but it's the only thing I can think of that might work if the monitor is at fault. |
| ||
I would have thought that simply doing a cls and flip would force it to wait until the graphics mode could respond the the flip and vwait. As sswift says, if the monitor doesn't keep up, there is not very much that can be done to detect it. |
| ||
Graphics mode change should be instant. If it's not, then it is the monitor's fault. Actually I've noticed that it takes windows XP much longer to change graphics mode than windows 2000/9x/ME. So it's more likely the operating system's fault. |
| ||
That bloody Bill Gate's fault again! :P I thought of that scaline checking method, also. I, too, was rather sceptical it would work and I wasn't disappointed. :/ |
| ||
Graphics 800,600 delay 1000 Also, be sure your not loading things after your gfx call. |
| ||
Er, if I don't load anything after the graphics call then nothing will be visible, rather defeating the purpose. ADDITION: That last comment got me thinking. and I just did a little tinkering with my code and think I've figured something out. I'll post once I figure out exactly what's going on. |
| ||
I just realized the pause before graphics start rendering is not due to loading things after Graphics3D, it is due to having code BEFORE Graphics3D. Very odd. I just tested it down to the only line of code before I call Graphics3D is a line declaring a global variable, and this still results in a pause. But if I call Graphics3D all the way up at the top, the starting logo is displayed immediately, even with lots of stuff going on after it before rendering starts. This is good to know but very annoying. I think I'll be calling Graphics3D into a safe mode like 640,480 just for displaying logos at the start, and then re-initializing into a different mode for the actual game with a check to see if that other mode is supported. |
| ||
AARGH! I just realized what I just described is only true if the call to Graphics3D at the top is Graphics3D 0,0 WTF?! I think I'm going to cry. EDIT: Sorry all, I was freaking out a little there. This all makes sense to me now. You need to call Graphics3D before you can use any 3D commands (and my logo is a sprite.) Meanwhile, if you use 0,0 for the resolution, the monitor settings aren't actually changed (ie. you're rendering at desktop resolution,) thus no pause. This is no good however since it is entirely possible for the desktop resolution to be set to a resolution which isn't supported for 3D rendering. I'm thinking I'm just going to start with two seconds of black before displaying any logos to account for the pause. |