Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 2 for OS X comes true!  (Read 106288 times)

0 Members and 2 Guests are viewing this topic.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #30 on: December 20, 2010, 10:29:44 pm »
I cannot reproduce the bug about key repeating on my machine.
Does the following code not work for you ?
Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{    
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML event check");

bool repeat = false;
window.EnableKeyRepeat(repeat);

// Start the game loop
while (window.IsOpened())
{
// Process events
sf::Event event;
while (window.GetEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
window.Close();

if (event.Type == sf::Event::KeyPressed)
{
// Escape key : exit
if (event.Key.Code == sf::Key::Escape) {
window.Close();
}

std::cout << "a key..." << std::endl;

// Enable/Disable key repeat.
if (event.Key.Code == sf::Key::R) {
repeat = !repeat;
window.EnableKeyRepeat(repeat);
std::cout << (repeat ? "repeat enable" : "repeat disable") << std::endl;
}
}
}

// Finally, display the rendered frame on screen
window.Clear();
window.Display();
}

return EXIT_SUCCESS;
}
SFML / OS X developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
SFML 2 for OS X comes true!
« Reply #31 on: December 20, 2010, 10:43:47 pm »
The bug targets TextEntered events, not KeyPressed events. Thus your code works fine, but not if you add something like that :
Code: [Select]

if (event.Type == sf::Event::TextEntered)
{
    std::cout << "text entered" << std::endl;
}
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #32 on: December 20, 2010, 10:55:13 pm »
Ho! I see. So that's one bug fixed!  :wink:
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 for OS X comes true!
« Reply #33 on: December 20, 2010, 11:10:09 pm »
I fixed point 2, now WaitEvent never doesn't false anymore unless the window is closed.

Quote
Ho! I see. So that's one bug fixed!

??
Key repeat must work for TextEntered events as well.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #34 on: December 20, 2010, 11:11:35 pm »
Look at the svn log  :wink:
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 for OS X comes true!
« Reply #35 on: December 20, 2010, 11:15:33 pm »
Ah sorry, it was not clear from your previous post that you fixed the bug between "Ho! I see." and "So that's one bug fixed!" :P
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #36 on: December 20, 2010, 11:18:01 pm »
I completely agree ^^
SFML / OS X developer

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
SFML 2 for OS X comes true!
« Reply #37 on: December 21, 2010, 02:47:57 am »
The mouse point returned by getMouseY() does not appear to account for the title bar.

Code: [Select]

int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "Test Window");
const sf::Input& wInput = window.GetInput();
window.ShowMouseCursor(true);

sf::Shape rec = sf::Shape::Rectangle(0,0,100,100, sf::Color(255,0,0));

    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.GetEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();

            if (event.Type == sf::Event::KeyPressed) {
                // Escape key : exit
                if (event.Key.Code == sf::Key::Escape)
                    window.Close();
            }
        }

float mouseX = (float)wInput.GetMouseX();
float mouseY = (float)wInput.GetMouseY();
rec.SetPosition(mouseX, mouseY);

window.Clear(sf::Color::Green);
window.Draw(rec);
        window.Display();
    }

    return EXIT_SUCCESS;
}

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #38 on: December 21, 2010, 01:20:29 pm »
Should be ok now.

Do you have some «lag» or is it really smooth ? (If you move your mouse too fast the shape doesn't go exactly to the border ? Is it the same on Linux/Win ? Is it the same with SFML 1 ? I don't thing so but I can't try.)
SFML / OS X developer

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
SFML 2 for OS X comes true!
« Reply #39 on: December 21, 2010, 03:57:43 pm »
Quote from: "Hiura"
Should be ok now.

Do you have some «lag» or is it really smooth ? (If you move your mouse too fast the shape doesn't go exactly to the border ? Is it the same on Linux/Win ? Is it the same with SFML 1 ? I don't thing so but I can't try.)


I dont have any noticeable lag, but if I move my mouse outside of the window really fast, then yeah, the rectangle isnt on the very edge. I have not tried it on other platforms.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 for OS X comes true!
« Reply #40 on: December 21, 2010, 03:59:44 pm »
Quote
if I move my mouse outside of the window really fast, then yeah, the rectangle isnt on the very edge.

This is ok, when moving too fast you can "skip" pixels.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #41 on: December 21, 2010, 05:20:34 pm »
yes, but how many ? up to 40px is ok for you ? It seems huge to me but it is also quite easy to "patch" this.
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 for OS X comes true!
« Reply #42 on: December 21, 2010, 05:52:48 pm »
But there's nothing wrong here, what would you patch?? We skip pixels because the OS can't generate MouseMove events for every single pixel that the mouse crosses.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML 2 for OS X comes true!
« Reply #43 on: December 21, 2010, 06:04:12 pm »
I REALLY need to take more time to put my idea out of my head....

By «it is also quite easy to "patch" this.» I meant «we can take the two last mouse position and find approximatively where the mouse went out of the window»... I promise, I'll make some effort! :roll:
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2 for OS X comes true!
« Reply #44 on: December 21, 2010, 06:05:36 pm »
:mrgreen:
Laurent Gomila - SFML developer

 

anything