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

Pages: [1] 2 3 ... 9
1
Okay, my bad, I just discovered the error. I looked up the PrintWriter class at the oracle java documentation, and changed it accordingly to the example on the page.
Now it looks like this:
PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
and it works. The strange thing is, that according to my java book, the code I used before should work too.
Anyways, I'm happy that it works now, and thank everyone that helped me with my problem.
Sorry again for bothering you, but I thought that it had to be a problem with SFML or my server program, since I just followed the instructions from my java book :(

2
Honestly, i don't see any data. I read some tutorials and searched for the string, with no result. I will have to have a look on the java code...  :-[

3
Okay, now the server checks whether the connection was accepted, and now I know for sure that the connection was accepted properly.
I installed wireshark, and it shows me six packets exchanged between the client and the server, but honestly I don't know what to do with that information.  :-\

4
Ok, now somehow my SFML server receives some data, although I didn't change anything in my code. But it shows "Error while receiving data", and the char array just contains unreadable characters.

Nevermind, my SFML server doesn't receive any data. "Error receiving data" is shown when I disconnect the client.

5
Network / Re: Help with Java client
« on: January 25, 2015, 04:28:36 pm »
Yes, it should work, shouldn't it? The client successfully connects to my server, but the data isn't received.
And of course I read the tutorials, and I'm sure that I could write a SFML-Client and a SFML-Server that would communicate just fine. But that's not the case here, I try to connect with a client written in Java, which is not using SFML. If someone could point me in the right direction please, It would be very nice :)
Also, as the FAQ states:
Quote
9. When all else fails, you can always come to the SFML forum and ask for help there.
  ;)

6
Network / Re: Help with Java client
« on: January 25, 2015, 02:35:33 pm »
Just to be clear I'm not looking for a java-specific solution. I just want to know how to transfer data between a SFML Server and a non-SFML client.

7
Network / How to transfer data from a non-SFML client to a SFML Server
« on: January 25, 2015, 12:29:46 am »
Im currently learning java, and I'm developing a chat application for android (in java).
The chat application takes a username and text from the user and sends it to a server application on my computer.
The server application is written in C++ with the SFML Network library.

Here's my very simple Server (It's supposed to just write out the sent text at the moment):
#include <SFML/Network.hpp>
#include <iostream>

using namespace std;

int main()
{

    sf::TcpListener listener;
    if (listener.listen(4242) != sf::Socket::Done)
    {
        cerr<< endl << "Error: Couldn't set up TCP listener";
    }

    sf::TcpSocket client;
    listener.accept(client);
    cout << endl <<"New client connected: " << client.getRemoteAddress() << endl;
    char data[100];
    std::size_t received;

    if (client.receive(data, 100, received) != sf::Socket::Done)
    {
    cerr<<endl<<"Error while receiving data";
    }
    else
    cout << endl << "Data received: " << data;


}
 
Here's a snippet of my java code in which the message is being sent:
            try {
                Socket socket = new Socket("192.168.1.126",4242);
                OutputStream out = socket.getOutputStream();

                PrintWriter output = new PrintWriter(out);
                output.println("Hello World!"); // Hello World will be replaced by the actual text message in the future

                socket.close();

            } catch (UnknownHostException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
 

When I run both applications, the phone actually connects to my server, and the server writes "New client connected..." to the console, but I'm unable to send the "Hello World!" text. The server doesn't receive any data.

So my question is: Is it possible that the Server receives the data? And If yes, how can I achieve that and what do I have to keep in mind?

8
Graphics / Re: [Android] SFML Application runs very slow
« on: December 30, 2014, 06:56:18 pm »
@Laurent: Thanks for the tips! I will try to implement them tomorrow.

@Jesper Juhl: I did build them in release mode, but thanks for the answer. I wouldn't have been surprised if I built them in debug mode by accident...

9
Graphics / [Android] SFML Application runs very slow
« on: December 30, 2014, 01:46:37 pm »
A few days ago I compiled SFML 2.2 for Android and already made a few small Apps. Now I'm trying to create something bigger, but there's a problem: The application needs a relatively long time to start up and react, for example when I rotate the phone. I think my phone is fast enough to run the App smoothly( I have an OnePlus One with a Qualcomm Snapdragon 801 and 3GB RAM), and other Apps created with SFML (For example Kroniax) run smoothly. If I compile the code on my PC, it runs fast, so I guess my code is just very resource-heavy.
The following code reproduces the problem:
#include <SFML/Graphics.hpp>

inline void adjustCharacterSize(sf::Text& text, const sf::Vector2u& windowSize, unsigned short factor)
{
        while(text.getGlobalBounds().width < windowSize.x - windowSize.x / factor && text.getCharacterSize() < 500)
                text.setCharacterSize(text.getCharacterSize() + 1);
                 
        while(text.getGlobalBounds().width > windowSize.x - windowSize.x / factor && text.getCharacterSize() > 10)
                  text.setCharacterSize(text.getCharacterSize() - 1);

}


int main(int argc, char *argv[])
{
    sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "", sf::Style::Fullscreen);
    window.setVerticalSyncEnabled(true);

    sf::Font font;
    font.loadFromFile("Lato-Light.ttf");

    sf::Text text;
    text.setFont(font);
    text.setString("Hello World!");
    text.setColor(sf::Color::Green);
    text.setCharacterSize(100);
    adjustCharacterSize(text, window.getSize(), 4);
    text.setPosition(150, 150);

    sf::View view = window.getDefaultView();


    while (window.isOpen())
    {

        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }

            if (event.type == sf::Event::Resized)
            {
                view.setSize(event.size.width, event.size.height);
                view.setCenter(event.size.width/2, event.size.height/2);
                adjustCharacterSize(text, window.getSize(), 4);
                window.setView(view);
            }
        }


        window.clear();
        window.draw(text);
        window.display();
    }
}
 
