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

Pages: [1]
1
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.

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

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

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

5
General / how to select SFML version to match CodeBlocks version
« on: November 22, 2021, 10:59:42 am »
The SFML set up instructions (https://www.sfml-dev.org/tutorials/2.5/start-cb.php) stresses the importance of correct selection of SFML version to match that of CodeBlocks, but does not offer clear guidince for that.

Indeed the last thing we want is the setup will start failing on certain projects because of non-compatibility of SFML and CodBlocks versions.
 
On https://youtu.be/8aQdx40KeHw?t=45  a Russian chap sugests that the correct version of SFML should match two dll files in Program Files\CodeBlocks\MinGW\bin:

libgcc_s_dw2-1.dll
libgcc_s_sjlj-1.dll

If you have just libgcc_s_dw2-1.dll than download DW2 version
If you also have libgcc_s_sjlj-1.dll then doen load SJLJ version

Is this correct?
If it is, will also be correct to download the SEH version if I donot have libgcc_s_dw2-1.dll or libgcc_s_sjlj-1.dll, but have  libgcc_s_seh-1.dll (I have CodeBlocks version 20.03

6
General / Event handling
« on: September 30, 2019, 08:25:26 pm »
Using CodeBlock compiled the following code to test the idea:  on mouse Click move a red dot to the cursor:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(1024, 768), "Test");
    sf::RectangleShape bullet(sf::Vector2f(5.0f, 5.0f));
    bullet.setFillColor(sf::Color::Red);

    while (window.isOpen())
    {
       sf::Event event;
       while (window.pollEvent(event))
       {
            if (event.type == sf::Event::Closed)
                window.close();
       }
        if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
        {
            sf::Vector2i mousePos = sf::Mouse::getPosition(window);
            bullet.setPosition((float) mousePos.x, (float)mousePos.y);
        }
        window.clear();
        window.draw(bullet);
        window.display();
    }
    return 0;
}

It works fine with the mouse on Win XP, 7, 8 and 10.

However the final objective is to make a program which could be controlled on a big screen with a laser pointer. To this end a web camera is used for which a program is written in C# using NET Framework 4.5. This program receives frames from the webcam, locates a laser dot and emulates mouse click event.

On Windows XP, 7 and 8  this works fine. However on Win 10 it does not. It moves the cursor to the laser dot, yet does not move the red dot as if the mouse click event does not come through.

Other standard Windows applications like Paint or Windows Explorer react to the laser beam properly therefore the problem seems to be in misunderstanding between my SFML code and Windows-10.

What could be wrong?

7
General / LNK2019 unresolved external symbol....
« on: September 30, 2019, 04:52:12 pm »
Hi, colleagues,
Four year ago there was a thread here  "Unresolved External Symbol" (https://en.sfml-dev.org/forums/index.php?topic=14715.0) which remains unresolved.

Trying to set up Visual Studio 2015 to work with SFML I run into  similar problem

In my 64 bit  Win 7 ultimate SP 1 I have: 

Visual Studio Community 2015   Version 14.0.25431.01 update 3.
It does not say if it is 86 or 64 but was installed from
en_visual_studio_community_2015_with_update_3_x86_x64_web_installer_8922963.exe
and says that it includes Visual C++ 2015 00322 20000 00000 AA787

SFML 2.5.1 for  Visual C++ 14 (2015) - 64-bit   downloaded from  www.sfml-dev.org/download/sfml/2.5.1/

I did and checked twice all the settings for the static version as prescribed at www.sfml-dev.org/tutorials/2.5/start-vc.php
I set Debug and Release for x64

Yet the sample code shown at www.sfml-dev.org/tutorials/2.5/start-vc.php  returns a bunch of errors "LNK2019 unresolved external symbol....." all referring to the first line of the code which is
#include <SFML/Graphics.hpp> 
and blaming symbols like gkBlendFunc, glClearColor etc from files sfml-graphics-s-d.lib, sfml-window-s-d.lib and sfml-system-s-d.lib,

Obviously VS finds and opens necessary libraries yet does not understand them.

In that old thread mentioned one of the suspects was C++ compiler which in VS10 was 32bit

How shall I find out if C++ compiler  in my  VS-2015 is 32 or 64?
if it is 64 what could be other possible reasons for errors?
Do I have incompatible version of VS and SFML? Or my setting in VS are wrong?

8
General / attchaching on object to another as a child on mouseClick
« on: September 27, 2019, 05:57:10 pm »
I  need to make a shooting simulator similar to this one made in Flash: http://igroflot.ru/shot/flash_game_50/

When mouse is pressed a bullet hole is placed on the target at the coursor coordinates. I guess these a local target coordinates and the bullet hole object becomes a child of the target object so that if the target moves or scales, the hole moves and scales with the target.

Also the points score is returned and its value depends on the hit zone of the target.
In Flash this is done by assembling the target of concentric circles each beeing a sepatate object with its points value and listening for onPress event (mouse click) which calls a function placing the bullet hole and returning the points.
In Flash when several objects, listening onPress event are placed one on top another, only the upper one reacts and stops event from propagating downwards.

I am trying to select a right tool to repeat this without Flash.
Can this approch be implemented in  C++ and SFML? I have SFML installed as well as Code Blocks C++ and Viasual Studio,  I looked through a number of tutorials, but still not sure if C++& SFML would be the right choice.

A founded opinion will be appreciated

Pages: [1]