예제 #1
0
static void startContinuous(void){
	// Method for continuing the Continuous mode
	resetContinuous();
	drawGallow();
	int i;
	for (i=0; i<try; i++){
		if (i==0){
			drawHead();
		}
		else if (i==1){
			drawBody();
		}
		else if (i==2){
			drawRightArm();
		}
		else if (i==3){
			drawLeftArm();
		}
		else if (i==4){
			drawRightLeg();
		}
	}
	static char puc_score[10];
	usprintf(puc_score, "Score: %d", score);
    RIT128x96x4StringDraw(puc_score, 69, 0, 15);
	displayAlphabet();
	drawUnderscore(0, 83);
	drawHiddenWord();
}

static void startClassic(void){
	// Method for starting the Classic mode
	resetClassic();
	drawGallow();
	static char puc_score[10];
	usprintf(puc_score, "Score: %d", score);
    RIT128x96x4StringDraw(puc_score, 69, 0, 15);
	displayAlphabet();
    drawUnderscore(0, 83);
	drawHiddenWord();
}
예제 #2
0
void GLWidget::paintGL()
{
    // This method gets called by the event handler to draw the scene, so
    // this is where you need to build your scene -- make your changes and
    // additions here.  All rendering happens in this function.

    checkForGLErrors();

    // Clear the screen with the background colour.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Setup the model-view transformation matrix stack.
    transformStack().loadIdentity();
    checkForGLErrors();

    const float GLOBAL_X_SCALE = 0.8f;
    const float GLOBAL_Y_SCALE = 0.8f;
    const float BODY_X_SCALE = 120.0f;
    const float BODY_X_INV_SCALE = (float)(1/BODY_X_SCALE);
    const float BODY_Y_SCALE = 150.0f;
    const float BODY_Y_INV_SCALE = (float)(1/BODY_Y_SCALE);
    const float NECK_X_SCALE = 65.0f;
    const float NECK_Y_SCALE = 50.0f;
    const float BEAK_UP_X_SCALE = 28.0f;
    const float BEAK_UP_Y_SCALE = 5.0f;
    const float BEAK_DOWN_X_SCALE = 28.0f;
    const float BEAK_DOWN_Y_SCALE = 5.0f;
    const float ARM_X_SCALE = 20.0f;
    const float ARM_Y_SCALE = 70.0f;
    const float LEG_X_SCALE = 10.0f;
    const float LEG_X_INV_SCALE = (float)(1/LEG_X_SCALE);
    const float LEG_Y_SCALE = 60.0f;
    const float LEG_Y_INV_SCALE = (float)(1/LEG_Y_SCALE);
    const float FOOT_X_SCALE = 10.0f;
    const float FOOT_Y_SCALE = 40.0f;

    // Note that successive transformations are applied *before* the previous
    // ones.

    // Push the current transformation matrix on the stack
    transformStack().pushMatrix();
    transformStack().scale(GLOBAL_X_SCALE,GLOBAL_Y_SCALE);

    // Draw body
    transformStack().pushMatrix(); // Draw body push

    transformStack().translate(body_move_horizontal_trans,body_move_vertical_trans);
    transformStack().scale(BODY_X_SCALE,BODY_Y_SCALE);
    m_gl_state.setColor(1.0, 1.0, 0.0);
    m_unit_body.draw();
    transformStack().scale(BODY_X_INV_SCALE,BODY_Y_INV_SCALE);

    // Draw left leg and foot
    transformStack().pushMatrix();
    drawLeftLegFoot(LEG_X_SCALE,LEG_Y_SCALE,
                    LEG_X_INV_SCALE,LEG_Y_INV_SCALE,
                    FOOT_X_SCALE,FOOT_Y_SCALE);
    transformStack().popMatrix();

    // Draw right leg and foot
    transformStack().pushMatrix();
    drawRightLegFoot(LEG_X_SCALE,LEG_Y_SCALE,
                        LEG_X_INV_SCALE,LEG_Y_INV_SCALE,
                        FOOT_X_SCALE,FOOT_Y_SCALE);
    transformStack().popMatrix();

    // Draw left arm
    transformStack().pushMatrix();
    drawLeftArm(ARM_X_SCALE,ARM_Y_SCALE);
    transformStack().popMatrix();

    // Draw head, upper beak and lower beak
    transformStack().pushMatrix();
    drawNeck(NECK_X_SCALE,NECK_Y_SCALE,
             BEAK_UP_X_SCALE,BEAK_UP_Y_SCALE,
             BEAK_DOWN_X_SCALE,BEAK_DOWN_Y_SCALE,
             BODY_Y_SCALE);
    transformStack().popMatrix();

    transformStack().popMatrix(); // Draw body pop

    // Retrieve the previous state of the transformation stack
    transformStack().popMatrix();


    // Execute any GL functions that are in the queue just to be safe
    glFlush();
    checkForGLErrors();
}
예제 #3
0
void glutDisplay() {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  loadGlobalCoord();

  glShadeModel(GL_SMOOTH);
  glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_LIGHTING);
                      
  glEnable(GL_LIGHT0);
  glLightfv(GL_LIGHT0, GL_AMBIENT, AMBIENT_LIGHT);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, DIFFUSE_LIGHT);
  glLightfv(GL_LIGHT0, GL_SPECULAR, SPECULAR_LIGHT);
  glLightfv(GL_LIGHT0, GL_POSITION, LIGHT_POSITION);
                                    
  glEnable(GL_LIGHT1);
  glLightfv(GL_LIGHT1, GL_AMBIENT, AMBIENT_SUB_LIGHT);
  glLightfv(GL_LIGHT1, GL_DIFFUSE, DIFFUSE_SUB_LIGHT);
  glLightfv(GL_LIGHT1, GL_SPECULAR, SPECULAR_LIGHT);
  glLightfv(GL_LIGHT1, GL_POSITION, SUB_LIGHT_POSITION);

  glEnable(GL_COLOR_MATERIAL); 
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, MATERIAL_AMBIENT); 
  glMaterialfv(GL_FRONT, GL_SPECULAR, MATERIAL_SPECULAR);
  glMateriali(GL_FRONT, GL_SHININESS, 48);

  glTranslatef(0, 0, baseTrans);
  glRotatef(bodyRot, 0, 0, 1);
  glRotatef(90.0f, 1, 0, 0);
  glColor3f(1.0, 1.0, 0); // Yellow color
  
  GLUquadricObj* body = gluNewQuadric();
  gluCylinder(body, 5.5, 7.0, 17, 100, 10);
  gluDeleteQuadric(body);

  glPushMatrix();
    drawLeftArm();
  glPopMatrix();

  glPushMatrix();
    drawRightArm();
  glPopMatrix();

  glPushMatrix();
    drawLeftLeg();
  glPopMatrix();

  glPushMatrix();
    drawRightLeg();
  glPopMatrix();
  
  glPushMatrix();
    drawTail();      
    
    glPushMatrix();
      drawBall();
    glPopMatrix();
  glPopMatrix();

  glPushMatrix();
    drawHead();  
 
    glPushMatrix();
      drawLeftEye();
    glPopMatrix();

    glPushMatrix();
      drawRightEye();
    glPopMatrix();

    glPushMatrix();
      drawLeftCheek();
    glPopMatrix();

    glPushMatrix();
      drawRightCheek();
    glPopMatrix();

    glPushMatrix();
      drawMouse();  
    glPopMatrix();

    glPushMatrix();
      drawLeftEar();
    glPopMatrix();

    glPushMatrix();
      drawRightEar();
    glPopMatrix();
  glPopMatrix();
  
  glutSwapBuffers();
}