int main(int argc, char** argv){ glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowSize( 600, 600); glutCreateWindow( "Demo" ); glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glEnable( GL_DEPTH_TEST ); glDepthRange(0.0, 1.0); glDepthFunc(GL_LEQUAL); setCubes(); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); glFrontFace(GL_CCW); glEnable(GL_NORMALIZE); glutKeyboardFunc( keyboardDown ); glutReshapeFunc( reshape ); glutDisplayFunc( display ); glutTimerFunc(16, update, 0); glutMainLoop( ); return(0); }
void ConsoleWindow::handleMouseUI( const InputEvent & e ) { if ( e.state == ae_input_DOWN && _selected ) activate(); for ( int i = 0 ; i < 6 ; i ++ ) { if ( e.state == ae_input_DOWN && e.checkID(_cubeSides[i].id()) ) { Audicle::instance()->move_to( i ); setCubes(); } } _timeLabel.handleMouse(e); _timeDisplay.handleMouse(e); _curLabel.handleMouse(e); _curDisplay.handleMouse(e); _prevLabel.handleMouse(e); _prevDisplay.handleMouse(e); _cubeWindow.handleMouse(e); _sizeBox.handleMouse(e); if ( e.state == ae_input_DOWN && _sizeBox.selected() ) { deactivate(); } }
figura::figura(int _count, char s[][5], char _name, int _color, int _pos, int _x ,int _y) { name = _name; count = _count; color = _color; pos = _pos; a = new cube[count]; setCubes(_count, s, _x, _y); }
void keyboardDown( unsigned char key, int x, int y ){ switch( key ){ case 27: // The 'esc' key case 'q'://quit program #ifdef FREEGLUT glutLeaveMainLoop( ); #else exit( 0 ); #endif break; case 'r'://reset cubes resetCube(&cube_a); resetCube(&cube_b); resetCube(&cube_c); resetCube(&cube_d); resetCube(&cube_e); setCubes(); break; default: break; } }
void ConsoleWindow::reshape( ) { DisplayWindow::reshape(); UIRect &bw = _baseWindow; //these are all relative to basewindow coordinates! double pad = _marginSize; double pad2 = 2.0 * _marginSize; double cspan = max ( 1.5 * bw.h() - pad2, min ( 1.2, 0.4 * bw.w() ) ); _cubeWindow.moveto ( pad, -pad ); _cubeWindow.resize ( cspan - pad2 , bw.h() - pad2 ); _contentWindow.moveto ( _cubeWindow.right() + pad2 , _cubeWindow.top() ); _contentWindow.resize ( bw.w() - ( cspan + pad2 ) , _cubeWindow.h() ); if ( _content ) setContentArea(); _vScrollBar.moveto ( _contentWindow.right(), _contentWindow.top() ); _vScrollBar.resize ( pad2, _contentWindow.h() ); _hScrollBar.moveto ( _contentWindow.left(), _contentWindow.bottom() ); _hScrollBar.resize ( pad , _contentWindow.w() ); _sizeBox.moveto ( -pad , - bw.h() + pad ); _sizeBox.resize ( pad2, pad2 ); _curLabel.moveto ( cspan + pad, pad * 1.5 ); _curLabel.resize ( pad2 * 3.0, pad * 3.0 ); _curLabel.setLabel("current face"); _curLabel.fitLabel(); _curDisplay.moveto ( cspan - pad * 1.5, pad * 1.5 ); _curDisplay.resize ( pad * 3.0 , pad * 3.0 ); _prevLabel.resize ( pad2 * 3.0, pad2 ); _prevLabel.setLabel( "previous face" ); _prevLabel.fitLabel(); _prevLabel.moveto ( cspan - ( _prevLabel.w() + pad ) , - bw.h() + pad ); _prevDisplay.moveto ( cspan - pad * 1.5, -bw.h() + pad * 1.25 ); _prevDisplay.resize ( pad * 3.0 , pad * 2.5 ); _prevDisplay.setLabel("0"); double timex = cspan + 0.5 * ( bw.w() - cspan ); _timeDisplay.moveto ( timex + pad, pad ); _timeDisplay.resize ( pad2 * 3.0, pad2 ); _timeLabel.resize ( pad * 3.0 , pad * 3.0 ); _timeLabel.fitLabel ( ); _timeLabel.moveto ( timex - ( pad + _timeLabel.w() * 0.5 ) , pad * 1.5 ); _timeDisplay.setx( _timeLabel.right() - pad * 0.5 ); double kdim = min ( _cubeWindow.h() * 0.25 , _cubeWindow.w() * 0.125 ); for ( int i = 0 ; i < 6; i++ ) { //resize _cubeSides[i].resize( kdim, kdim ); } //this is always the same. //depending on the current face, each //cubeside will move to one of these positions... _cubePos[ Audicle::UP ] = Point2D ( kdim, 0 ); _cubePos[ Audicle::DOWN ] = Point2D ( kdim, -2.0 * kdim ); _cubePos[ Audicle::LEFT ] = Point2D ( 0, -kdim ); _cubePos[ Audicle::RIGHT ] = Point2D ( 2.0 * kdim, -kdim ); _cubePos[ Audicle::BACK ] = Point2D ( 3.0 * kdim, -kdim ); _cubePos[ Audicle::CUR ] = Point2D ( kdim, -kdim ); setCubes(); }