Hi all,
I'm teaching myself OpenGL, using SFML for a context. I've finally gotten to the point where I want to be able to move the camera. So you know, press 'w' and the camera's "move foward" becomes true.
I'm having a problem getting the input to actually trigger something though. My guess is there is something simple I'm just missing, perhaps some one can help.
// My main function is where the message loop is:
sf::Event pEvent;
bool open = (app.isOpen()? true : false);
while (open)
{
while (app.pollEvent(pEvent))
{
open = prgEvent(pEvent);
}
display();
app.display();
}
app.close();
delete model;
delete terra;
delete cam;
return 0;
// prgEvent(pEvent) takes the event and splits it into types,
// returning false if program should end
bool prgEvent(sf::Event& pEvent)
{
// A false return signals the end of the program
switch (pEvent.type)
{
case sf::Event::KeyPressed: return prgKeyPressed(pEvent.key.code);
case sf::Event::Closed: return false; // Note that this works
}
return true;
}
//prgKeyPressed() makes a switch on the actual key
#define print1(x) std::cout << x << '\n'
bool prgKeyPressed(sf::Keyboard::Key& kpCode)
{
// A false return signals the end of the program
switch (kpCode)
{
case sf::Keyboard::Escape: print1(kpCode); return false;
}
return true;
}
@Exploiter: Like those tags?
So, in the case of sf::Keyboard::Escape I print kpCode (which is 36), and then return false, right?
I get 36 printing on console, but the program doesn't quit. Like I said, I must be missing something here.
Thanks