Jump to content
Sign in to follow this  
Guest mgipson

Refresh problem after setting bright / dark flags

Recommended Posts

Guest mgipson

I have a problem I am hoping somebody can help me with.I have some gauges that respond to night lighting by setting the bright image flag on certain parts, for example to make an engine gauge face and needle light up but not the background.I do this by setting the IMAGE_USE_BRIGHT flag on the elements and then setting the IMAGE_ON_SCREEN flag to force a redraw. I do this in the gauge pre draw. I do this 2 times when the lighting has changed, I don't want to set IMAGE_ON_SCREEN all the time.This works fine 95% of the time. However some times the bright flag will not take effect until the needle starts to move and sometimes not even then.I am doing something wrong to force a refresh? Does anybody know of a way around this?Thanks,Mark

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

If your gauge is on screen, then the IMAGE_ON_SCREEN flag is already set, and setting isn't going to "invalidate" and cause a redraw. Besides, anything you do in "pre-draw" is happening right before an update anyway.You only need to play with that flag if you want to take something off screen and then put it back later, like perhaps an "OFF" flag.The behavior you are seeing where the needle has to move is not your fault. In fact, if you set the time to a time at dusk, just before the lighting goes low enough to cause FS to begin using the IMAGE_USE_LUMINOUS colors, you will note the same behavior. That is that some gauges will change to the luminous color, and some will not until you "move" the needle.I believe this is just a bug in the lighting system. One way around it is to introduce a bit of jitter into your gauges, but this is not always appropriate.But, I would recommend setting the bright flag in the macro callbacks, that's what I do, and I have not run into this problem. This is because any change in that callback will cause a redraw.Also, if you are not updating the gauge at 18 Hz, this may be another reason you see no change.Good luck

Share this post


Link to post
Share on other sites
Guest mgipson

I haven't tried setting it the callback. What about elements that don't have callbacks though?

Share this post


Link to post
Share on other sites

Since MAKE_STATIC has no callback, change it to MAKE_SLIDER and create the two callbacks needed. Set the origin to 0,0 so it will behave like a MAKE_STATIC.I use this in slider, needle and ICON type callbacks to produce 'bi-level' lighting: if (panel_lights == 2) { LIGHT_IMAGE(pelement) ; } else if (panel_lights == 1) { DARKEN_IMAGE(pelement); LUMINOUS_IMAGE(pelement); } else if (panel_lights == 0) { DARKEN_IMAGE(pelement) ; }The extra DARKEN_IMAGE(pelement) is necessary to force the LIGHT_IMAGE "off" before using LUMINOUS_IMAGE when decreasing brightness... ;)For some elements, I need to 'clone' the MAKE_SLIDER, etc. macros and the callbacks, make necessary changes to make 'em unique (i.e., SLIDER_off, SLIDER_lo, SLIDER_hi), then use a combination of if (plights == 2){ SHOW_IMAGE(pelement); LIGHT_IMAGE(pelement; }elseHIDE_IMAGE(pelement);etc.


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest mgipson

Thanks Bill, I am going to try this method on one gauge if see if it works for me. If so then I will have th huge 'fun' of changing all my gauges :-(

Share this post


Link to post
Share on other sites

>Thanks Bill, I am going to try this method on one gauge if>see if it works for me. If so then I will have th huge 'fun'>of changing all my gauges :-(Actually, once you've got two done, the rest become simpler to do...It took me a day and a half (about 14 hours) to complete 47 gauges...The nice thing about this technique is that it requires no additional bitmap resources, since the same resource id is used three times at worst case, and only once at best.If one really wanted to go crazy, a copy of the bitmap with a 'light effect' applied in Photoshop could be added, which would allow for five levels of lighting:off - .bmpdim - alternate .bmp w/ Luminousmed - alternate .bmp w/ Brightmed2 - .bmp w/ Luminousbright - .bmp w/ Bright


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest mgipson

After some more experiments I seem (fingers crossed) to have got my old method working, not sure why though :-)Before I was doing the set bright and a set off screen, which only worked some of the time. Now I have this code which seems to work all the time, it's being called from the gauge pre update and not from a callback.void SetLitElements(int circuit, PELEMENT_HEADER list, int num){ LightSystem* pLightSystem = Systems::GetLightSystem(); bool bright = false; if(pLightSystem != NULL) { bright = pLightSystem->GetLightCircuitState(circuit); } for(int i=0; i

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...