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

Author Topic: circle wiew  (Read 2077 times)

0 Members and 1 Guest are viewing this topic.

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
circle wiew
« on: April 07, 2014, 04:51:47 pm »
How to have a wiev in circle shape?, smth like this:http://i.iinfo.cz/urs/ll4-113213552845883.gif

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10913
    • View Profile
    • development blog
    • Email
Re: circle wiew
« Reply #1 on: April 07, 2014, 05:04:55 pm »
"wiew", "wiev", "smth", ...
I get that English can be hard, but if you spend zero time on writing something, then it makes everyone wonder if you spent the equal "amount" of time thinking about the things you're asking for and besides that, it's quite easy to look up a few things and if you activate spell correction in your browser, things will be even easier. ;)

As for the question, no there are no "circle" views, but you can use a render texture to stance out a part. I've one written an example that shows how this could be done.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: circle wiew
« Reply #2 on: April 07, 2014, 05:17:38 pm »
Or if all you want is a black area around your world you could just load a texture with a transparent circle in the middle and draw that over your world.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: circle wiew
« Reply #3 on: April 07, 2014, 09:11:11 pm »
Thank you, i went through your code, and i tried to create my own much more simpler... surprisingly it doesnt work. (just black screen appears)
sf::Sprite static_background;                                                                           //to put some texture to background(red box in your code)
        sf::Texture tx_static_background;                                                                      
                                                                                                                                               
        if(!tx_static_background.loadFromFile("image.png"))                                    
                return 1;                                                                                                              
        static_background.setTexture(tx_static_background);                                     //     
        //-------------------------------------------------
        sf::RenderTexture tx_transparent;                                                                       //creating texture for the transpaent place + adding circle shape
        tx_transparent.create(60, 60);                                                                          //and other things to texture
        tx_transparent.clear();

        sf::CircleShape shape;                                                                                         
        shape.setFillColor(sf::Color(255, 255, 255, 60));
        shape.setPosition(sf::Vector2f(30.f, 30.f));
        tx_transparent.draw(shape, sf::BlendNone);
        tx_transparent.display();                                                                                       //
        //-------------------------------------------------
        sf::Sprite shape_sprite;
        shape_sprite.setTexture(tx_transparent.getTexture());
    shape_sprite.setPosition(150.f, 150.f);
    shape_sprite.setOrigin(30, 30);
       
        sf::RenderTexture m_layer;
        m_layer.create(300, 300);

        m_layer.clear();
    m_layer.draw(shape_sprite, sf::BlendNone);
    m_layer.display();

        sf::Sprite final_sprite;
        final_sprite.setTexture(m_layer.getTexture());
 
its from beginning main(), do you know where is mistake?
Thanks for help.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: circle wiew
« Reply #4 on: April 07, 2014, 09:57:54 pm »
The clear/draw/display needs to be in a loop so it gets done every frame.  You may want to reread the SFML tutorials.

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: circle wiew
« Reply #5 on: April 08, 2014, 02:59:13 pm »
Ok, no way,it still doesnt work.
But i solved this with the simplest idea -transparent circle shape with black Thickness...
 :D

Doodlemeat

  • Guest
Re: circle wiew
« Reply #6 on: April 10, 2014, 12:28:55 am »
You can render the screen to a RenderTexture and then apply that to a CircleShape. This is far more dynamic than using an image.