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.


Topics - nfect

Pages: [1]
1
General discussions / Is it just me, or SFML is very well written
« on: March 17, 2021, 12:51:06 am »
So  I learnt how to code with SFML, at the beginning it was hard to make sense of everything, but eventually I got it. After 2 years, the deeper I got into SFML, the more I read the source code, the more I realized how well it was written, elegant and clean. Some months ago I started using another library for an audio project (you may already know what library I'm talking about), and the deeper I get into it, the more awful I find it, it all "works", but it's definitely an awful piece of library, there's as many hurdles as there's after thought, it feels clunky, "fakely" user friendly, cramped and convoluted. There's a too many of everything acting as flexibility, while not enough of simple things that could make it really flexible (unless you  rewrite  yourself the source code). So I'm wondering, is it because I learnt coding with SFML that I find it hard to go deeper in another library, or is SML just as good as I feel it is?

2
Graphics / gl flush issues with font.getTexture
« on: June 29, 2020, 07:42:45 pm »
I'm not sure where it comes from:

An internal OpenGL call failed in Texture.cpp(98).
Expression:
   glFlush()
Error description:
   GL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

I first tried to apply the font texture to the renderstates directly, then I tried to store the texture before applying i, I have no idea what to do so far, any pointer?

3
Graphics / I need help with font.getTexture
« on: May 29, 2020, 04:46:39 am »
Hello, I want to create some kind of a poor man's interactive text editor to include in my project. I started with sf::Text, but it got really really slow. I thought of using font->getTexture and font->getGlyph to get a little more control and cut the middle men.
I couldn't find a way to make it work (most certainly due to my lack of knowledge). font->getTexture always returns me small square. Does it return only the letters that have been used and font->getTexture only shows that?

My goal is to be able to retrieve positioning of the letters and interact with them using a mouse.

exemple code:

sf::RectangleShape shape;
sf::Font newFont;
newFont.loadFromFile("fonts/consola.ttf");
shape.setTexture(&newFont.getTexture(20));
shape.setSize(sf::Vector2f(200, 200));
window.draw(shape);


4
General discussions / Did I say thank you, yet?
« on: November 14, 2019, 02:55:01 am »
Hey guys! It's been some months now that I dived into sfml, I got some struggles there and there, but it's definitely the library you need if you want to learn c++, you can have feedback for everything you try, and this is awesome. You guys did an amazing job, I love EVERYTHING you've done with it, it's 99.5% perfect !! I didn't dare playing with some features yet, but so far, wow. I had fun with vertex arrays, playing with them, adding shaders and what not, I mean, EVERYTHING is possible with sfml, and I just wanted to thank you guys, you guys are pure geniuses. Give me a laptop and sfml, and I will never get bored!

5
General / is there a crop in sfml?
« on: November 05, 2019, 08:11:49 pm »
I was wondering if there was a way to "crop" a group of objects with sfml. I'm using views right now, but it feels a bit awkward and hack-ish. Is there something that works like a view, but can be handled with simple position/size/rotation... instead of %of the screen,...

6
General / I'm having a bit of a delay
« on: October 26, 2019, 04:38:21 pm »
Hello there, I don't know if I'm missing something, is there a slight delay with the Events (Mouse) in SFML?
I have a "View", inside I have a VertexArray, and when I'm dragging it, it do so with a very short delay. I don't know if I'm doing something wrong, I need help!


void Render::mouse_moved(sf::Event event) {

        sf::Vector2i mouse_position = sf::Mouse::getPosition(window);

        if (!is_dragging) {
                int loop = (int)(Sprite::viewer_vector.size() - 1);
                for (int j = loop; j >= 0; j--) {
                        if (Sprite::viewer_vector[j]->mouse_in(mouse_position.x, mouse_position.y)) {
                                if (Sprite::viewer_vector[j] != viewer_interact) {
                                        viewer_interact = Sprite::viewer_vector[j];
                                }
                                break;
                        }
                }
                int loop_in = (int)(viewer_interact->viewer_interactable_vector.size() - 1);
                bool sprite_found = false;

                for (int k = loop_in; k >= 0; k--) {
                        if (viewer_interact->viewer_interactable_vector[k]->mouse_in(mouse_position.x, mouse_position.y)) {
                                if (viewer_interact->viewer_interactable_vector[k] != sprite_interact) {
                                        if (sprite_is_over) {
                                                sprite_interact->on_out();
                                        }
                                        sprite_interact = viewer_interact->viewer_interactable_vector[k];
                                        sprite_interact->on_over();
                                        sprite_is_over = true;
                                }
                                sprite_found = true;
                                break;
                        }
                }
                if (!sprite_found) {
                        if (sprite_is_over) {
                                sprite_interact->on_out();
                        }
                        sprite_is_over = false;
                        sprite_interact = NULL;
                }
        }
        else {
                sprite_interact->drag(mouse_position.x,mouse_position.y);
        }
}

void Sprite::drag(float v1, float v2) {

        set_color(255, 255, 0, 255);

        if (!dragging) {

                x_move = v1 - x();
                y_move = v2 - y();
                dragging = true;

        }

        x(v1-x_move);
        y(v2-y_move);

        //std::cout << name << " start dragging" << std::endl;

}

 

I believed I used the shortest way to get this done, but I still have some delay

7
General / I can't get custom shapes to work
« on: May 27, 2019, 05:22:54 pm »
I found some examples of roundedrectangles/elipses, yet I can't get them to work. Build is fine with no errors, yet ".draw" shows nothing :/ It's been 3 days I'm trying to get it to work, and since I'm a total newbie, it feels like I can't pin point what I'm doing wrong.

https://github.com/SFML/SFML/wiki/Source%3A-Draw-Rounded-Rectangle

here's the example I tryed, and for the elipses:

https://www.sfml-dev.org/tutorials/2.0/graphics-shape.php

With the first example, I create an hpp, and a cpp, copy and paste, create a new shape in the int main, ask to draw it, and nothing appears. I'm lost :/

I even tryed replacing the end of the code by the code from the original rectangleshape, and it works .

// this does not work, draw shows me a shape
    if(index >= myCornerPointCount*4)
        return sf::Vector2f(0,0);

    float deltaAngle = 90.0f/(myCornerPointCount-1);
    sf::Vector2f center;
    unsigned int centerIndex = index/myCornerPointCount;
    static const float pi = 3.141592654f;

    switch(centerIndex)
    {
        case 0: center.x = mySize.x - myRadius; center.y = myRadius; break;
        case 1: center.x = myRadius; center.y = myRadius; break;
        case 2: center.x = myRadius; center.y = mySize.y - myRadius; break;
        case 3: center.x = mySize.x - myRadius; center.y = mySize.y - myRadius; break;
    }

    return sf::Vector2f(myRadius*cos(deltaAngle*(index-centerIndex)*pi/180)+center.x,
                        -myRadius*sin(deltaAngle*(index-centerIndex)*pi/180)+center.y);

// this does

    switch (index)
    {
        default:
        case 0: return Vector2f(0, 0);
        case 1: return Vector2f(mySize.x, 0);
        case 2: return Vector2f(mySize.x, mySize.y);
        case 3: return Vector2f(0, mySize.y);
    }

Pages: [1]