SFML community forums

Help => Window => Topic started by: adikid89 on April 03, 2011, 09:54:59 pm

Title: [1.6][solved] glScissors and resizing window.
Post by: adikid89 on April 03, 2011, 09:54:59 pm
How should I do it... the clip area very wrong.. and I don't know how to update it to match the new window size.  :(

Edit: Helpful pictures?
normal(not resized, works) http://img845.imageshack.us/i/normalf.png/
resized(doesn't work) http://img203.imageshack.us/i/resizedb.png/
Edit: More info?  :|
this is what i do when the window gets resized:

Code: [Select]
m_clipRect = m_rect; //a IntRect ... of sorts
sf::Vector2f pos = m_rect.GetPos();
        //hopefully this will turn the view coords into screen coords?.. oh wait.. this doesn't do that.. any other way?
ConvertCoords(pos); //calls sf::RenderWindow.ConvertCoords()

m_clipRect.x = (int)pos.x;
m_clipRect.y = s_gui->GetWindow().GetHeight() - (int)pos.y - m_rect.h; //this is how it's done for glScissors apparently, cause it takes the lowerleft point
   m_clipRect.w *= scaleW;   //scaleW is newWidth/oldWidth
m_clipRect.h *= scaleH;   //same with height


Solved like so:
I used window/view ratio to find coords and size like this:
Code: [Select]

        //calculate distortion percentage
        float widthPrc = newWidth/viewWidth;
float heightPrc = newHeight/viewHeight;

        //get the coords in the view
m_clipRect = m_rect;

        //apply distortion
m_clipRect.x *= widthPrc ;
m_clipRect.y *= heightPrc ;
m_clipRect.w *= widthPrc ;
m_clipRect.h *= heightPrc ;


Only one problem remains... :

P.S. Apparently maximizing the window doesn't send a resize event... Is that intented? Is there another event for maximize or something? :|
(Windows 7 x64, sfml 1.6)