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

Pages: [1]
1
Network / SFML TCP as server for MUD
« on: September 06, 2019, 08:12:44 pm »
Hello,

I want to make MUD (Multi User Dungeon) game and looking for best library for networking. The game would be text based RPG, without any heavy graphics, but with expanded command system, lot of items etc. World will be built from "rooms", each room has 4 possible exits, connected with other room. Is choosing SFML good option? Can it handle multiple connections at the same time and will it be hard to make such server with barely no experience?

2
Window / Combining multiple windows
« on: May 29, 2019, 11:33:14 am »
Hello, I am making a program which is a physical simulation. I would like to have big lattice with atoms, next to it, on right - plots and charts and on left - sliders and buttons with options. I am wondering if I can make 3 different classes, which contains separate windows and than just combine them with single, one, big window? Or maybe there is a better solution for that?

EDIT: Just found views tutorial - is it a correct way to do that?

3
Network / Re: Web interface for C++ application
« on: November 09, 2018, 08:40:41 am »
Thank you

4
Network / Re: Web interface for C++ application
« on: November 08, 2018, 09:30:29 pm »
So you think it should be better to use some other library?

5
General / Re: [Visual Studio] don't have SFML in #include
« on: November 07, 2018, 10:44:25 pm »
Check if you have right platform Debug/Release as well as 32/64-bit. Probably you configured it for some other options than you are trying to use. You can put us some screenshots from Properties to check

6
Network / Web interface for C++ application
« on: November 07, 2018, 10:34:15 pm »
Hello. I have a program written in C++, but at this moment it works in console. I was using SFML for making graphic interface previously, but this time I want to try something new. My program is suppose to work on embedded system (like Raspberry Pi), so I won't have display screen for it. Instead of that, I wanted to make some web browser interface for it. User has to type Raspberry Pi IP in own browser, along with port (for example 192.168.48.5:8888) and than he should see the simple interface (not much, just a few buttons). After clicking button, certain things should happen in C++ program. Am I able to achieve that with SFML? Where should I search? Is it CGI/REST API?

Example: UV4L with it's webRTC server (it has interface I am looking for - https://i.stack.imgur.com/w5Yhz.png?fbclid=IwAR1UexTVjdM8rDe5O8apC6_lULzVMJsT9rL1qDk9mAjyEPqnVOFvBjZ5PyA)

Thanks for help

7
General / SFML as overlay for other window
« on: May 27, 2018, 04:12:10 pm »
Hello. I working on project, where I have some OpenCV window with transforms, draws etc. Is there an option to "embedded" this window into SFML project, so it would looks like an overlay?

8
Network / Re: UDP Socket does not connect
« on: March 10, 2018, 11:40:17 am »
Oh, you are right, my bad. But even in this way, application never get packet. It is send from PC, but on Rpi there is always NotReady, and never Done. Something like it lost package meanwhile.

EDIT: I think I got it:

PC:
#include <SFML/Network.hpp>
#include <iostream>

int main() {

        sf::UdpSocket socket;
        socket.setBlocking(false);

        sf::Packet packet;
        sf::String command = "write";
        sf::Uint16 pin = 23;
        sf::Uint16 value = 0;

        packet << command << pin << value;

        sf::IpAddress recipient = "192.168.1.102";
        unsigned short port = 54000;

        while (1) {
                packet.clear();
                packet << command << pin << value;
                if (socket.send(packet, recipient, port) != sf::Socket::Done)
                {
                        std::cout << "Some error" << std::endl;
                }
                else {
                        std::cout << value << std::endl;
                        if (value < 10) {
                                value++;
                        }
                        else {
                                value = 0;
                        }
                       
                }
        }

                system("PAUSE");

        return 0;
}

Rpi:
#include <SFML/Network.hpp>
#include <SFML/Network.hpp>
#include <iostream>

int main() {

        sf::UdpSocket socket;
        socket.setBlocking(false);

        if (socket.bind(54000) != sf::Socket::Done)
        {
                std::cout << "Cannot bind socket" << std::endl;
        }

        sf::Packet packet;
        sf::IpAddress remoteIP;// = "192.168.1.100";
        unsigned short remotePort;// = 54000;
       
        while (1) {
                auto status = socket.receive(packet, remoteIP, remotePort);
                if (status == sf::Socket::Done){
                        std::cout << "Got it" << std::endl;
                        sf::String command;
                        sf::Uint16 pin;
                        sf::Uint16 value;

                        packet >> command >> pin >> value;
                        std::cout << remoteIP  << ": "<< "Command: " << command.toAnsiString().c_str() << " " << pin << " " << value << std::endl;
                }
                else if (status == sf::Socket::NotReady){
                        std::cout << "No data" << std::endl;
                }
        }


        return 0;
}

 

