ViewportSizeX, ViewportSizeY

Sorry if this is a stupid question, or if I missed something, but I’m extremely new to all this.

When he created the two int32’s Called ViewportSizeX, and ViewportSizeY, it automatically knew the viewport size.

Where is it defined? When I looked at the documentation, I found that you’d need to do a bit of this:

//Viewport Size
 const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());

 //Viewport Center!            
 const FVector2D  ViewportCenter =  FVector2D(ViewportSize.X/2, ViewportSize.Y/2);

to get it. Where did he do that?

I watched it again a couple times and I realized what happened.

when he called the function GetViewportSize(ViewportSizeX, ViewportSizeY);
it was a built in function that passes viewport size as a vector into those two parameters.

Don’t know how still, but at least I’m not 100% lost anymore.

The function is what gives ViewportSizeX and ViewportSizeY it’s values.

int SetTwoValuesToZero(int& x, int& y)
    x = 0;
    y = 0;
int main()
    int a = 6;
    int b = 10;
    SetTwoValuesToZero(a, b); //a and b now 0

You should go back to lecture 163 Creating OUT Parameters. I think basically when we pass a reference through a parameter, we can indirectly modify the value in the method calling by modify the reference in the called method.

Privacy & Terms