void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); glMatrixMode(GL_MODELVIEW); cPosition(); }
void cScreen::refresh() { if(( mBitmapRedraw || mSpriteRedraw) && !mTextRedraw) { bitmapRefresh(); spriteDraw(); } if( mTextRedraw ) { mTextRedraw = false; } mWindow->RenderAt(mSurface, cPosition(8, 15)); if(mCursorOn) { size_t x = ((mCursorX) * 2 ) * mScale; size_t y = 70 + (mCursorY) * mScale; //TODO //mWindow->RenderAt( mSDLCursorSurface, cPosition(x,y) ); } mWindow->FrameEnd(); }
void cWindow::EventCheck() { SDL_Event SysEvent; while (SDL_PollEvent(&SysEvent)) { cEvent Event; switch (SysEvent.type) { case SDL_KEYDOWN: Event.mType = eEvent_KeyDown; Event.mButton = SysEvent.key.keysym.scancode; break; case SDL_KEYUP: Event.mType = eEvent_KeyUp; Event.mButton = SysEvent.key.keysym.scancode; break; case SDL_MOUSEMOTION: Event.mType = eEvent_MouseMove; Event.mPosition = cPosition(SysEvent.motion.x, SysEvent.motion.y); break; case SDL_MOUSEBUTTONDOWN: switch (SysEvent.button.button) { case 1: Event.mType = eEvent_MouseLeftDown; Event.mButton = 1; break; case 3: Event.mType = eEvent_MouseRightDown; Event.mButton = 3; break; } Event.mPosition = cPosition(SysEvent.motion.x, SysEvent.motion.y); Event.mButtonCount = SysEvent.button.clicks; break; case SDL_MOUSEBUTTONUP: switch (SysEvent.button.button) { case 1: Event.mType = eEvent_MouseLeftUp; Event.mButton = 1; break; case 3: Event.mType = eEvent_MouseRightUp; Event.mButton = 3; break; } Event.mPosition = cPosition(SysEvent.motion.x, SysEvent.motion.y); Event.mButtonCount = SysEvent.button.clicks; break; case SDL_CONTROLLERAXISMOTION: case SDL_JOYAXISMOTION: Event.mType = eEvent_JoyMovement; Event.mButton = SysEvent.jaxis.axis; Event.mJoyAxis = SysEvent.jaxis.value; break; case SDL_CONTROLLERBUTTONDOWN: case SDL_JOYBUTTONDOWN: Event.mType = eEvent_JoyButtonDown; break; case SDL_CONTROLLERBUTTONUP: case SDL_JOYBUTTONUP: Event.mType = eEvent_JoyButtonUp; break; case SDL_QUIT: Event.mType = eEvent_Quit; break; } if (Event.mType != eEvent_None) g_Creep.EventAdd(Event); } }
void cWindow::EventCheck() { SDL_Event SysEvent; while (SDL_PollEvent( &SysEvent )) { cEvent Event; switch (SysEvent.type) { case SDL_KEYDOWN: Event.mType = eEvent_KeyDown; Event.mButton = SysEvent.key.keysym.scancode; break; case SDL_KEYUP: Event.mType = eEvent_KeyUp; Event.mButton = SysEvent.key.keysym.scancode; break; case SDL_MOUSEMOTION: Event.mType =eEvent_MouseMove; Event.mPosition = cPosition( SysEvent.motion.x, SysEvent.motion.y ); break; case SDL_MOUSEBUTTONDOWN: switch (SysEvent.button.button) { case 1: Event.mType = eEvent_MouseLeftDown; Event.mButton = 1; break; case 3: Event.mType = eEvent_MouseRightDown; Event.mButton = 3; break; } Event.mPosition = cPosition( SysEvent.motion.x, SysEvent.motion.y ); Event.mButtonCount = SysEvent.button.clicks; break; case SDL_MOUSEBUTTONUP: switch (SysEvent.button.button) { case 1: Event.mType = eEvent_MouseLeftUp; Event.mButton = 1; break; case 3: Event.mType = eEvent_MouseRightUp; Event.mButton = 3; break; } Event.mPosition = cPosition( SysEvent.motion.x, SysEvent.motion.y ); Event.mButtonCount = SysEvent.button.clicks; break; case SDL_QUIT: Event.mType = eEvent_Quit; break; } if ( Event.mType != eEvent_None ) g_Fodder.EventAdd( Event ); } }
void keyboard (unsigned char key, int x, int y) { switch (key) { case 'f': day = (day + 10) % 360; glutPostRedisplay(); break; case 'F': day = (day - 10) % 360; glutPostRedisplay(); break; case 'y': year = (year + 5) % 360; glutPostRedisplay(); break; case 'Y': year = (year - 5) % 360; glutPostRedisplay(); break; case 'l': light_angle+=2.0/90; // if(light_position1>1.0)light_position1=0.0; glutPostRedisplay(); break; case 'L': light_angle-=2.0/90; // if(light_position1>1.0)light_position1=0.0; glutPostRedisplay(); break; case 'k': cam_radius+=0.2; cPosition(); glutPostRedisplay(); /*glLoadIdentity(); camera_position+=0.1; gluLookAt(camera_position,camera_position, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);*/ glutPostRedisplay(); break; case 'K': cam_radius-=0.2; cPosition(); glutPostRedisplay(); /*glLoadIdentity(); camera_position-=0.1; gluLookAt(camera_position,camera_position, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);*/ glutPostRedisplay(); break; case'w': cam_angle_v+=1.0/30; if(cam_angle_v>1.0) { cam_angle_v=1.0; } cPosition(); glutPostRedisplay(); break; case's': cam_angle_v-=1.0/30; if(cam_angle_v<-1.0) { cam_angle_v=-1.0; } cPosition(); glutPostRedisplay(); break; case'a': cam_angle_u+=1.0/30; cPosition(); glutPostRedisplay(); break; case'd': cam_angle_u-=1.0/30; cPosition(); glutPostRedisplay(); break; case'r': cam_radius=5.0; cam_angle_u=0; cam_angle_v=0; cPosition(); glutPostRedisplay(); break; case'q': move(); glutPostRedisplay(); break; case'Q': move1(); glutPostRedisplay(); break; case 27: exit(0); break; default: break; } }