Page 1 of 1

[solved]glScissor and resizing window in sfml.

Posted: Mon Apr 04, 2011 9:35 am
by adikid89
When I resize the window, the clip rectangle for glScissor should change.. but I don't exactly know how to change it so that it fits the rect resized by view used by sfml about doing that... Any help please? :(

helpful pictures?
normal(not resized)http://img845.imageshack.us/i/normalf.png
resized http://img203.imageshack.us/i/resizedb.png

Re: glScissor and resizing window in sfml.

Posted: Wed Apr 06, 2011 5:50 am
by MrDeathNote
adikid89 wrote:When I resize the window, the clip rectangle for glScissor should change.. but I don't exactly know how to change it so that it fits the rect resized by view used by sfml about doing that... Any help please? :(

helpful pictures?
normal(not resized)http://img845.imageshack.us/i/normalf.png
resized http://img203.imageshack.us/i/resizedb.png
Can you not just call:

glScissor(0,0,SCREEN_WIDTH, SCREEN_HEIGHT);

Re: glScissor and resizing window in sfml.

Posted: Wed Apr 06, 2011 8:08 am
by adikid89
Why would I.. I guess I didn't explain properly. I use glScissor to not draw child widgets outside the rect of their parent. And the shape and position of the parent's rect changed when resized, and I need to compensate for that. I think I found a solution though: calculating the positions and size as a percentage of the window's size(for example the widget is at 1% width(x axis), 10%(y axis), its size is 15%(width) and 13%(height), and just convert that into the new window's size)
I think that should work..

Re: glScissor and resizing window in sfml.

Posted: Wed Apr 06, 2011 9:16 am
by MrDeathNote
Right I get what you're saying now. I thought you mean't the entire window. I guess your way could work if you take the widget/window ratio. I don't see any reason why that wouldn't work.

glScissor and resizing window in sfml.

Posted: Wed Apr 06, 2011 9:46 am
by adikid89
It didn't work...the positions were off..But I think I found the way this time :lol: . Because they resized based on the current view/window ratio... I'll uhm *calculate* the coords and size based on that. Still not quite sure how that'd go... but basically, in a window 800x600 with a view of 800x600, the ratio is 1, so the sizes and pos remain the same, in a window of 1000x600, the ratios are 1.25 and one.... so the position is offset by 1.25? and so is the width. At least I hope that's how it works :(

Edit: Using window/view ratio worked..