Reputation: 25
I am testing out the feature in the SFML library mouseWheelScroll.delta
but I always get a return value of 0. Why could this be?
My code that I used is below, note that on some of the first lines of code in the program I initialised the variable sf::Event event;
.
if (event.type == sf::Event::MouseWheelScrolled) {
std::cout << "wheel movement: " << event.mouseWheelScroll.delta << std::endl;
}
Does the SFML library need a window or could it use the console? (I only ask because I am creating a console application)
Upvotes: 0
Views: 747
Reputation: 25
Thank you for the help everyone, it turns out that I had a problem with the line sf::RenderWindow v(sf::VideoMode::getDesktopMode(), "SFML");
and this was because the VC++ add-on wasn't installed, which is why I was always getting a "could not find "winmm.lib"" error.
Both of these code samples that others provided work, it was just me... sorry, but it is much appreciated!
Upvotes: 1
Reputation: 1993
I'm almost sure that you've forgotten something in your event loop. I've tried this snippet and it works fine
#include <iostream>
#include <SFML\Graphics.hpp>
int main(){
sf::RenderWindow v(sf::VideoMode::getDesktopMode(), "SFML");
while (v.isOpen()){
sf::Event event;
while (v.pollEvent(event)){
if (event.type == sf::Event::Closed)
v.close();
else if (event.type == sf::Event::MouseWheelScrolled){
std::cout << "Wheel: " << event.mouseWheelScroll.delta << std::endl;
}
}
v.clear();
v.display();
}
return 0;
}
Please, try it and compare what are you doing wrong (and then share with us)
Answering your second question, i have created a render window, but i think your question it's more about if the project can be a Console Application, and in fact, this is it and if you try it, it show both console and window.
Upvotes: 0