コード例 #1
0
ファイル: main.c プロジェクト: TomPeerdeman/GEGT2013
void DrawGLScene(void)
{
  double stretch,height,position,rotation;

  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

  glLoadIdentity();
  gluLookAt(5.0, 5.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

  position=cos((double)frame*speed)*2;
  height=fabs(sin((double)frame*speed)*10)+1;
  rotation=cos((double)frame*speed)*90;
  stretch=1+0.3*sin((double)frame*speed/2);

  if(useMyTransformations) {
    if(doTranslate) myTranslatef(position,height-5,0.0);
    if(doRotate) myRotatef(rotation,0.2,0.6,0.77);
    if(doScale) myScalef(1/sqrt(stretch),stretch,1/sqrt(stretch));
  } else {
    if(doTranslate) glTranslatef(position,height-5,0.0);
    if(doRotate) glRotatef(rotation,0.2,0.6,0.77);
    if(doScale) glScalef(1/sqrt(stretch),stretch,1/sqrt(stretch));
  }

  //drawCube();
  drawTeapot();

  frame++;

  glutSwapBuffers();
}
コード例 #2
0
ファイル: test.c プロジェクト: jamesl/cg1_pipeline2d
void drawPolys(void) {
	myMatrixMode(GL_MODELVIEW);
	myScalef(50.0,50.0);

	drawHouse();

	myPopMatrix();
	myTranslatef(-50.0,0.0);
	myScalef(30.0,30.0);
	
	drawHouse();

	myPopMatrix();
	
	myTranslatef(0.0,-100.0);	
	myScalef(40.0,40.0);

	drawHouse();

	glFlush();
}
コード例 #3
0
void displayCallback( ){
  const float centerPosition[] = {0.0, 0.0, 0.0};

  float viewingTransform[16];
  float modelingTransform[16];

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glMatrixMode(GL_MODELVIEW);

  myLookAt( viewingTransform,
    eyePosition[0], eyePosition[1], eyePosition[2],
    centerPosition[0], centerPosition[1], centerPosition[2],
    upVector[0], upVector[1], upVector[2], camZ
  );

  // Set light & material properties for the teapot;
  // lights are transformed by current modelview matrix
  // such that they are positioned correctly in the scene.
  matMultVec4f( light0, light0_position, viewingTransform );
  matMultVec4f( light1, light1_position, viewingTransform );
  matMultVec4f( light2, light2_position, viewingTransform );
  matMultVec4f( light3, light3_position, viewingTransform );

  shaderProgram_A->activate( );
  activateUniforms_A( );
  glLoadIdentity( );
  glMultMatrixf(viewingTransform);
  myScalef(modelingTransform,
           teapotScale_A[0], teapotScale_A[1], teapotScale_A[2]);
  glMultMatrixf(modelingTransform);
  myTranslatef(modelingTransform,
               teapotTranslation_A[0],
               teapotTranslation_A[1],
               teapotTranslation_A[2]);
  glMultMatrixf(modelingTransform);
  _glutSolidTeapot(1.3);

  shaderProgram_B->activate( );
  activateUniforms_B( );
  glLoadIdentity( );
  glMultMatrixf(viewingTransform);
  myTranslatef(modelingTransform,
               teapotTranslation_B[0],
               teapotTranslation_B[1],
               teapotTranslation_B[2]);
  glMultMatrixf(modelingTransform);
  _glutSolidTeapot(1.3);

  glutSwapBuffers();
}
コード例 #4
0
ファイル: test.c プロジェクト: jamesl/cg1_pipeline2d
void display( void ) {
	
     /* 
	* Set clear color to gray 
     */
    myClearColor ( 0.8, 0.8, 0.8, 0.0 );
	
    /* 
	* Clear screen window 
     */
    myClear( GL_COLOR_BUFFER_BIT );
		
	myLoadIdentity();
	myPushMatrix();
	
	/* 
	 * plain old polygon test
	 */
	if ( (displayNumber % 4) == 1) {
		
		/* default clipping */
		myOrtho2D( -100.0, 100.0, -100.0, 100.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );
	
		myPushMatrix();

		/* draw the polys */
		drawPolys();
	}
	else if ( (displayNumber % 4) == 2) {
		
		/* clipping test */
		myOrtho2D( -65.0, 75.0, -80.0, 65.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );
		
		/* flip screen around! */
		myScalef(-1.0,1.0);
		myPushMatrix();
		

		/* draw the polys */
		drawPolys();
		
    }
	else if ( (displayNumber % 4) == 3) {
		
		/* default clipping */
		myOrtho2D( -100.0, 100.0, -100.0, 100.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );

		/* rotate screen */
		myRotatef(15.0);
		myPushMatrix();

		/* draw the tranformed polys */
		drawPolys();
	}
	
	else /* displayNumber == 0 */ {
		
		/* default clipping */
		myOrtho2D( -100.0, 100.0, -100.0, 100.0 );
		
		/* default viewport */
		myViewport( 0, 0, screenWidth, screenHeight );

		myRotatef(-15.0);
		myScalef(.5,.5);
		myPushMatrix();
		myRotatef(15.0);
		myPushMatrix();

		/* draw the tranformed polys */
		drawPolys();
	
		
	}
	
	/* 
     * Flush GL buffers to the display   
     */
    glFlush( );
	
}