I already found out that the function  'adjustCharacterSize' seems to be responsible for the slow behavior, but I don't know why. I modified the function several times, but with no success.
Any ideas oft what I could do?

10
General discussions / Re: SFML 2.2 tagged in repository
« on: December 11, 2014, 03:53:13 pm »
Great work guys! I'm really excited about the new features and improvements :) .

Will there be tutorials regarding the Android and iOS app development with SFML on the website?

11
Graphics / Re: sf::Quad Vertex Array Gradient isn't always 'smooth'
« on: November 16, 2014, 05:47:28 pm »
How exactly would you divide the quad?
Because if you subdivide the quad into more quads, every one of the quads will have the seam too, won't they?


12
Graphics / Re: sf::Quad Vertex Array Gradient isn't always 'smooth'
« on: November 16, 2014, 03:55:30 pm »
If you mean to modify the sf::Texture at runtime
Yes, thats what I meant.

Maybe it's a little bit too much to ask for, but isn't there any other solution? Because in my opinion it's not the most elegant way to solve the problem. For example, on the API Documentation Page it says that converting from/to sf::Image is a slow operation, and I will have to do that in every frame, after I've changed the colors of the sf::Image. I think that'll be a problem, especially on mobile devices. :-\

13
Graphics / Re: sf::Quad Vertex Array Gradient isn't always 'smooth'
« on: November 16, 2014, 12:45:47 pm »
@Gambit
What do you mean with the order of the vertices? The vertices are placed in clockwise order, starting in the bottom left corner, and they also change color in that order.

@Nexus
Since I want to port the game for iOS and Android, shaders aren't an option for me, because SFML doesn't support them on mobile devices.
I would use the texture option, but I guess I can't modify the corner colors in the texture, so that the gradient changes it's color, can I?

14
Graphics / sf::Quad Vertex Array Gradient isn't always 'smooth'
« on: November 16, 2014, 11:23:37 am »
Im currently making a Game, where the background should consist of a smooth, color-changing gradient.
In order to achieve that, I have a sf::Quad vertex array, each vertex is positioned in a corner of the window, and the vertices change color. This works pretty well, except that for some reason, sometimes the gradient isn't smooth.
Smooth:

Not Smooth (Ignore the blue fragment in the bottom right corner, my screen capturing program messed that up, I mean the green line which goes from the top right corner to the bottom left):


Why does this happen, and how can I avoid it?

15
General / Re: A few questions regarding Android development
« on: November 02, 2014, 08:43:35 pm »
I still haven't gotten around to trying it myself so I can't give any detailed advice, but I do remember seeing the SFML team create these two potentially useful things:

https://github.com/SFML/SFML/wiki/Tutorial:-Building-SFML-for-Android

https://github.com/SFML/SFML/tree/master/examples/android

Thanks for those links! :)

I tried SFML Android on Eclipse, Code::Blocks and VS2013. The best (for me) is VS + vs-android + visualgdb
visualGDB is commercial but it is worth the money. I'll buy it someday. Note, that using of C::B and VS+vs-android require pretty good knowledge of cross-compiling. It does not use "ndk-build".
Hmm... I'd like to stay with C::B, but If it requires a good knowledge of cross-compiling I guess I will have to switch to Eclipse for my Android projects :D

Pages: [1] 2 3 ... 9