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

Pages: [1]
1
Window / Re: Mouse and keyboard at the same time
« on: August 24, 2014, 12:39:16 am »
I haven't tested other systems, but same bug was with windows' getAsyncKeyState, so hardware is probably problem. I'm using ASUS G750JX, win8 and latest drivers. I'll test with a hardware mouse soon, as this could be a trackpad button bug.

E: Yup, It's HW/Driver bug. Plugging in external mouse solved issue.

2
Window / Re: Mouse and keyboard at the same time
« on: August 24, 2014, 12:26:04 am »
Sorry for vague description. So when I press keyboard button, mouse button state is always false. If I press mouse button, and then keyboard button, both are true and work normally. Also, if I press keyboard button, then release it, and right after releasing the button press mouse button, mouse button doesn't trigger until around 1sec has passed from releasing keyboard button.

Here is the most minimal code, that will reproduce the problem:
#include <iostream>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Keyboard.hpp>


int main()
{
        while (true)
    {

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
                        std::cout <<"KB\n";    
                }

                if(sf::Mouse::isButtonPressed(sf::Mouse::Left)){
                                std::cout << "MB\n";
                }
                       
        }
       
        return 0;
}

 

In the code, keyboard button w and LMB are used.

3
Window / Mouse and keyboard at the same time
« on: August 23, 2014, 11:53:54 pm »
I have this outside event loop:

if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)){
                                shotInitialize(player);
                }

                //Reasons for keycodes are in fhe function movePlayer
                keyPress = 0;
                                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
                                        keyPress = keyPress + 1;
                                }
                                if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)){
                                        keyPress = keyPress + 2;
                                }
                                if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)){
                                        keyPress = keyPress + 8;
                                }
                                if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
                                        keyPress = keyPress + 4;
                                }


                       
               
                //Clear previous render
                window.clear();

                movePlayer(player, keyPress);
                shotUpdate(player, window, spriteContainer);
                spriteContainer.Player.setPosition(player.positionX, player.positionY);
                spriteContainer.Player.setRotation(player.rotation);
                window.draw(spriteContainer.Player);


                //Display new render
        window.display();

But for some reason, when mouse button is pressed while, or right after keyboard button is pressed, it won't do anything. This is quite annoying, since this prohibits real time input. Could someone tell me how could I make keyboard states not interfere with mouse buttons etc?

4
C / Re: SFML sprite crops for some reason
« on: June 27, 2014, 08:03:11 am »
I banged my head for a while, and rewrote that exactly the same code, and found out, that there was an option bool resetRect = false, which probably was the reason it cropped parts of the image, since when I changed the code to:

//........
//Problem somewhere near here.
                texture.loadFromImage(MB, sf::IntRect());
               
                sprite.setTexture(texture, true); // <-- Here the problem was
//....

And the croping was no more. So there was only one boolean that I forgot, typical mistake, sorry for your inconvenience, and thank you.

5
C / SFML sprite crops for some reason
« on: June 26, 2014, 10:45:00 pm »
I have small code to render Mandelbrot set. The actual set rendering, and image are correct (I saved it on HDD, and it displayed correct). My problem however is, that for some reason, when resizing window, the image behaves weirdly. Firstly if I do nothing with the scale (which should be automatic if I understand correctly), the image scales different rate than window (although a new image has been generated to match the new window size). If I do handle the scale, bottom part and left side of the set is cropped out as black (if I save the image, the bottom part is there). What am I doing wrong?


Main file, where pretty much everything happens:
int main()
{
        int windowWidth = 1500, windowHeight = 800;
        sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), "Mandelbrot");
        window.setFramerateLimit(60);

       
        sf::Texture texture;
        std::cout << "create MB \n";
        sf::Image MB = createMBPicture(windowWidth, windowHeight);
       
       



        texture.loadFromImage(MB, sf::IntRect());

        sf::Sprite sprite;

        sprite.setTexture(texture);
        int i = 0;
    while (window.isOpen())
    {
               

        sf::Event event;

        while (window.pollEvent(event))
        {

            if (event.type == sf::Event::Closed)
                window.close();
                        if (event.type == sf::Event::Resized){

                                windowWidth = event.size.width;
                                windowHeight = event.size.height;
                                std::cout << "W: " << windowWidth << "H: " << windowHeight << " \n";
                               
                                MB = createMBPicture(windowWidth, windowHeight);
                                MB.saveToFile("E:\\Mandelbrot.jpg");
                                //Problem somewhere near here.
                                texture.loadFromImage(MB, sf::IntRect());
                               
                                sprite.setTexture(texture);


                               
                                sprite.setScale(1500.0f/(float)windowWidth, 800.0f/(float)windowHeight); //Scaling handling here
                                std::cout << "W: " << sprite.getScale().x << "H: " << sprite.getScale().y << " \n";
                               

                        }
        }

        window.clear();

                window.draw(sprite);

        window.display();
    }

    return 0;
       
}

 

Pages: [1]