m1m8

Move quad

Sep 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. while (!endApp)
  2.     {  
  3.         glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  4.  
  5.         //clears the frame buffer
  6.         TheScreen::Instance()->ClearScreen();
  7.  
  8.         //updates input manager
  9.         TheInput::Instance()->Update();
  10.  
  11.         KeyState key = TheInput::Instance()->GetKeyState();
  12.        
  13.         //break out of loop if X is clicked or space is pressed;
  14.         if ((TheInput::Instance()->IsXClicked()) || (key[SDL_SCANCODE_SPACE]) || (key[SDL_SCANCODE_Q]))
  15.         {
  16.             endApp = true;
  17.         }
  18.  
  19.         mouseX = TheInput::Instance()->GetMouseMotionX() / 100;
  20.         mouseY = TheInput::Instance()->GetMouseMotionY() / 100;
  21.        
  22.         glPushMatrix();
  23.         glTranslatef(mouseX, mouseY, 0.0f);
  24.             glBegin(GL_QUADS);
  25.            
  26.             //Top left corner
  27.             glColor3f(1, 0, 1);
  28.             glVertex3f(0.0f, 0.0f, 0.0f);
  29.  
  30.             //Top right corner
  31.             glColor3f(1, 0, 0);
  32.             glVertex3f(128.0f, 0.0f, 0.0f);
  33.  
  34.             //Bottom right corner
  35.             glColor3f(1, 0, 1);
  36.             glVertex3f(128.0f, 128.0f, 0.0f);
  37.  
  38.             //Bottom left corner
  39.             glColor3f(1, 0, 1);
  40.             glVertex3f(0.0f, 128.0f, 0.0f);
  41.             glEnd();
  42.         glPopMatrix();
  43.  
  44.         // PUT THIS IN DEBUG MANAGER
  45.         GLenum errorCode = glGetError();
  46.  
  47.         if (errorCode == GL_NO_ERROR)
  48.         {
  49.             std::cout << "no error" << std::endl;
  50.         }
  51.  
  52.         else if (errorCode == GL_INVALID_OPERATION)
  53.         {
  54.             std::cout << "error" << std::endl;
  55.         }
  56.  
  57.         //Swap buffers
  58.         TheScreen::Instance()->SwapBuffer();
  59.  
  60.         SDL_Delay(10000 / 60);
  61.     }
Add Comment
Please, Sign In to add comment