Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - runyonave

Pages: [1]
1
Graphics / Re: Issue with a Y offset on viewport
« on: November 01, 2022, 07:28:13 pm »
Wow, thank you! This makes a lot more sense. Plus it's a much simpler way of setting the viewport than what I was doing.


2
Graphics / Re: Issue with a Y offset on viewport
« on: November 01, 2022, 05:48:06 pm »
Thanks for looking in to this Kojak. I think I understand what the issue would be with the Y position of the quad placement. I am just not sure what you mean by setting the view's Y position. Are you reseting the view position after the viewport has been set?

I have found that setting the center to half of the width and height sets the image in the correct position.

E,g, viewBL.setCenter(sf::Vector2f(280.f, 280.f));

I have attached a screenshot with how it looks now.


3
Graphics / Issue with a Y offset on viewport
« on: November 01, 2022, 03:41:03 am »
I am trying to do something really basic with sf::View.

On a 1280x720 pixel window, I need to place a viewport which is 560x560 with a 160px gap from the top.

What I get is this:

https://imgur.com/a/2zhiV7S

It creates the correct gap length, but it also applies a gap at the bottom

Code I wrote for the viewport:

    int viewport_bl_OffsetX = 0;
    int viewport_bl_OffsetY = 160;
    int viewport_bl_W = 560;
    int viewport_bl_H = 560;

    sf::View viewBL(sf::FloatRect(
        static_cast<float>(viewport_bl_OffsetX),
        static_cast<float>(viewport_bl_OffsetY),
        static_cast<float>(viewport_bl_W),
        static_cast<float>(viewport_bl_H)
    ));

    float viewport_bl_OffsetXRatio = static_cast<float>(viewport_bl_OffsetX) / window_W;
    float viewport_bl_OffsetYRatio = static_cast<float>(viewport_bl_OffsetY) / window_H;

    float viewport_bl_WRatio = static_cast<float>(viewport_bl_W) / window_W;
    float viewport_bl_HRatio = static_cast<float>(viewport_bl_H) / window_H;

    viewBL.setViewport(sf::FloatRect(
        viewport_bl_OffsetXRatio, // 0.00000000
        viewport_bl_OffsetYRatio, // 0.222222224
        viewport_bl_WRatio, // 0.437500000
        viewport_bl_HRatio // 0.777777791
    ));
 

The ratios seem to be correct, but I am not sure why it leaves a gap at the bottom.

Pages: [1]