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

Pages: [1] 2
1
General discussions / Re: Is it just me, or SFML is very well written
« on: April 18, 2021, 04:43:56 am »
It's more than the code I'm talking about, the way it's written depends on it's "era", like an old house made of stones, I'm not really looking at the bricks but at the way they fit together. I mean I learnt almost everything I know about coding with sfml, and not just how to write an if or an else, but how it should flow, readability, and ergonomics/flexibility, which, let's be honest here, is something that is lacking in "today's" libraries.

2
General discussions / Re: Is it just me, or SFML is very well written
« on: March 18, 2021, 12:28:44 am »
I'm just amazed by the clarity. Is there a way I can get some information on how Laurent planned the whole thing, or if he kept rewriting almost from scratch once a "new thing" had to be implemented.

there is an almost creative variety of different ways how code can be bad.

I loved that line!

@Nexus do you think SFML is here to stay and will be maintained/upgraded over the years? Some people I talk to believe it's "old" or  "dated" while I can't stop praising it. I just hope it's here to stay, even though I don't have any project ongoing with sfml right now, I wouldn't like it to be gone.

@Samrich just ask, I'll answer asap.

3
General / Re: An internal OpenGL call failed in Texture.cpp(98).
« on: March 17, 2021, 02:53:47 am »
That's an odd one. I tried your code and had no issues

4
General / Re: How to always draw texture in its original resolution?
« on: March 17, 2021, 02:35:37 am »
We might need a bit of your code to see what you're doing with your texture to point you  to the right solution. An sf::View is a good idea, but it really depends on what you want to do with that texture





5
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?

6
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?

7
Graphics / Re: I need help with font.getTexture
« on: May 29, 2020, 09:57:24 pm »
Oh no no no, Laurent, don't get me wrong! My only goal is to interact with the text. I split my string into a vector of chars, then create quads to which I apply the char textures, so I can keep track of positioning of each letters. It's for a text block that can be resized, adjusted/ justified and different style/font/color applied per letter. Since I'm not particularly advanced as a coder, this is what I came up with to do this. Of course, if there's another way to do this, I'd be really happy to know it, or have some pointers since I'm not that advanced on this part of the project, it's always time to get better ideas/take better decisions.

the code I shared here was just to show that I kind of understood the way to take, in no way a real code! Thanks for your help again guys, and amazing job on sfml!

And yeah, for the white dot I kind of figured I didn't apply any coordinates, that was a silly question :/

late edit:

well, it seems that my method is painfully slow, and I over sought the ability to get the position of a char by index in sf::text, that will speed up the whole thing by a very, very large amount. Ahhh, I love sfml!

8
Graphics / Re: I need help with font.getTexture
« on: May 29, 2020, 01:56:29 pm »
just another question, there's a white dot in the top left corner, is there something I should do to get rid of it?

9
Graphics / Re: I need help with font.getTexture
« on: May 29, 2020, 01:32:05 pm »
      sf::Glyph glyph;
      glyph = font->getGlyph(sf::Uint32('a'), size, false);
      TextRaw* newLetter = new TextRaw;
      newLetter->states.texture = &font->getTexture(size);
      newLetter->shapeUpdate();
      add(*newLetter);

that did the job, thanks a lot exploiter !!!

10
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);


11
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!

12
General / Re: creating a click menĂ¹
« on: November 05, 2019, 08:21:06 pm »
you first need to check how events work

https://www.sfml-dev.org/tutorials/2.5/window-events.php

lower in that page, you'll find this piece of code

if (event.type == sf::Event::MouseButtonPressed)
{
    if (event.mouseButton.button == sf::Mouse::Right)
    {
        std::cout << "the right button was pressed" << std::endl;
        std::cout << "mouse x: " << event.mouseButton.x << std::endl;
        std::cout << "mouse y: " << event.mouseButton.y << std::endl;
    }
}

which means: if "right mouse button pressed, do this"

in the place of the "couts", you can add your code to make a "sprite", "rectangle",... appear at the location you wish (event.mouseButton.x, event.mouseButton.y), available from the event itself

sf::Quads is a primitive type, you can create your own shapes with sf::VertexArray, but I advise you to first play with what is already there before diving deeper, it's very complete already!

13
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,...

14
General / Re: I'm having a bit of a delay
« on: November 05, 2019, 08:05:19 pm »
thanks a lot for your answers !

15
General / Re: I'm having a bit of a delay
« on: October 27, 2019, 11:47:46 am »
Thanks for your response, Exploiter .

I'm using the event.mouseMove now, it makes the code look cleaner, but it didn't get rid of the little lag. It's very small though, nothing I can't live with! I'm even wondering if it's not due to the way I translate my vertex arrays somewhere else in the code.

With the mapToPixelCoords, I've just read :

For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor.

does this mean I can retrieve any object under the cursor? I'm using Views and VertexArrays.

If so, I can't really visualize how to get it to do it, newbie here!

Pages: [1] 2
anything