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

Pages: [1]
1
SFML projects / Re: Nehe OpenGL Tutorials Converted to SFML
« on: June 27, 2013, 09:26:47 pm »
I've gathered that's the 'correct' way to do it - I saw it says so in Events explained :: "The KeyPressed and KeyReleased events".

My question was: why does the event-handling work fine in the cpp file I linked to?

It listens for movement keys inside the
while (myWindow.isOpen())
loop, but outside (and after) the
while (myWindow.pollEvent(event))
loop.

Non-movement keys, such as Escape to quit, are handled within
while (myWindow.pollEvent(event))

If I move the movement-key listening to there, it causes stutter.

The code doesn't work perfectly, mind - moving the mouse causes stutter. I'll probably look at moving it to the correct way using isKeyPressed.

I think I've figured it out now: it works when and only when the key-press event is 'left over' from
while (myWindow.pollEvent(event))

This means if I move my mouse around (firing events which are ignored) when holding down the left arrow button, I can cause it to stutter, or even stop, as the event 'left over' is no longer the expected keyboard event, but the mouse event, which is duly ignored.

2
SFML projects / Re: Nehe OpenGL Tutorials Converted to SFML
« on: June 27, 2013, 03:37:26 pm »
xerpi, I've done something similar at https://github.com/MaxBarraclough/NeHe-SFML2

I've ported the first 12 lessons. It's based on Chris Briscoe's SFML 1 port, at https://github.com/cwbriscoe/

I've also moved it to CMake.

Although it's working, I can't figure out how the keyboard event-handling works, in, say, Lesson 10.
The movement-key handling beginning at line 286 of
https://github.com/MaxBarraclough/NeHe-SFML2/blob/c2ef9849b478822f44588998c00f47e9251ceb48/nehe_lesson_10.cpp
seems to expect a sf::Event::KeyPressed to be there, despite that we've just run through our    "while (myWindow.pollEvent(event))" loop.

If I move the movement-key handling code up into the "while (myWindow.pollEvent(event))" loop, it stutters as one would expect.

Pages: [1]
anything