Does remoteIP and remotePort has to be empty?

9
Network / UDP Socket does not connect
« on: March 10, 2018, 12:03:10 am »
Hey, I want to send some packet which contains: command, pin number and value from my PC to Raspberry Pi via UDP. I made this code:

PC:
#include <SFML/Network.hpp>
#include <iostream>

int main() {

        sf::UdpSocket socket;
        socket.setBlocking(false);

        sf::Packet packet;
        sf::String command = "write";
        sf::Uint16 pin = 23;
        sf::Uint16 value = 0;

        packet << command << pin << value;

        sf::IpAddress recipient = "192.168.1.102";
        unsigned short port = 54000;

        while (1) {
                if (socket.send(packet, recipient, port) != sf::Socket::Done)
                {
                        std::cout << "Couldn't send" << std::endl;
                }
                else {
                        std::cout << value << std::endl;
                        value++;
                }
        }


        return 0;
}

Rpi:
#include <SFML/Network.hpp>
#include <iostream>

int main() {

        sf::UdpSocket socket;
        socket.setBlocking(false);

        if (socket.bind(54000) != sf::Socket::Done)
        {
                std::cout << "Cannot bind socket" << std::endl;
        }

        sf::Packet packet;
        sf::IpAddress remoteIP = "192.168.1.101";
        unsigned short remotePort = 54000;
       
        while (1) {
                if (socket.receive(packet, remoteIP, remotePort) == sf::Socket::Done) {
                        std::cout << "Got it" << std::endl;
                        sf::String command;
                        sf::Uint16 pin;
                        sf::Uint16 value;

                        packet >> command >> pin >> value;
                        std::cout << "Command: " << command.toAnsiString().c_str() << " " << pin << " " << value << std::endl;
                }
                else if (socket.receive(packet, remoteIP, remotePort) == sf::Socket::NotReady) {
                        std::cout << "Some error while recieving" << std::endl;
                }
        }


        return 0;
}
 

But I have some error while running both programs, cause it says packet is sent from PC, but it's still "Some error while recieving" on Rpi. What thing I failed and missunderstand?

10
Graphics / Re: Problem with text
« on: June 19, 2017, 08:33:06 pm »
Thank you so much. Didn't realise I am out of window

11
Graphics / Problem with text
« on: June 19, 2017, 06:48:33 pm »
Hey. I have a code:

Quote
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include <iostream>

using namespace sf;
int main()
{
   
   sf::RenderWindow window(sf::VideoMode(320, 240), "Font Test");
   Font font;
   font.loadFromFile("ditr.ttf");
   Text text;
   text.setFont(font);
   text.setString("Hello World");
   text.setFillColor(Color::Red); //Maybe a color
   text.setCharacterSize(24);

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

      }
      text.setPosition(250, 250);
      window.clear(Color::White);
      window.draw(text);
      window.display();
   } //while
   return 0;
}

But when I compile, I have a white screen, without text. Can you tell me why?

12
General / Re: Working in console, showing in window
« on: June 11, 2017, 07:01:03 pm »
So using getch and kbhit I would be able to write in console, then work on this data and send them to window display? Can you give me small example?

13
General / Re: Working in console, showing in window
« on: June 11, 2017, 11:51:24 am »
The problem is that it has to be "system console" as itself, not other windows which looks like that. I have to have the general program in console and the window has to be only for graphic display, so I think I can't use SFML window as main loop of my program. I think I will use threads then. Thanks for replay

PS. I am usind PDCurse for console, not cout/cin

14
General / Working in console, showing in window
« on: June 10, 2017, 11:39:16 pm »
Hello,

I just started to learn SFML and have to do a project for my university. The task is to work with console and SFML window at the same time, using object orientated C++. For example I want to have menu in my console:

1. Draw circle
2. Draw rectangle
...

And when I type 1 in console, the SFML window updates and show circle. I don't know how to achieve that, because in every course of SFML I saw while loop for displaying window. It prevents from using console, unless I close the window. I need them both opened. I have two classes:

Scheduler -> while loop for taking numbers from console
SFMLWind -> for displaying the primitive in window

But I totaly don't know how to connect them to work simultanously. Can you show me the way? What I need to learn?

EDIT:

I've heard about threds - do I need them here?

Pages: [1]