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

Author Topic: Clipping [VB.NET]  (Read 2536 times)

0 Members and 1 Guest are viewing this topic.

Recoil

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Clipping [VB.NET]
« on: June 19, 2015, 12:22:42 pm »
I am able to draw a sprite to the screen and change the opacity values to look like night and day.  Not I am trying to achieve lighting effects for various sections of the screen that will not be affected by the dark overlay.  I'm trying to determine how I can clip the second sprite with the first CircleShape so I will have a start on a dynamic lighting effect.

Dim tmpLight As New CircleShape(300)
tmpLight.Texture = New Texture(LightGfx)
tmpLight.TextureRect = New IntRect(LightGfxInfo.Width / 2 - 150, LightGfxInfo.Height / 2 - 150, 300, 300)

tmpLight.FillColor = New SFML.Graphics.Color(255, 255, 255, 255) 'CurrLevel)
tmpLight.Position = New Vector2f(0, 0)
GameWindow.Draw(tmpLight)
 

Dim tmpSprite As Sprite
tmpSprite = New Sprite(NightGfx)
tmpSprite.TextureRect = New IntRect(0, 0, frmMainGame.GameScreen.Width, frmMainGame.GameScreen.Height)

tmpSprite.Color = New SFML.Graphics.Color(255, 255, 255, CurrLevel)
tmpSprite.Position = New Vector2f(0, 0)
GameWindow.Draw(tmpSprite)
 

I do not see any way that I am able to clip the Sprite by the CircleShape.  I would really appreciate a suggestion on a method to achieve this.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Clipping [VB.NET]
« Reply #1 on: June 19, 2015, 12:52:05 pm »
SFML doesn't yet support clipping.

However you can use a render texture and blend modes to achieve similar things.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Recoil

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Clipping [VB.NET]
« Reply #2 on: June 19, 2015, 01:28:31 pm »
Thanks for the reply.  I have looked around but am unable to find an example in vb.net of how to apply blend mode.  The closest thing I can get is Blendmode.Add() but I am unable to use this on either the sprite or the circle.

I can find stuff in c++ but nothing for vb.net.  Would you know where an example may be located?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Clipping [VB.NET]
« Reply #3 on: June 19, 2015, 01:34:53 pm »
There are very, very few if any who write things in VB, however since it's .NET the C# code should also help. I'm not familiar with the .NET API, but it should be similar to C++, so you'll have to pass the BlendMode as RenderState when calling draw.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Recoil

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Clipping [VB.NET]
« Reply #4 on: June 19, 2015, 02:16:55 pm »
GameWindow.Draw(tmpLight, New RenderStates(BlendMode.Alpha))
 
That got me the ability to use BlendMode, but the effect is identical to GameWindow.Draw(tmpLight) because my image is a transparent png.

Thanks for the help.  I may have to look into another way to achieve this.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Clipping [VB.NET]
« Reply #5 on: June 19, 2015, 02:32:35 pm »
There are more than just the Alpha blending and yes the alpha blending is the default mode, but there are many more, you just need to play around with them a bit. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/