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

Pages: [1] 2
1
Window / Re: simulating mouseClick
« on: January 22, 2024, 10:41:39 am »
thank you very much for your comment.
I did not understand your question "How is the mouse simulated?"
I thought "mouse simulated" means using relevant function. In my case Mouse::isButtonPressed

From your question I suspect that apart from using  function like Mouse::isButtonPressed or event, mouse simulation requires more than just using function or event - is this the case?

PS. I tried to use C++ built-in function GetAsyncKeyState(). For some reason it even in the simplest test-code for Left Click like

int main()
{
   Sleep(100);
   if(GetAsyncKeyState(0x01))
        {
                cout<<"mouse"<<endl;
        }
}
 
it behave not as expected (no mater which integer I put inside  Sleep();
But for the Right button GetAsyncKeyState(0x02) works fine

2
Window / simulating mouseClick
« on: January 20, 2024, 07:48:53 pm »
I am trying to develop an application to work with the mouse coursor controlled by laser pointer (a webcam scanning the screen, a program scanning frames in search of laser dot, calculates its coordinated and simulates mouse click in these coordinates).

I am coding it in MSVS Community 2019 C++ and SFML.
One of the things I am trying to do is to place a sprite (just a red circle) into a certain place (x,y) which is different for every click using:

if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
        {
                spriteSircle.setPosition(x, y); //x and y are calculated earlier in the program
        }

To simulate mouseClick the laser pointer is set to generate a short (50 msec) laser pulse.

With the standard mouse it works fine.
Yet with  the laser pointer two things do happen very often:
1. It misses laser clicks
2. It places the red circle at the coordinates of the PREVIOUS place. I.e. where it should have been places at the previous click

Where might be the error? It might be with the program which scans the frames and simulates the mouseclick, but I have no access to its code, and therefore need to make sure that the problem is not in my code.

3
General / Re: "SFML Works!" test code using Class
« on: December 19, 2021, 03:29:15 pm »
I see now. Creating window in Windows native way is big pain indeed. Thanks again for the most professional aid

4
General / Re: "SFML Works!" test code using Class
« on: December 19, 2021, 01:47:49 pm »
Thank you very much. The link to C++ tutorials will certainly be of help. Now I see that things changed since I last used C++. Till now I have not come across the term "operating system window". Against  this term Google returns plenty of links to articles about operating system Windows but none about its meaning in this here context

5
General / Re: "SFML Works!" test code using Class
« on: December 19, 2021, 10:32:17 am »
Thank you, kojack, for taking time to write the detailed explanation. Impressed with the depth of your knowleadge.
Actually I suspected that something wrong was with the line you pointed at:
Quote
sf::RenderWindow mWindow(sf::VideoMode(640, 480), "SFML Application");

Using sf::RenderWindow both inside class definition and outside it might be confusing for compiler. The reason I had to use it outside class definition was:

In Game Class two private members were declared the same way:
Quote
private:
    sf::RenderWindow mWindow;
    sf::CircleShape mPlayer;

However initializing the second member
Quote
mPlayer.setRadius(40.f);
worked, while similar initializing the first member
Quote
mWindow(sf::VideoMode(640, 480), "SFML Application");
generated an error
Quote
no match for call to '(sf::RenderWindow) (sf::VideoMode, const chat[17])'
Why didn't it work and why it required calling "create", while similar declared mPlayer worked without "create"?

6
General / Re: "SFML Works!" test code using Class
« on: December 18, 2021, 02:30:58 pm »
Thank you, this is a great relief!
I tried to modify it to look more familiar to me:
Quote
Game::Game()
{
   sf::RenderWindow mWindow(sf::VideoMode(640, 480), "SFML Application");
   //{mWindow(sf::VideoMode(640, 480), "SFML Application"); this cause error no match for call to '(sf::RenderWindow) (sf::VideoMode, const chat[17])'
    mPlayer.setRadius(40.f);
    mPlayer.setPosition(100.f, 100.f);
    mPlayer.setFillColor(sf::Color::Cyan);
};
The other functions copied from the book:
Quote
void Game::run()
{
    while (mWindow.isOpen())
    {
        processEvents();
        update();
        render();
    }
}

void Game::processEvents()
{
    sf::Event event;
    while (mWindow.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            mWindow.close();
        }
}

void Game::update()
{
}

void Game::render()
{
    mWindow.clear();
    mWindow.draw(mPlayer);
    mWindow.display();
}

int main()
{
    Game game;
    game.run();
    return 0;
}
It compiles and runs with no errors yet it just flashes for a split second that 640x480 window with white background and no circle.
What I am missing?

7
General / "SFML Works!" test code using Class
« on: December 18, 2021, 12:23:34 pm »
I am trying the book SFML Game Development recommended on www.sfml-dev.org/learn.php
They start with the classic "SFML Works!" test code, but do it using Class:
Quote
class Game
{
 public:
    Game();
    void run();
 private:
    void processEvents();
    void update();
    void render();
 private:
    sf::RenderWindow mWindow;
    sf::CircleShape mPlayer;
};

So far so good. But the following definition of Game() constructor, I cut and copy it here:

Quote
Game::Game()
: mWindow(sf::VideoMode(640, 480), "SFML Application")
, mPlayer()
{
 mPlayer.setRadius(40.f);
 mPlayer.setPosition(100.f, 100.f);
 mPlayer.setFillColor(sf::Color::Cyan);
}
I learned C++  in 1998 using "How to programm C++" by H.M. and P.J. Deitel and this syntax puzzles me. Is this a new version C++ or just slip of pen? Anyway, as is it would not compile.

8
General / Re: libstdc++-6.dll and libgcc_s_seh-1.dll are not found
« on: December 14, 2021, 03:15:08 pm »
thank you. I will follow your advice

9
General / Re: Process terminated with status -1073741510
« on: December 14, 2021, 03:13:50 pm »
Thank you. Actually I suspected something like that and before posting my question here,  googled "status -1073741510". It returned several links all saying about  some run-time error. I did not realised that 1073741510 is the same as 0xC000013A

10
General / Re: libstdc++-6.dll and libgcc_s_seh-1.dll are not found
« on: December 14, 2021, 03:04:16 pm »
Thank you.
If I build it in static mode, will it work on its own?

11
General / Process terminated with status -1073741510
« on: December 12, 2021, 04:52:34 pm »
Hallow Words build and runs OK, but after closing it down a message in red is appended to the log:
Process terminated with status -1073741510 (0 minute(s), 15 second(s))

What is status 1073741510?

12
General / libstdc++-6.dll and libgcc_s_seh-1.dll are not found
« on: December 12, 2021, 04:48:52 pm »
I set up CodeBlocks with SFML to use dynamic libraries. After building and running HallowWord it created bin folder with debug folder in it, but no release folder - should it be like that?
Although from IDE it runs OK, but the exe file genereated in bin/debug  keeps saying that  libstdc++-6.dll and
libgcc_s_seh-1.dll  are not found  - is this normal?

13
General / Re: Build fails; 'undefined reference to..'
« on: December 12, 2021, 04:39:59 pm »
Is there anything that is not actually explained in the tutorial? If so I'd be glad to add it.

If you mean https://www.sfml-dev.org/tutorials/2.5/start-cb.php then indeed it wants adding in.
For example itn says:
-------
There are multiple variants of GCC for Windows, which are incompatible with each other (different exception management, threading model, etc.). Make sure you select the package which corresponds to the version that you use.
----------
Does this mean SFML version should match Code::Blocks version. If so would you add more detail on this?

14
General / Re: how to select SFML version to match CodeBlocks version
« on: November 22, 2021, 06:29:47 pm »
Thank you very much. Now I have solid understanding, not a guesswork!

15
General / Re: how to select SFML version to match CodeBlocks version
« on: November 22, 2021, 05:51:52 pm »
does version 8.1.0 refers to 810 in the filename of SFML you refered me to?

Pages: [1] 2
anything