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

Pages: [1]
1
Network / TCP Connection
« on: August 01, 2016, 01:15:57 pm »
Hi,

Let's assume that two users are connected through a TCP connection, with TCP sockets. During a very short amount of time (like 500 ms), the Internet connection between these two users is cut, for whatever reason. Unfortunately, during that short period of time, each user sent a (different) message to the other, using the TCP connection (sockets) that they set up earlier. When the Internet connection is up again, how will these two messages be handled ? Which one will be processed first, causing one user to get confirmation that their message went through first, before receiving the other user's message ?

Not sure if I'm clear enough, but thanks in advance for your input.

2
Network / [Solved] Compiling code doesn't compile anymore due to g++ update
« on: November 15, 2015, 12:01:14 pm »
Hello,

I'm using Ubuntu 15.04 and was compiling my project fine until today. Yesterday I agreed to run the occasional Ubuntu update and today I rebooted my computer. G++ got updated to 5.1.1 and my code suddenly encounters the following linking problems:

ConnectionInterface.o: In function `ConnectionInterface::ConnectionInterface()':
/home/lol/Documents/Coding/Union/ConnectionInterface.cpp:64: undefined reference to `sf::IpAddress::toString[abi:cxx11]() const'
/home/lol/Documents/Coding/Union/ConnectionInterface.cpp:74: undefined reference to `sf::IpAddress::toString[abi:cxx11]() const'
ConnectionInterface.o: In function `ConnectionInterface::EstablishConnection()':
/home/lol/Documents/Coding/Union/ConnectionInterface.cpp:159: undefined reference to `sf::IpAddress::IpAddress(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
Makefile:211: recipe for target 'Menu' failed
make: *** [Menu] Error 1

Usually when I get this issue, I just delete all .o files and start over, or check that I didn't forget any flag, but this time the problem persists. Any advice? Thanks.

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

4
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.

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

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

7
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  :)

8
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.

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

10
Graphics / sf::Text overflow?
« on: June 12, 2015, 10:30:41 am »
Hello,

it seems that my sf::Text instance won't manage to put its string within its borders. I put its origin at half its width and half its height, then set its position. I also created four 1x1 red dots and set their positions to each (supposed) corner of the rectangle of the text. This way I can visualize the problem more easily. I also created a fifth 1x1 red dot to show where the center/origin of my text is supposed to be.

(click to show/hide)


As you can see, the text is displaced by 1 pixel on the right, and by 7 pixels downwards. I checked everything in my code and nothing explains it. So my question is, is there an option somewhere to "make sure" that the text remains within its borders, or something?

11
Graphics / Basic questions
« on: July 21, 2014, 03:26:33 pm »
Hello,

1. I created a texture and loaded a .png file on it. Then I created a sprite, using the same texture. Now I would like to make my sprite n% transparent, with n between 0 and 100. How do I do?

2. If I want to create a sprite without any file, like a 100-px square, filled in red, how do I do? The only possibility is to actually use a sf::RectangleShape instance?

Thank you.

12
General / Includes and using-namespaces trouble
« on: July 16, 2014, 10:25:31 pm »
Hello,

I cannot compile my project because g++ seems to have a problem with my includes and using-namespaces.

My main file starts like this:

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <deque>
#include <array>
#include <vector>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

using namespace std;
using namespace sf;

class Card;
class Motion;
class Player;

#include "GS.hpp"
#include "Card.hpp"
#include "Player.hpp"
#include "Motion.hpp"
#include "Functions.hpp"
#include "Card.cpp"
#include "Player.cpp"
#include "Motion.cpp"
#include "Functions.cpp"

When I compile my file, I get a bunch of

Code: [Select]
Babel.cpp:(.text+0x1a5): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
Babel.cpp:(.text+0x1ca): undefined reference to `sf::Transformable::setRotation(float)'
/tmp/ccWFVqF0.o: In function `Card::SleeveSet(sf::Texture*)':
Babel.cpp:(.text+0x28e): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
/tmp/ccWFVqF0.o: In function `Card::SetRotation(double)':
Babel.cpp:(.text+0x2ea): undefined reference to `sf::Transformable::setRotation(float)'
/tmp/ccWFVqF0.o: In function `Card::Blit()':
Babel.cpp:(.text+0x305): undefined reference to `sf::RenderStates::Default'
Babel.cpp:(.text+0x312): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
/tmp/ccWFVqF0.o: In function `Card::Scale(double)':
Babel.cpp:(.text+0x36f): undefined reference to `sf::Transformable::setScale(float, float)'
Babel.cpp:(.text+0x38e): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
Babel.cpp:(.text+0x3b3): undefined reference to `sf::Transformable::setScale(float, float)'
Babel.cpp:(.text+0x3f0): undefined reference to `sf::Transformable::setScale(float, float)'
Babel.cpp:(.text+0x40c): undefined reference to `sf::Sprite::setTexture(sf::Texture const&, bool)'
Babel.cpp:(.text+0x431): undefined reference to `sf::Transformable::setScale(float, float)'
[...]

Someone knows how to handle this? Thanks.

13
General / Won't compile
« on: July 10, 2014, 06:47:30 pm »
Hello, here is my very simple file SFML.cpp :

#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>

using namespace std;

int main(int argc, char **argv)
{
    sf::RenderWindow Window(sf::VideoMode(800, 600), "My Window :D");
    sf::Texture Sprite;
    Window.clear(sf::Color::Black);
    Window.display();
    return 0;
}

I try to compile it :

g++-4.8 -std=c++11 -o SFML SFML.cpp -Wall -lsfml-graphics -lsfml-window -lsfml-system

And here is what I get :

/tmp/ccg01oFm.o: In function `main':
SFML.cpp:(.text+0x104): undefined reference to `sf::String::String(char const*, std::locale const&)'
SFML.cpp:(.text+0x155): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
SFML.cpp:(.text+0x182): undefined reference to `sf::Texture::Texture()'
SFML.cpp:(.text+0x19a): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
SFML.cpp:(.text+0x1a9): undefined reference to `sf::Window::display()'
SFML.cpp:(.text+0x1bd): undefined reference to `sf::Texture::~Texture()'
SFML.cpp:(.text+0x212): undefined reference to `sf::Texture::~Texture()'
collect2: error: ld returned 1 exit status

Would you know how to fix this? Thanks.

Pages: [1]