resize fullscreen quad

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

resize fullscreen quad

Post by Seven »

I am adding the ability to toggle XEffects in my app and so far so good with a full screen quad.
I need to resize the fullscreen quad to render only to a portion of the screen.
it seems that I could ratio the desired screen coordinates (resolution) against the full screen dimensions (dims)
but this is not working properly.

any help would be appreciated.

Code: Select all

 
    /// Sets a new screen render window target.
    void setScreenRenderPosition(const irr::core::rect<irr::s32>& resolution)
    {
        irr::core::dimension2du dims = m_Driver->getScreenSize();
        float x = (float)dims.Width;
        float y = (float)dims.Height;
 
        float xRatio    = (float)resolution.UpperLeftCorner.X   / x;
        float yRatio    = (float)resolution.UpperLeftCorner.Y   / y;
        float xRatio2   = (float)resolution.LowerRightCorner.X  / x;
        float yRatio2   = (float)resolution.LowerRightCorner.Y  / y;
        
        printf("render window %d %d %d %d\n", resolution.UpperLeftCorner.X, resolution.UpperLeftCorner.Y, resolution.LowerRightCorner.X, resolution.LowerRightCorner.Y );
 
        printf("resolution Xratio(%f), Yratio(%f), Xratio2(%f), Xratio2(%f)\n ", xRatio, yRatio, xRatio2, yRatio2);
 
        Vertices[0].Pos = irr::core::vector3df(-1.0f * xRatio,  -1.0f  *yRatio,  0.0f);
        Vertices[1].Pos = irr::core::vector3df(-1.0f * xRatio,   1.0f  *yRatio2, 0.0f);
        Vertices[2].Pos = irr::core::vector3df(1.0f  * xRatio2,   1.0f *yRatio2, 0.0f);
        Vertices[3].Pos = irr::core::vector3df(1.0f  * xRatio2, -1.0f  *yRatio,  0.0f);
        Vertices[4].Pos = irr::core::vector3df(-1.0f * xRatio, -1.0f   *yRatio,  0.0f);
        Vertices[5].Pos = irr::core::vector3df(1.0f  * xRatio2,  1.0f  *yRatio2, 0.0f);
 
        for (int x=0; x<6; x++) printvec(irr::core::stringc(x), Vertices[x].Pos);
        printf("--------------------------------------------\n");
    }
 

I get this ouput with the above code
/*
render window 704 130 1048 1004
resolution Xratio(0.484848), Yratio(0.128968), Xratio2(0.721763), Xratio2(0.996032)
name 0 X(-0.484848), Y(-0.128968), Z(0.000000)
name 1 X(-0.484848), Y(0.996032), Z(0.000000)
name 2 X(0.721763), Y(0.996032), Z(0.000000)
name 3 X(0.721763), Y(-0.128968), Z(0.000000)
name 4 X(-0.484848), Y(-0.128968), Z(0.000000)
name 5 X(0.721763), Y(0.996032), Z(0.000000)
*/
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

Re: resize fullscreen quad

Post by AReichl »

1.: WHAT is wrong (in your opinion)?
2.: also print out 'dims'.
Post Reply