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)
*/