Advertisement
Guest User

sdl2-32mousetest

a guest
Dec 5th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <SDL2/SDL.h>
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     SDL_GLContext rctx;
  10.  
  11.     if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0)
  12.     {
  13.         return -1;
  14.     }
  15.  
  16.     SDL_Window* win = SDL_CreateWindow("32 bit mouse test", 0, 0, 1920, 1080,
  17.                                         SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
  18.     SDL_Event   e;
  19.     bool        quit = false;
  20.  
  21.     while(!quit)
  22.     {
  23.         while(SDL_PollEvent(&e))
  24.         {
  25.             switch(e.type)
  26.             {
  27.             case SDL_MOUSEMOTION:
  28.                 cout << "x: " << e.motion.x << "(" << e.motion.xrel << ")" << endl;
  29.                 cout << "y: " << e.motion.y << "(" << e.motion.yrel << ")" << endl;
  30.                 break;
  31.             case SDL_MOUSEBUTTONDOWN:
  32.             case SDL_KEYDOWN:
  33.             case SDL_QUIT:
  34.                 quit = true;
  35.                 break;
  36.             default:
  37.                 break;
  38.             }
  39.         }
  40.     }
  41.     SDL_DestroyWindow(win);
  42.     SDL_Quit();
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement