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

Pages: 1 2 [3] 4 5
31
System / Re: Absolute Time
« on: September 15, 2015, 06:05:36 pm »
Okay thank you, I'll try to do things differently then.

32
Graphics / Qt & SFML
« on: September 15, 2015, 05:56:03 pm »
Hello,

I am now using Qt and a QPushButton is connected to a function that creates an sf::RenderWindow. It appears that the following line is stalled:

GS::window.create(sf::VideoMode(GS::resWidth, GS::resHeight), "Some Window :D");

I was expecting to see a new window pop up (monitored by SFML) when the QPushButton is clicked, but instead the program fizzles. Is there something I should know about using Qt and SFML together?

33
System / Absolute Time
« on: September 02, 2015, 01:20:22 pm »
Hello,

I would like to measure time non-relatively. This is because two distant computers are going to send timings to each other, and as a result there must be a universal Clock or something that they use to compare those timings. Is there a way to use sf::Clock in an absolute (non-relative) manner? If not, how would you advise me to solve this issue?

Thanks in advance.

34
Network / Re: TCP
« on: September 01, 2015, 02:42:34 pm »
When I was talking of Internet interruption, I meant a duration of ~1/2/10 seconds, not ~1/2/10 minutes.  I suppose an sf::TcpSocket doesn't get disconnected for this kind of short duration.

Thanks everyone.

35
Network / Re: TCP
« on: September 01, 2015, 01:23:14 pm »
Okay so if the recipient lags or is experiencing a short Internet interruption, I can't know that he hasn't received the message yet?

Also, if 10 sf::Packets are sent while the recipient has briefly lost their connection, what would happen when they get it back? Would they receive all 10 sf::Packets in the same order they were sent?

36
Network / TCP
« on: September 01, 2015, 01:04:23 pm »
Hello,

I apologize if my question is dumb (probably is). Suppose I send an sf::Packet through an sf::TcpSocket. How do I know, from the sender's perspective, that the recipient has received the sf::Packet indeed?

37
Graphics / Re: QImage -> sf::Image
« on: August 18, 2015, 04:46:57 pm »
Well the sequence is either RGBRGB... or ARGBARGB..., which are both different from RGBARGBA... used by SFML, so the following won't work / isn't correct:

m_pixels = std::vector<Uint8>(array, array + n);

although it's fast and easy, which is all the more the pity.

Now I wonder if I'd rather make my QImage using the RGB format, then add zeroes in the vector: R, G, B, 0, R, G, B, 0... ; or if I'd rather make my QImage using the ARGB format, then make a lot of swaps so that the sequence becomes RGBA-formatted. Would you have a preference?

38
Graphics / QImage -> sf::Image
« on: August 18, 2015, 04:13:09 pm »
Hey,

I'm trying to convert the pixel array of QImages into the std::vector<Uint8> used by sf::Images. QImages can have many formats, but the two formats I could be using are QImage::Format_RGB32 and QImage::Format_ARGB32.

I was wondering if sf::Images always have the RGBA32 format, or if it's possible to simply use the RGB32 format instead. If that's not possible, the conversion can take much longer.

39
Graphics / Drawing the bullet character in sf::Text
« on: July 20, 2015, 08:23:09 pm »
Hello,

I've been trying to draw a bullet (●) via sf::Texts but every time the result wasn't exactly what I wanted. I am using std::wstrings. I've tried '\x9679', '\x2022' and other characters that I've now forgotten, but each time the bullet was too small, or a white square.

Any help would be very much appreciated  :)

40
Graphics / Re: Wrap & justify sf::Text
« on: July 20, 2015, 08:17:21 pm »
Well luckily I was drawing sf::Texts at a size that was much shorter than what it should have been, so this means I don't have that problem anymore.

The bullet problem remains though, I've tried '\x9679', '\x2022' and other things, but each time I tried, SFML drew a square or a bullet that was too small instead. So I'm open to ideas. I would like to print a big, black bullet like this: ●

Well anyway, this is completely irrelevant to the initial topic, so I'm going to start another thread about it. Thanks for your help.

41
Graphics / Re: Wrap & justify sf::Text
« on: July 19, 2015, 12:18:09 pm »
Well there's a card game whose cards I'm trying to make replicas. Each card has a description inside a box, and my program is supposed to copy/paste the text (found on the Internet) inside the box of a blank card that will hopefully be its exact copy eventually!

But anyways, I've managed to justify the text by splitting it into n one-word sf::Texts! I have another problem though. When a card has a long text, the font size is reduced so that everything can be stored inside the box. My problem is that my sf::Texts with small sizes (the following example is size=9) aren't very good-looking:



The text is:

std::wstring Text = L"&#9679;This text is hard to read.\n&#9679;This text is hard to read.\n&#9679;This text is hard to read.\n&#9679;This text is hard to read.";

And the character that neither the picture nor the code shows is a bullet (which is another problem). Is there a way to smooth texts or something? Thank you for your help so far.

42
Graphics / Re: Wrap & justify sf::Text
« on: July 17, 2015, 06:30:25 pm »
Well I'd rather wait for Laurent's opinion about this, but if there is nothing remotely simple to solve my problem, I think my next question will be "What library do you think I should use?" ^^,

I'm already extensively using SFML for my project, but if there's a library that would solve this fairly easily, I'd rather make another small program and use it along with the rest :)

Edit: or maybe I could cut the n-word sf::Text in n one-word sf::Texts and draw each word where it should be...

43
Graphics / [Solved] Wrap & justify sf::Text
« on: July 17, 2015, 04:24:20 pm »
Hello,

I'm trying to draw an sf::Text inside a rectangle, and I've looked up how to wrap my sf::Text so that it doesn't go out of the rectangle. I found Laurent's post:

Calculating a character position is trickier than just accumulating the glyphs' widths. For this reason, there's a sf::Text::getCharacterPos function which gives you what you want. Call it for every position (from 0 to text size), and when result.x becomes greater than your limit, insert a \n. And start again after the line break.

and my question is: how can I make the sf::Text "justified" inside the rectangle? My first thought was to center it and then scale it horizontally so that it reaches both sides of the rectangle, but it gets more complicated when I'm dealing with a 10-line sf::Text, because every line would need a different scale factor. I would have to split the sf::Text in 10 one-line sf::Texts, but that looks awfully complicated. Not to mention that a scaled sf::Text might not even look aesthetic.

I'm at a loss here. Thank you for your help.

44
Graphics / Re: Best way to use sf::Image and sf::Text
« on: July 17, 2015, 01:03:36 pm »
Thanks!

45
Graphics / Best way to use sf::Image and sf::Text
« on: July 17, 2015, 12:40:41 pm »
Hey,

I'm writing a code that would use several .png files to build an sf::Image from scratch, and at some point I have to add texts on that image. It is my understanding that there's no straightforward way for this, so I was going to actually draw the sf::Sprite then the sf::Text on my sf::RenderWindow, then use the sf::RenderWindow::capture function to get the final image with text on it.

Is this the best way though? I was under the impression that the capture function takes time, and I was hoping to find something more convenient.

Thanks!

Pages: 1 2 [3] 4 5