Exemplo n.º 1
0
Arquivo: main.cpp Projeto: JoaoS/CG
void draw_level(GLint level)
{
    for(int k =0;k<levels[level].n_troncos;k++)
        draw_troncos(k,level);
    /*desenho do tunel*/  
    if(level ==0)
    {    
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D,tex[1]);    
    }
    else if(level ==1)
    {   
        glEnable(GL_TEXTURE_2D);
        glColor4f(GRAY2);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // blending + textura
        glBindTexture(GL_TEXTURE_2D,tex[3]);   
    }    
    glPushMatrix();     
        glTranslatef(levels[level].tunelPos[0],levels[level].tunelPos[1],levels[level].tunelPos[2]);
        GLUquadricObj*  y = gluNewQuadric( );       
        gluQuadricDrawStyle(y, GLU_FILL);           
        gluQuadricNormals(y, GLU_SMOOTH);           
        gluQuadricTexture(y,GL_TRUE);               
        gluCylinder(y,levels[level].tunelDim[0],levels[level].tunelDim[1],levels[level].tunelDim[2],32,32);       
        gluDeleteQuadric(y);                        
    glPopMatrix();
    glDisable(GL_TEXTURE_2D);
}
Exemplo n.º 2
0
void Psphere::draw(){
	GLUquadricObj *qObj = gluNewQuadric();
	gluQuadricNormals(qObj, GLU_SMOOTH);
	gluQuadricTexture(qObj, GL_TRUE);
	glEnable(GL_TEXTURE_2D);
	gluSphere(qObj,radius,slices,stacks);
}
Exemplo n.º 3
0
GLuint GLTexobj::makeObject( const QImage& tex1, const QImage& tex2 )
{
    GLUquadricObj* q = gluNewQuadric();
    GLuint cylinderObj = glGenLists(1);
    glNewList( cylinderObj, GL_COMPILE );

    glTranslatef( 0.0, 0.0, -1.0 );

    // cylinder
    glTexImage2D( GL_TEXTURE_2D, 0, 3, tex1.width(), tex1.height(), 0,
		  GL_RGBA, GL_UNSIGNED_BYTE, tex1.bits() );
    gluQuadricTexture( q, GL_TRUE );
    gluCylinder(q, 0.6, 0.6, 2.0, 24, 1);

    // end cap
    glTexImage2D( GL_TEXTURE_2D, 0, 3, tex2.width(), tex2.height(), 0,
		  GL_RGBA, GL_UNSIGNED_BYTE, tex2.bits() );
    glTranslatef( 0.0, 0.0, 2.0 );
    gluDisk( q, 0.0, 0.6, 24, 1 );

    // other end cap
    glTranslatef( 0.0, 0.0, -2.0 );
    gluQuadricOrientation( q, (GLenum)GLU_INSIDE );
    gluDisk( q, 0.0, 0.6, 24, 1 );

    glEndList();
    gluDeleteQuadric( q );

    return cylinderObj;
}
Exemplo n.º 4
0
void GLWidget::initializeGL()
{
    glClearColor (0.35f, 0.35f, 0.4f, 0.5f);                        // Background color
    glColor4f(0.35f, 0.35f, 0.4f,1.0f);
    glClearDepth (1.0f);											// Depth Buffer Setup
    glDepthFunc(GL_LEQUAL);										// The Type Of Depth Testing (Less Or Equal)
    glEnable(GL_DEPTH_TEST);										// Enable Depth Testing
    glShadeModel(GL_FLAT);											// Select Flat Shading (Nice Definition Of Objects)
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);				// Set Perspective Calculations To Most Accurate
    quadratic = gluNewQuadric();                                    // Create A Pointer To The Quadric Object
    gluQuadricNormals(quadratic, GLU_SMOOTH);						// Create Smooth Normals
    gluQuadricTexture(quadratic, GL_TRUE);							// Create Texture Coords

    glMatrixMode(GL_TEXTURE);

  //  glEnable(GL_LIGHTING);											// Enable Lighting
  //  glEnable(GL_COLOR_MATERIAL);									// Enable Color Material

 //   glEnable(GL_LIGHT0);											// Enable Default Light
 //   glEnable(GL_LIGHT1);


 //     float light_diffuse[] = {0.4, 0.4, 0.8, 1.0};
