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 - 7ark

Pages: [1]
1
Graphics / Re: Outline Shader Not Working Outside Sprite Bounds?
« on: March 18, 2018, 02:33:54 am »
The shader is applied to every pixel that is covered by the shape but nothing outside of that. A sprite, then, is simply a (transformed) rectangle and the shader will only apply within that  (transformed) rectangle. To have a shader affect a larger space, you can use a larger object or maybe apply the shader to the entire window via a render texture (post-fx), for example.

Hm, alright thanks.

2
Graphics / Outline Shader Not Working Outside Sprite Bounds?
« on: March 17, 2018, 11:13:30 pm »
Maybe I'm doing something wrong, or maybe this is intended? I'm fairly new to using SFML, and I've made a system for adding shaders to my objects. I haven't noticed until now, but I've added an outline shader to a sprite whose texture doesn't have much transparent space around it, unlike the previous sprites I had used the shader on.

Well the outline doesnt actually get applied to any part that the sprite bounds aren't apart of. So the only transparent space in the texture is the corners (its a button with rounded corners), and so clearly thats not what I wanted.
I don't do a ton with shaders normally, and I just started using SFML. So I'm not sure if this is normal, or if there's a way to fix it?

3
Graphics / Re: Detecting Mouse Inside Sprite
« on: March 01, 2018, 04:52:15 pm »
Since you modify the view, the screen to world space mapping isn't 1:1, thus you need to use mapPixelToCoords to get the mouse coordinates in world space.

Yeah, I actually ended up doing that without it working still. Found out the way I'm dealing with my transform is the problem. I have a sf::Transform on my Object class, which calls the renderer.draw(sprite, transform). So even tho I was scaling my object, the actual script size isn't actually smaller. So I need to find some way of actually changing the sprite.

4
Graphics / Detecting Mouse Inside Sprite
« on: March 01, 2018, 05:31:55 am »
Hello, I recently started using SFML, not new to programming, though it's been a few months since I've used a lot of C++.

Trying to detect if the mouse pointer is within the bounds of a sprite, and I cannot seem to get it right. I have a custom view setup just like this
Code: [Select]
mainView.setSize(sf::Vector2f(GameSettings::width, GameSettings::height));
mainView.setCenter(sf::Vector2f(0, 0));

I have a GameObject class and such which contains a sprite, whose position is set in the constructor. In my main loop I'm updating a static reference to a sf::vector3f for the mouse position which I get with sf::Mouse::getPosition(window);

So later I attempt to determine if the mouse pointer is within the area of the sprite, but I've been having trouble getting it to detect correctly.
I am doing this
Code: [Select]
if (gameObject->GetSprite().getGlobalBounds().contains(Game::MousePosition()))
Where it gets the sprite, and Game::MousePosition() returns that mouse position from earlier.

I'd appreciate any help, thanks!

Pages: [1]
anything