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

Pages: [1]
1
Graphics / Re: Vertex strange stripes
« on: October 31, 2016, 05:43:58 pm »
Adding "half-pixel" is helping when its not zoomed-out. I guess i can tie it up to zooming, but still, this is not perfect solution.

If it's a precision problem then rounding correctly won't help. Even though i tried rounding all up, rounding all down, and rounding some down and some up it did not help.
The problem is probably in the non-perfect representation of numbers by the float type.

For the record, this is the way i round down:
                        quad[0].texCoords = sf::Vector2f(floor((float)tu *       64 + Fraction), floor((float)tv *       64 + Fraction));
                        quad[1].texCoords = sf::Vector2f(floor((float)(tu + 1) * 64 - Fraction), floor((float)tv *       64 + Fraction));
                        quad[2].texCoords = sf::Vector2f(floor((float)(tu + 1) * 64 - Fraction), floor((float)(tv + 1) * 64 - Fraction));
                        quad[3].texCoords = sf::Vector2f(floor((float)tu *       64 + Fraction), floor((float)(tv + 1) * 64 - Fraction));
 

2
Graphics / Vertex strange stripes
« on: October 30, 2016, 08:25:37 pm »
Welcome!

I'm working on some project.

I wrote this function:

void Display::Draw(unsigned int layer)
{
        for (unsigned int i = 0; i < m_width; ++i)
                for (unsigned int j = 0; j < m_height; ++j)
                {
                        int tileNumber;

                        tileNumber = Map->MapData[i][j].TextureID;

                        int tu = tileNumber % (tilemap.getSize().x / 64);
                        int tv = tileNumber / (tilemap.getSize().x / 64);

                        sf::Vertex* quad = &vertices[(i + j * m_width) * 4];

                        quad[0].position = sf::Vector2f((float)i * 64 - MOVED, (float)j * 64 - MOVED);
                        quad[1].position = sf::Vector2f((float)(i + 1) * 64 - MOVED, (float)j * 64 - MOVED);
                        quad[2].position = sf::Vector2f((float)(i + 1) * 64 - MOVED, (float)(j + 1) * 64 - MOVED);
                        quad[3].position = sf::Vector2f((float)i * 64 - MOVED, (float)(j + 1) * 64 - MOVED);

                        quad[0].texCoords = sf::Vector2f((float) tu * 64, (float)tv * 64);
                        quad[1].texCoords = sf::Vector2f((float)(tu + 1) * 64, (float)tv * 64);
                        quad[2].texCoords = sf::Vector2f((float)(tu + 1) * 64, (float)(tv + 1) * 64);
                        quad[3].texCoords = sf::Vector2f((float) tu * 64, (float)(tv + 1) * 64);
                }

        window->draw(vertices, &tilemap);

}

 

But on some computers a strange thing happens. The file which is held in the tilemap is attached to the post.
(The textures aren't beautiful, so don't judge). The problem are the stripes which are showing (check the attached screenshot). They shouldn't since TextureID contains numbers 0-5.

Why are they showing,
and how to prevent them? 

3
Network / Re: Socket connect max time
« on: February 10, 2016, 05:57:52 pm »
Well, as you can see on the screenshots it takes 0ms to connect. But i tried also version with 1s and 5s

4
Network / Re: Socket connect max time
« on: February 10, 2016, 12:16:29 pm »
Then tell my why it didn't connect.
That's the whole point of this thread.

Why
Quote
socket.connect("127.0.0.1", 1234, Timeout);

this DOES NOT connect to the server. NEVER. (status = Disconnected, remote address = 0.0.0.0)

whereas
Quote
socket.connect("127.0.0.1", 1234);

this DOESconnect to the server. (status = Done, remote address = 127.0.0.1)

5
Network / Re: Socket connect max time
« on: February 09, 2016, 04:57:43 pm »
Whole code:
Server
Quote
#include <SFML/Network.hpp>
#include <iostream>

using namespace std;

int main(){
    sf::TcpListener listener;
    listener.listen(1234);
    sf::TcpSocket client;
    listener.accept(client);
    cout<<"Connected - server"<<endl;
    getchar();
return 0;
}

Client
Quote

#include <SFML/Network.hpp>
#include <iostream>
#include <ctime>

using namespace std;

int main(){
    sf::Time Timeout = sf::milliseconds( 300 );
    sf::TcpSocket socket;
    socket.connect("127.0.0.1", 1234, Timeout);
    clock_t start = clock();
    printf( "It took ms to connect %lu ms\n", clock() - start );
    getchar();

 return 0;
}

It was part of a bigger code, but when i realized that it was not working i removed rest. The basic, which is also shown on the screenshots, still doesn't work.

6
Network / Re: Socket connect max time
« on: February 09, 2016, 12:42:30 pm »
EDIT: Sorry for weird syntax on the screenshots, programming in the morning can end up strange.

Normal connection(to prove i know what i am doing[or at least i think so]):
http://postimg.org/image/o1q9mqzqh/

Default socket.connect( 127.0.0.1, 1234) takes about 1034ms (It's the sf::Time::Zero for my OS) to go to next line of code if the server doesn't exist - which means connection can't be established.

http://postimg.org/image/sgve6a227/
 
But i think the sf::Time::Zero (the 1036ms) is too long. I want to have it set for 300ms. So i used the code below:
Quote
sf::Time Timeout =sf:: milliseconds(300);
sf::TcpSocket socket;
socket.connect( 127.0.0.1, 1234, Timeout );

Problem is simple. The "socket.connect( 127.0.0.1, 1234, Timeout );" never connects to the server.
If i replace it with "socket.connect( 127.0.0.1, 1234)" it does.

http://postimg.org/image/7vvivrf29/

Why the one with "Timeout" doesn't work?


7
Network / Socket connect max time
« on: February 05, 2016, 08:02:38 pm »
I have a problem with setting maximum time for socket to connect.

There is code:
Server
Quote
sf::TcpListener listener;
listener.listen( 1234 );
sf::TcpSocket client;
listener.accept( client );
cout << "Connected" << endl;

Client
Quote
sf::Time Timeout =sf:: milliseconds(300);
sf::TcpSocket socket;
socket.connect( 127.0.0.1, 1234, Timeout );

If I remove the "Timeout" it works fine. It also works fine if i set it to sf::Time::Zero. But the problem is that it's too long.


Pages: [1]
anything