Dealing with DeviceResolution
Monkey Forums/Monkey Programming/Dealing with DeviceResolution
| ||
I found this html snippet from ElectricBoogaloo and it is very useful! However it appears DeviceWith & DeviceHeight does not update? So even tough things in my app "should" be resolution independant (and is) I can't test it "on the fly". Any ideas on how to fix? Feels like that would be the end of the resolution testing hassle forever! :) |
| ||
I'm rendering this to test: Method OnRender() DrawCircle 0, 0, 100 DrawCircle 0, DeviceHeight, 100 DrawCircle DeviceWidth, DeviceHeight, 100 DrawCircle DeviceWidth, 0, 100 End It seems to work downwards. When initial resolution is higher width/height works even at smaller resolutions but not bigger? |
| ||
Just a thought, based on my use of diddy.SetNativeGraphicsSize(): are you trying to read the new values during OnUpdate()? In the case of the diddy function, I don't know whether it only activates during OnRender(), or whether Monkey only reads the values then, but when I call it I don't get a new resolution until OnRender() is called. |
| ||
Yeah, I also used the SetNativeGraphicsSize before, then I had the resolution set from code - which is OK, but this is much more handy imo. Even if it takes a render, would that not mean it just takes a frame to get it "right" again? Or is there something manual. Like a MojoVerifyDevice? |
| ||
Hmm.. I'm using DeviceWidth() and DeviceHeight() here, with no issues. I tend to stick them into Global variables, though.. J_WW=DeviceWidth();J_WH=DeviceHeight() inside OnRender() seems to work fine for me. Perhaps, as Gerry suggests, it only works within OnRender()..? |
| ||
Gerry, setting SetVirtual(DeviceWidth, DeviceHeight, True) in OnRender was one of the things I had missed. Thanks for that! Now it "almost" always work. But like before it gets weird in certain cases. It is the two rightmost circles that disappear so I assume it has to do with DeviceWidth/DeviceHeight, or is it only for me? I'm testing on Chrome. |
| ||
Hm... I have gotten it working now. I'm updating the rez in OnUpdate. Tough seems like I have to set the size and position of every gui-element every frame. However the corner-circle work now in all resolutions :) |
| ||
"Tough seems like I have to set the size and position of every gui-element every frame." Just store the last-known resolution, and if it hasn't changed since the last frame you don't have to change your layout. |