//    float light_position[] = {0.0,-1000.0,0.0,0.0};
//    float light_position1[] = {0.0,0.0,100.0,0.0};
 //     glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
  //  glLightfv(GL_LIGHT0, GL_POSITION, light_position);
 //   glLightfv(GL_LIGHT1, GL_POSITION, light_position1);

//    float material[] = { 0.5, 0.5, 0.5, 1.0};
 //   glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,material);

//    glEnable(GL_NORMALIZE);
}
Exemplo n.º 5
0
Sample_18::Sample_18()
:	m_xrot(0.0f)
,	m_yrot(0.0f)
,	m_xspeed(0.1f)
,	m_yspeed(0.1f)
,	m_z(-5.0f)
,	m_filter(0)
,	m_light(false)
,	m_part1(0)
,	m_part2(0)
,	m_p1(0)
,	m_p2(1)
,	m_quadratic(NULL)
,	m_object(0)
{
	for (int i = 0; i < TEX_QTY; ++i)
	{
		m_texture[i] = 0;
	}
	m_image.loadBMP( "data/wall.bmp" );

	m_quadratic=gluNewQuadric();          // Create A Pointer To The Quadric Object
	gluQuadricNormals(m_quadratic, GLU_SMOOTH);   // Create Smooth Normals
	gluQuadricTexture(m_quadratic, GL_TRUE);      // Create Texture Coords
}
Exemplo n.º 6
0
void Ring :: draw(double radiusScale, Point3 currentPosition) {
	if (enabled == true)
	{		
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		GLUquadricObj *quadratic = NULL;
		quadratic = gluNewQuadric();         // Create A Pointer To The Quadric Object
		gluQuadricDrawStyle(quadratic, GLU_FILL);
		gluQuadricTexture(quadratic, GL_TRUE);      // Create Texture Coords
		gluQuadricNormals(quadratic, GLU_SMOOTH);   // Create Smooth Normals
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);	// Linear Filtering
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glBindTexture(GL_TEXTURE_2D,textureId);

		glPushMatrix();
			glTranslated(currentPosition.x, currentPosition.y, currentPosition.z);
			glRotated(ringRotation + 90, 1, 0, 0);
		
			glBegin(GL_QUAD_STRIP);
			for (double angle=0; angle<=360; angle+= 0.2)
			{
				glNormal3f(0.0,0.0,1.0);
				glTexCoord2f (0.0, 1.0);
				glVertex3d (outerRadius * radiusScale * cos(angle), outerRadius * radiusScale * sin(angle), 0.0);
				glNormal3f (0.0, 0.0, 1.0);
				glTexCoord2f (1.0, 0.0);
				glVertex3d (innerRadius * radiusScale * cos(angle), innerRadius * radiusScale * sin(angle), 0.0);
			}
			glEnd();	
		glPopMatrix();
	}
}
Exemplo n.º 7
0
void drawCar(int index, bool drawingShadow) {
	switch (index % 3) {
	case 0:
		glColor3f(1.0, 0.0, 0.0);
		break;
	case 1:
		glColor3f(0.0, 1.0, 0.0);
		break;
	case 2:
		glColor3f(0.0, 0.0, 1.0);
		break;
	}
	if (drawingShadow) {
		glColor3f(0.1, 0.1, 0.1);
	}
	glTranslated(0, 0.5, 0);
	
	if (index == 1) {
		glEnable(GL_TEXTURE_2D);
		glTexImage2D(GL_TEXTURE_2D, 0, 3, texball_w, texball_h, 0, GL_RGB, GL_UNSIGNED_BYTE, texball);
		GLUquadricObj *quadratic;
		quadratic = gluNewQuadric();
		gluQuadricTexture(quadratic, GL_TRUE);
		drawCube(0, 0, 0, 1);
		glScaled(2, 0.5, 2);
		glRotated(-90.0f, 1.0f, 0.0f, 0.0f);
		gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32);
		glDisable(GL_TEXTURE_2D);
	} else {
		drawCube(0, 0, 0, 1);
	}

	glPopMatrix();
}
void rysujKsiezyc()
{
	GLUquadricObj* quadro = gluNewQuadric();
	gluQuadricNormals(quadro, GLU_SMOOTH);
	gluQuadricTexture(quadro, GL_TRUE);
	glEnable(GL_TEXTURE_2D);
	glPushMatrix();
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glPushMatrix();
		//nachylenie
		glRotatef(Pziemia, 0.0, 0.0, 1.0);
		//wokó³ s³oñca
		glRotatef(RotacjaWokolSlonca*(1 / Sziemia) * 100000, 0.0, 1.0, 0.0);
		glTranslatef(Oziemia, 0.0, 0.0);
		//wokó³ w³asnej osi
		glRotatef(360.0 *(ObrotPlanet / 1)*4, 0.0, 1.0, 0.0);
			//oddalenie od ziemi
			glTranslatef(0.5, 0.0, 0.0);
			glBindTexture(GL_TEXTURE_2D, Tksiezyc);
			gluSphere(quadro, 0.04, 48, 48);
		glPopMatrix();
	glPopMatrix();
	glDisable(GL_TEXTURE_2D);
	gluDeleteQuadric(quadro);
}
Exemplo n.º 9
0
void Collectable::Draw(){
	float color[3] = {0.0, 0.0, 0.0};
		switch(apply){
			case Collectable::Flip:
				color[0]=1.0;
				break;
			case Collectable::SpeedUp:
				color[1]=1.0;
				break;
			case Collectable::SlowDown:
				color[2]=1.0;
				break;
			}
	
	glPushMatrix();
		glTranslatef(position.x, 1, position.z);
		rot+=1;
		glRotatef(rot, 0, 1,0);
		Material::setColor(color[0], color[1], color[2]);
		GLUquadric *qobj = gluNewQuadric(); 

		gluQuadricTexture(qobj,GL_TRUE); 

		glEnable(GL_TEXTURE_2D);
		//glBindTexture(GL_TEXTURE_2D,Texture::getSeatId());
		
		gluSphere(qobj,1,15,10); 

		gluDeleteQuadric(qobj); 
		glDisable(GL_TEXTURE_2D);
	glPopMatrix();
}
Exemplo n.º 10
0
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())								// If Loading The Textures Failed
	{
		return FALSE;									// Return False
	}
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.2f, 0.5f, 1.0f, 1.0f);				// Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glClearStencil(0);									// Clear The Stencil Buffer To 0
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations
	glEnable(GL_TEXTURE_2D);							// Enable 2D Texture Mapping

	glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmb);			// Set The Ambient Lighting For Light0
	glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDif);			// Set The Diffuse Lighting For Light0
	glLightfv(GL_LIGHT0, GL_POSITION, LightPos);		// Set The Position For Light0

	glEnable(GL_LIGHT0);								// Enable Light 0
	glEnable(GL_LIGHTING);								// Enable Lighting

	q = gluNewQuadric();								// Create A New Quadratic
	gluQuadricNormals(q, GL_SMOOTH);					// Generate Smooth Normals For The Quad
	gluQuadricTexture(q, GL_TRUE);						// Enable Texture Coords For The Quad

	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);	// Set Up Sphere Mapping
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);	// Set Up Sphere Mapping

	return TRUE;										// Initialization Went OK
}
void rysujPlanete(GLfloat nachylenie, GLfloat dlugoscRoku, GLfloat oddalenieOdSrodka, GLfloat obrotOsi, GLuint tekstura, GLfloat promien)
{
	GLUquadricObj* quadro = gluNewQuadric();
	gluQuadricNormals(quadro, GLU_SMOOTH);
	gluQuadricTexture(quadro, GL_TRUE);
	glEnable(GL_TEXTURE_2D);
	glPushMatrix();
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glPushMatrix();
			glRotatef(nachylenie, 0.0, 0.0, 1.0);
			//wokó³ s³oñca
			if (dlugoscRoku!=0.0)
			glRotatef(RotacjaWokolSlonca*(1/dlugoscRoku)*100000, 0.0, 1.0, 0.0);
			glTranslatef(oddalenieOdSrodka, 0.0, 0.0);
			//wokó³ w³asnej osi
			glRotatef(360.0 *(ObrotPlanet/obrotOsi), 0.0, 1.0, 0.0);
			//obrócenie w celu normalnoœci planety - pieguny na górze
			glRotatef(-90.0, 1.0, 0.0, 0.0);
			glBindTexture(GL_TEXTURE_2D, tekstura);
			gluSphere(quadro, promien, 48, 48);
		glPopMatrix();
	glPopMatrix();
	glDisable(GL_TEXTURE_2D);
	gluDeleteQuadric(quadro);
}
Exemplo n.º 12
0
Ambient::Ambient(string id)
{
    this->id = id;
    
    skyApp = new CGFappearance();
    kApp = new CGFappearance();
    sApp = new CGFappearance();
    mApp = new CGFappearance();
    tileGApp = new CGFappearance();
    tileKApp = new CGFappearance();
    tileSApp = new CGFappearance();
    tileMApp = new CGFappearance();
    
    // sets texture's wrap
    skyApp->setTextureWrap(GL_REPEAT, GL_REPEAT);
    kApp->setTextureWrap(GL_CLAMP, GL_CLAMP);
    sApp->setTextureWrap(GL_CLAMP, GL_CLAMP);
    mApp->setTextureWrap(GL_CLAMP, GL_CLAMP);
    tileGApp->setTextureWrap(GL_REPEAT, GL_REPEAT);
    tileKApp->setTextureWrap(GL_REPEAT, GL_REPEAT);
    tileSApp->setTextureWrap(GL_REPEAT, GL_REPEAT);
    tileMApp->setTextureWrap(GL_REPEAT, GL_REPEAT);
    
    // sky
    sphereQuadric = gluNewQuadric();
    gluQuadricDrawStyle(sphereQuadric, GLU_FILL);
    gluQuadricNormals(sphereQuadric, GLU_SMOOTH);
    gluQuadricOrientation(sphereQuadric, GLU_INSIDE);
    gluQuadricTexture(sphereQuadric, GL_TRUE);
    
}
Exemplo n.º 13
0
//------------------------------------------------------------------------------
void DrawCylinderDL()
{
	GLUquadricObj *gluObject = NULL;

	gluObject = gluNewQuadric();
	gluQuadricDrawStyle (gluObject, GLU_FILL);
	gluQuadricTexture (gluObject, TRUE);
	gluQuadricNormals (gluObject, GLU_SMOOTH);

	//Making a display list
	// mysphereID = glGenLists(1);
	// glNewList(mysphereID, GL_COMPILE);

	glPushMatrix();								//update to not use a pushMatrix, zz debug
		glRotatef (180.0f, 0.0f, 0.0f, 1.0f);	//orient world texture for coord 0,0
		gluCylinder (gluObject, 1.0, 1.0, 2.0, 24, 1);
		glRotatef (180.0f, 1.0f, 0.0f, 0.0f);	//flips the disk over
		gluDisk (gluObject, 0.0, 1.0, 24, 1);	//draw bottom disk
		glRotatef (180.0f, 0.0f, 1.0f, 0.0f);	//flip to right-side up
		glTranslatef (0.0f, 0.0f, 2.0f);		//translate to the top
		gluDisk (gluObject, 0.0, 1.0, 24, 1);	//draw top disk
	glPopMatrix();

	// glEndList();
	// gluDeleteQuadric(sphere);				``````````````//zz debug, should use this
}
Exemplo n.º 14
0
void Cylinder::draw(float textS, float textT) {
	glBegin(GL_POLYGON);
	for (int i = slices; i > 0; i--) {
		float theta = 2. * acos(-1.) * float(i) / float(slices);

		float x = base * cosf(theta);
		float y = base * sinf(theta);

		glTexCoord2f(y * textT, x * textS);
		glNormal3f(x / sqrt(pow(x, 2) + pow(y, 2)), y / sqrt(pow(x, 2) + pow(y, 2)), 0);
		glVertex2f(x, y);
	}
	glEnd();

	gluQuadricTexture(this->cylin, GL_TRUE);
	gluCylinder(this->cylin, this->base, this->top, this->height, this->slices, this->stacks);

	glPushMatrix();
	glTranslatef(0., 0., height);
	glBegin(GL_POLYGON);
	for (int i = 0; i < slices; i++) {
		float theta = 2. * acos(-1.) * float(i) / float(slices);

		float x = top * cosf(theta);
		float y = top * sinf(theta);

		glTexCoord2f(y * textT, x * textS);
		glNormal3f(x / sqrt(pow(x, 2) + pow(y, 2)), y / sqrt(pow(x, 2) + pow(y, 2)), 0);
		glVertex2f(x, y);
	}
	glEnd();
	glPopMatrix();
};
Exemplo n.º 15
0
void Castle::DrawHead()
{
	glColor3ub(0, 100, 0);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texId);    // Tell openGL which texture buffer to apply as texture
	glColor3f(1.0, 1.0, 1.0);          // Set the base colour of the quad
	glPushMatrix();
	{
		GLUquadricObj *quadratic;
		quadratic = gluNewQuadric();
		gluQuadricNormals(quadratic, GLU_SMOOTH);
		gluQuadricTexture(quadratic, GLU_TRUE);
		glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
		//glScaled(100, 2, 2);
		gluCylinder(quadratic,0.4f,0.4f,0.4f,32,32);
		glTranslated(0, 0, 0.4);
		DrawCircle(0.4,360);
	}
	glPopMatrix();
	glBindTexture(GL_TEXTURE_2D, 0); // Bind to the blank buffer to stop ourselves accidentaly using the wrong texture in the next draw call
	glDisable(GL_TEXTURE_2D);	
	//glTranslatef(0, 0.2, 0);

	glPushMatrix();
	{
		//glColor3ub(0, 100, 0);
		glColor3f(0.4, 0.4, 0.4);
		glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
		glutSolidCone(0.6, 1.2, 32, 32);
		glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
		DrawCircle(0.6,360);
		glColor3ub(0, 100, 0);
	}
	glPopMatrix();
}
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here
{
	if (!LoadGLTextures())								// Jump To Texture Loading Routine
	{
		return FALSE;									// If Texture Didn't Load Return FALSE
	}

	glEnable(GL_TEXTURE_2D);							// Enable Texture Mapping
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);		// Setup The Ambient Light
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);		// Setup The Diffuse Light
	glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);	// Position The Light
	glEnable(GL_LIGHT1);								// Enable Light One

	quadratic=gluNewQuadric();							// Create A Pointer To The Quadric Object (Return 0 If No Memory) (NEW)
	gluQuadricNormals(quadratic, GLU_SMOOTH);			// Create Smooth Normals (NEW)
	gluQuadricTexture(quadratic, GL_TRUE);				// Create Texture Coords (NEW)

	return TRUE;										// Initialization Went OK
}
Exemplo n.º 17
0
CMoonImage::CMoonImage (float distance)
{
  // Load DXT texture
  strncpy (ddsFilename, "ART/MOONMAP_256.dds",511);
  CImageDXT *dxt = new CImageDXT (ddsFilename);
  texid = CTextureManager::Instance().BindTexture (ddsFilename, dxt);
  SAFE_DELETE (dxt);

  // Rendering size and distance are arbitrarily chosen so that moon is has the
  //   correct apparent size and appears far away from the observer
  this->distance = distance;
  size = 8000.0f;

  // Initialize GLU quadric for sphere rendering
  q = gluNewQuadric ();
  gluQuadricDrawStyle (q, GL_FILL);
  gluQuadricOrientation (q, GLU_OUTSIDE);
  gluQuadricTexture (q, GL_TRUE);
  gluQuadricNormals(q, GLU_SMOOTH);

  // Create textured sphere in display list
  dlOrb = glGenLists (1);
  glNewList (dlOrb, GL_COMPILE);
  gluSphere (q, size, 16, 16);
  glEndList ();
}
Exemplo n.º 18
0
Minigun::Minigun( World * world ) :
	AWeapon( world, 10000, 200, 200 )
{
	mQuadric = gluNewQuadric();
	gluQuadricTexture( mQuadric, GL_TRUE );

	mName = "Minigun";
	mDrawn = false;
	mReload = false;
	mCoolDown = 0.1f;
	mFired = false;
	mRange = 100.0f;
	mTrailRadius = 0.01f;
	mDamage = 1.0f;
	mRotation = 0.0f;
	mMaterial = new Material( scene()->glWidget(), "BlackSteel" );
	mFireSound = new AudioSample( "minigun" );
	mFireSound->setLooping( true );

	mImpactParticleMaterial = new Material( scene()->glWidget(), "DirtParticle" );
	mImpactParticles = new ParticleSystem( 128 );
	mImpactParticles->setSize( 0.5f );
	mImpactParticles->setGravity( QVector3D( 0.0f, -80.0f, 0.0f ) );
	mImpactParticles->setDrag( 0.25f );
	mImpactParticles->setMinLife( 1.0f );
	mImpactParticles->setMaxLife( 2.0f );
}
Exemplo n.º 19
0
void draw_cannon() {

        
        GLUquadricObj *quadric;
        quadric = gluNewQuadric();

        gluQuadricDrawStyle(quadric, GLU_FILL);
        gluQuadricTexture(quadric, GL_TRUE);

        /* Wheel 1 */
        glPushMatrix();
        glTranslatef ( 0.0 , 1.0 , 0.0 );
        draw_wheel() ;
        glPopMatrix();

        /* Wheel 2 */
        glPushMatrix();
        glTranslatef ( 0.0 , -1.0 , 0.0 );
        draw_wheel() ;
        glPopMatrix();

        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, texture_granite);

        /* Barrel sits on this thing */
        glPushMatrix();
        glRotatef (90, 1.0, 0.0, 0.0);
        glTranslatef ( -3.0 , 0.0 , -0.6 );
        draw_barrel_leg() ;
        glPopMatrix();

        glPushMatrix();
        glRotatef (90, 1.0, 0.0, 0.0);
        glTranslatef ( -3.0 , 0.0 , 0.6 );
        draw_barrel_leg() ;
        glPopMatrix();

        /* Axle */
        glPushMatrix();
        glRotatef (90, 1.0, 0.0, 0.0);
        glTranslatef ( 0.0 , 1.0 , 0.0 );
        glTranslatef ( 0.0 , 0.0 , -1.0 );
        gluCylinder(quadric, 0.25, 0.25, 2.00, 30, 30);
        glPopMatrix();

        /* Barrel */
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, texture_granite);
        glPushMatrix();
            glTranslatef ( -2.0 , 0.0 , 0.0 );
            glTranslatef ( 0.0 , 0.0 , 1.0 );
            glRotatef ((GLfloat) 60.0, 0.0, 1.0, 0.0);
            gluCylinder(quadric, 0.5, 0.5, 3.00, 30, 30);
            gluSphere(quadric, 0.52 , 30, 30);
        glPopMatrix();
        glDisable(GL_TEXTURE_2D);

        gluDeleteQuadric(quadric);
}
/* default init procedure for GLUT */
void init(void)
{    
        GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
        GLfloat mat_shininess[] = { 50.0 };

        glClearColor (0.0, 0.0, 0.0, 0.0);
        glShadeModel(GL_FLAT);
        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_LEQUAL);

        /* texture stuff */
        /* fill in checkimage array*/
        makeCheckImage(0);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        /* generate '1' texture and return the ID in address starting at &texName*/
        glGenTextures(1, &texName);

        /* set the current texture to texture ID in texName*/
        glBindTexture(GL_TEXTURE_2D, texName); 

        /* wrap the texture around the s- and t-dimension*/
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

        /* if texture is too small or too big for the surface,
         * magnify or minify it by using the texel coordinate 
         * nearest the pixel to be colored.
         */
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
                                   GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                                   GL_NEAREST);

        /* apply the checkimage array to the current texture*/
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth,
                                checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 
                                checkImage);

        /* lighting stuff */
        glShadeModel (GL_SMOOTH);

        /* specular highlights have color 'mat_specular'*/
        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);

        /* shininess ('N') = mat_shininess*/
        glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);

        glEnable(GL_LIGHTING);  /* enable lighting */
        glEnable(GL_LIGHT0);    /* enable light0 */

	/* quadratic stuff */
	quadratic=gluNewQuadric();	
	gluQuadricNormals(quadratic, GLU_SMOOTH);
	gluQuadricTexture(quadratic, GL_TRUE);	

	/* normalize all normal vectors for lighting and shading */
	glEnable(GL_NORMALIZE);
}
Exemplo n.º 21
0
CylinderDrawable::CylinderDrawable(const Matrix4& orientation, const Point3Df& position, float length, float widthBase, float widthTop) : 
						m_orientation(orientation), m_position(position), m_length(length), m_widthBase(widthBase), m_widthTop(widthTop)
{ 
	m_pQuadric = gluNewQuadric();
	gluQuadricNormals(m_pQuadric, GLU_SMOOTH);
	gluQuadricTexture(m_pQuadric, GL_TRUE);
	gluQuadricOrientation(m_pQuadric, GLU_OUTSIDE);
}
Exemplo n.º 22
0
SceneGraph::Cylinder::Cylinder( const HelperGl::Material & material, float baseRadius/*=1.0*/, float topRadius/*=1.0*/, float height/*=1.0*/, int slices/*=20*/, int stacks/*=1*/ ) : m_material(material), m_quadric(gluNewQuadric()), m_baseRadius(baseRadius), m_topRadius(topRadius), m_height(height), m_slices(slices), m_stacks(stacks)
{
	gluQuadricNormals(m_quadric, GLU_SMOOTH) ;
	if(m_material.hasTexture())
	{
		gluQuadricTexture(m_quadric, true);
	}
}
Exemplo n.º 23
0
void LoadManTextures() {
	man_tex = TextureLoad("textures/security.bmp", GL_FALSE, GL_LINEAR, GL_LINEAR, GL_REPEAT);
	man_face_tex = TextureLoad("textures/face.bmp", GL_FALSE, GL_LINEAR, GL_LINEAR, GL_REPEAT);
	
	quadric = gluNewQuadric();
	gluQuadricNormals(quadric, GLU_SMOOTH);
	gluQuadricTexture(quadric, GL_TRUE);
}
Exemplo n.º 24
0
void Sphere::walk_gl()
{
    GLUquadricObj* q = gluNewQuadric();
    gluQuadricNormals(q, GLU_SMOOTH);
    gluQuadricTexture(q, GL_TRUE);
    gluQuadricDrawStyle(q, GLU_FILL);
    gluSphere(q,1,20,20);
}
Exemplo n.º 25
0
SceneGraph::Sphere::Sphere( const HelperGl::Material & material, float radius/*=1.0*/, int slices/*=20*/, int stacks/*=20*/ ) : m_material(material), m_quadric(gluNewQuadric()), m_radius(radius), m_slices(slices), m_stacks(stacks)
{
	gluQuadricNormals(m_quadric, GLU_SMOOTH) ;
	if(m_material.hasTexture())
	{
		gluQuadricTexture(m_quadric, true);
	}
}
Exemplo n.º 26
0
void InitVars()
{
	 //create palnes
	pl1._Position=TVector(0,-300,0);
	pl1._Normal=TVector(0,1,0);
	pl2._Position=TVector(300,0,0);
	pl2._Normal=TVector(-1,0,0);
	pl3._Position=TVector(-300,0,0);
	pl3._Normal=TVector(1,0,0);
	pl4._Position=TVector(0,0,300);
	pl4._Normal=TVector(0,0,-1);
	pl5._Position=TVector(0,0,-300);
	pl5._Normal=TVector(0,0,1);


	//create cylinders
	cyl1._Position=TVector(0,0,0);
	cyl1._Axis=TVector(0,1,0);
	cyl1._Radius=60+20;
	/*cyl2._Position=TVector(200,-300,0);
	cyl2._Axis=TVector(0,0,1);
	cyl2._Radius=60+20;
	cyl3._Position=TVector(-200,0,0);
	cyl3._Axis=TVector(0,1,1);
    cyl3._Axis.unit();
	cyl3._Radius=30+20;*/
	//create quadratic object to render cylinders
	cylinder_obj= gluNewQuadric();
	gluQuadricTexture(cylinder_obj, GL_TRUE);

    //Set initial positions and velocities of balls
	//also initialize array which holds explosions
	NrOfBalls=1;
	ArrayVel[0]=veloc;
	ArrayPos[0]=TVector(199,180,10);
	/*ExplosionArray[0]._Alpha=0;
	ExplosionArray[0]._Scale=1;
	ArrayVel[1]=veloc;
	ArrayPos[1]=TVector(0,150,100);
	ExplosionArray[1]._Alpha=0;
	ExplosionArray[1]._Scale=1;
	ArrayVel[2]=veloc;
	ArrayPos[2]=TVector(-100,180,-100);
	ExplosionArray[2]._Alpha=0;
	ExplosionArray[2]._Scale=1;
	for (int i=3; i<10; i++)
	{
         ArrayVel[i]=veloc;
	     ArrayPos[i]=TVector(-500+i*75, 300, -500+i*50);
		 ExplosionArray[i]._Alpha=0;
	     ExplosionArray[i]._Scale=1;
	}
	for (int i=10; i<20; i++)
	{
         ExplosionArray[i]._Alpha=0;
	     ExplosionArray[i]._Scale=1;
	}*/
}
Exemplo n.º 27
0
void init_scene()
{
   static GLfloat lightpos[4]={50.0f, 50.0f, -320.f, 1.0f};
   GLubyte* tex;

   /* Clear error */
   glGetError();

   /* draw a perspective scene */
   glMatrixMode(GL_PROJECTION);
   glFrustumf(-100.f, 100.f, -100.f, 100.f, 320.f, 640.f);
   glMatrixMode(GL_MODELVIEW);

   /* turn on features */
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);

   /* place light 0 in the right place */
   glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

   /* enable filtering */
   glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

   tex=make_texture(256, 256);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, tex);
   free(tex);

   disk_fill=gluNewQuadric();
   gluQuadricDrawStyle(disk_fill, GLU_FILL);
   gluQuadricNormals(disk_fill, GLU_SMOOTH);

   disk_fill_flat=gluNewQuadric();
   gluQuadricDrawStyle(disk_fill_flat, GLU_FILL);
   gluQuadricNormals(disk_fill_flat, GLU_FLAT);

   disk_fill_texture=gluNewQuadric();
   gluQuadricDrawStyle(disk_fill_texture, GLU_FILL);
   gluQuadricNormals(disk_fill_texture, GLU_SMOOTH);
   gluQuadricTexture(disk_fill_texture, GLU_TRUE);

   disk_point=gluNewQuadric();
   gluQuadricDrawStyle(disk_point, GLU_POINT);
   gluQuadricNormals(disk_point, GLU_SMOOTH);

   disk_line=gluNewQuadric();
   gluQuadricDrawStyle(disk_line, GLU_LINE);
   gluQuadricNormals(disk_line, GLU_SMOOTH);

   disk_silh=gluNewQuadric();
   gluQuadricDrawStyle(disk_silh, GLU_SILHOUETTE);

   if (glGetError())
   {
      printf("Oops! I screwed up my OpenGL ES calls somewhere\n");
   }
}
Exemplo n.º 28
0
void GameBoard::initializeGL( QGLWidget & target ) {
  QImage wall( "textures/wall.jpg" );
  this->wallTexture = target.bindTexture( wall );
  QImage grass( "textures/grass.jpg" );
  this->grassTexture = target.bindTexture( grass );
  QImage roof( "textures/roof.jpg" );
  this->roofTexture = target.bindTexture( roof );
  QImage tiles( "textures/tiles.jpg" );
  this->ghostsStartTexture = target.bindTexture( tiles );
  QImage dot( "textures/dot.png" );
  this->dotTexture = target.bindTexture( dot );

  this->staticList = glGenLists( 1 );
  glNewList( this->staticList, GL_COMPILE );
  {
    for ( int y = 0; y < this->height; ++y ) {
      for ( int x = 0; x < this->width; ++x ) {
        if ( GameBoard::Wall == this->blocks[ y ][ x ] ) {
          this->addWallBlock( x, y );
        }
        else if ( GameBoard::Path == this->blocks[ y ][ x ] ) {
          this->addGrassBlock( x, y );
        }
        else if ( GameBoard::Dot == this->blocks[ y ][ x ] ) {
          this->addGrassBlock( x, y );
        }
        else if ( GameBoard::Powerup == this->blocks[ y ][ x ] ) {
          this->addGrassBlock( x, y );
        }
        else if ( GameBoard::Teleport1 == this->blocks[ y ][ x ] ) {
          this->addGrassBlock( x, y );
        }
        else if ( GameBoard::PlayerStart == this->blocks[ y ][ x ] ) {
          this->addGrassBlock( x, y );
        }
        else if ( GameBoard::PlayerWall == this->blocks[ y ][ x ] ) {
          this->addFloorBlock( x, y, this->roofTexture, this->defaultMaterial );
        }
        else if ( GameBoard::GhostsStart == this->blocks[ y ][ x ] ) {
          this->addFloorBlock(
            x, y, this->ghostsStartTexture, this->defaultMaterial
          );
        }
      }
    }
  }
  glEndList();

  this->dotList = glGenLists( 1 );
  this->dotQuadric = gluNewQuadric();
  gluQuadricTexture( this->dotQuadric, true );
  glNewList( this->dotList, GL_COMPILE );
  {
    glBindTexture( GL_TEXTURE_2D, this->dotTexture );
    gluSphere( this->dotQuadric, 0.1f, 360 / 30, 180 / 30 );
  }
  glEndList();
}
Exemplo n.º 29
0
BasketBall::BasketBall() :
    Ball(MyGlobal::BASKETBALL_RADIUS)
{
  quadric = gluNewQuadric();
  gluQuadricNormals(quadric, GL_SMOOTH);
  gluQuadricTexture(quadric, GL_TRUE);
  if (texture == -1)
    texture = GLAid::loadTexture(MyGlobal::BASKETBALL_TEXTURE_PATH);
}
Exemplo n.º 30
0
Dummy::Dummy( World * world ) : ACreature( world )
{
	mQuadric = gluNewQuadric();
	gluQuadricTexture( mQuadric, GL_TRUE );

	mHeightAboveGround = 6.0f;
	mVelocityY = 0.0f;
	mMaterial = new Material( scene()->glWidget(), "KirksEntry" );
}