it's been all day I have a problem getting mousewheel events properly in one of my program. I can make a program from scratch and it work properly, however as soon as i do the same things inside this one, nothing seem to work as i want:
#include <iostream>
#include <SDL2/SDL.h>
int SCREEN_WIDTH = 640;
int SCREEN_HEIGHT = 480;
SDL_Event e;
SDL_Window* gWindow;
bool initSDL();
bool handleKeys();
void close();
bool initSDL()
{
if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
{
}
gWindow = SDL_CreateWindow( "Opengl Test",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
SCREEN_WIDTH,
SCREEN_HEIGHT,
SDL_WINDOW_SHOWN );
return true;
}
bool handleKeys()
{
while( SDL_PollEvent( &e ) )
{
if ( e.type == SDL_MOUSEWHEEL )
{
std::cout << "WhhheeeeeelllllllLLLLLLLLlllllll" << std::endl;
}
if ( e.type == SDL_QUIT )
{
return true;
}
}
}
void close()
{
//Destroy Window
SDL_DestroyWindow( gWindow );
gWindow = NULL;
//Quit SDL subsystem
SDL_Quit();
}
int main()
{
if(!initSDL())
{
}
while( !handleKeys() )
{
}
close();
}
I compile with this makefile:
#comment
#Compiler to use:
CC=g++
#Compiler flags:
APPNAME=TutOpengl
OBJ=main.o
#LIBS=-lSDL2
LIBS=-lSDL2
CFLAGS=-c -g -Wall -std=c++11 -I ./src $(LIBS)
all: $(APPNAME)
$(APPNAME): $(OBJ)
$(CC) $(OBJ) -o $(APPNAME) $(LIBS)
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp
clean:
rm -rf *.o $(APPNAME)
Under Ubuntu(14.04), SDL2. I can't get MouseWheel events properly and as of today i'm unable to find out. In the larger program set i get the MOUSEWHEELS events only every now and then like at random. Compiling should give you one warning, thanks in advance if anyone can help.
return false;
to the end of yourhandleKeys()
function solve the problem? For me your code (in VS2015) worked fine once I resolved all the warnings. \$\endgroup\$ – Tyyppi_77 Oct 4 '15 at 9:04if
sequence inside ofhandleKeys()
withswitch
statement. \$\endgroup\$ – HolyBlackCat Mar 28 '16 at 13:45