Exemple #1
0
void SimpleHouse2::draw(DrawingState*)
{
  glColor3fv(&color.r);
  polygoni( 5, -20,0,-30, 20,0,-30, 20,30,-30, 0,45,-30, -20,30,-30);
  polygoni(-5, -20,0, 30, 20,0, 30, 20,30, 30, 0,45, 30, -20,30, 30);
  fetchTexture("simpleHouse2-front.png");
  glBegin(GL_POLYGON);
  glNormal3f(1,0,0);
  glTexCoord2f(0,1); glVertex3i( 20,30,-30);
  glTexCoord2f(1,1); glVertex3i( 20,30, 30);
  glTexCoord2f(1,0); glVertex3i( 20, 0, 30);
  glTexCoord2f(0,0); glVertex3i( 20, 0,-30);
  glEnd();
  glBegin(GL_POLYGON);
  glNormal3f(-1,0,0);
  glTexCoord2f(0,0); glVertex3i(-20, 0,-30);
  glTexCoord2f(1,0); glVertex3i(-20, 0, 30);
  glTexCoord2f(1,1); glVertex3i(-20,30, 30);
  glTexCoord2f(0,1); glVertex3i(-20,30,-30);
  glEnd();
  glBindTexture(GL_TEXTURE_2D,0);
  glBindTexture(GL_TEXTURE_2D,0);
  fetchTexture("roof3.png");
  polygoni( 4, 20,30,-30,  20,30, 30,   0, 45, 30,   0, 45, -30);
  polygoni(-4,-20,30,-30, -20,30, 30,   0, 45, 30,   0, 45, -30);
}
Exemple #2
0
static void drawWheel1(float radius, float width)
{
	glPushMatrix();
	
	// Car wheels
	for (int i = -1; i <= 1; i += 2) {
		for (int j = -1; j <= 1; j += 2) {
			glPushMatrix();
			glTranslatef(i * 0.8, 0.3, j * 1);
			glRotatef(90 * i, 0, 1, 0);
			//if (j < 0) glRotatef(turnIndex * 20, 0, 1, 0);
			//glRotatef(i * wheelAngle, 0, 0, 1);
			fetchTexture("wheel_side_texture.bmp");
			//glBindTexture(GL_TEXTURE_2D, wheelSideTexture);
			gluCylinder(qobj, radius, radius, 0.3, 50, 20);
			glTranslatef(0, 0, 0.3);
			fetchTexture("wheel_texture.bmp");
			//glBindTexture(GL_TEXTURE_2D, wheelTexture);
			gluDisk(qobj, 0, radius, 50, 20);
			glPopMatrix();
		}
	}
	glBindTexture(GL_TEXTURE_2D, 0);

	glPopMatrix();
}
Exemple #3
0
void Church::draw(DrawingState*)
{
  int xsz = 30;
  int zsz = 40;
  int hgh = 50;
  int top = 65;

  glColor3fv(&color.r);
  fetchTexture("church-front.png");
  glBegin(GL_POLYGON);
  glNormal3f(0,0,-1);
  glTexCoord2f(0,0); glVertex3i(-xsz, 0, -zsz);
  glTexCoord2f(0,1); glVertex3i(-xsz,hgh, -zsz);
  glTexCoord2f(.5,1.5); glVertex3i(  0,top,-zsz);
  glTexCoord2f(1,1); glVertex3i( xsz,hgh,-zsz);
  glTexCoord2f(1,0); glVertex3i( xsz, 0,-zsz);
  glEnd();
  glBegin(GL_POLYGON);
  glNormal3f(0,0,1);
  glTexCoord2f(0,0); glVertex3i(-xsz, 0,   zsz);
  glTexCoord2f(1,0); glVertex3i( xsz, 0,   zsz);
  glTexCoord2f(1,1); glVertex3i( xsz,hgh,   zsz);
  glTexCoord2f(.5,1.5); glVertex3i(  0,top,zsz);
  glTexCoord2f(0,1); glVertex3i(-xsz,hgh,   zsz);
  glEnd();
  glBindTexture(GL_TEXTURE_2D,0);

  polygoni( 4, xsz,hgh,-zsz,  xsz,hgh, zsz,   0, top, zsz,   0, top, -zsz);
  polygoni(-4, -xsz,hgh,-zsz, -xsz,hgh, zsz,   0, top, zsz,   0, top,
		   -zsz);

  fetchTexture("church-side.png");
  polygoni( 4, xsz, 0,-zsz,  xsz, 0, zsz,  xsz, hgh, zsz,  xsz, hgh, -zsz);
  polygoni(-4,-xsz, 0,-zsz, -xsz, 0, zsz, -xsz, hgh, zsz, -xsz, hgh, -zsz);


  glPushMatrix();
  glTranslatef(0,0,(float)zsz);
  int ss=10;					// steeple size
  int sh=60;					// height
  int th=120;					// top of point
  glBindTexture(GL_TEXTURE_2D,0);
  polygoni(4, -ss, 0,-ss,  ss, 0,-ss,  ss,sh,-ss,  -ss,sh,-ss);
  polygoni(4,  ss, 0,-ss,  ss, 0, ss,  ss,sh, ss,   ss,sh,-ss);
  polygoni(4,  ss, 0, ss, -ss, 0, ss, -ss,sh, ss,   ss,sh, ss);
  polygoni(4, -ss, 0, ss, -ss, 0,-ss, -ss,sh,-ss,  -ss,sh, ss);
  polygoni(3, -ss,sh,-ss,  ss,sh,-ss,   0,th,0);
  polygoni(3,  ss,sh,-ss,  ss,sh, ss,   0,th,0);
  polygoni(3,  ss,sh, ss, -ss,sh, ss,   0,th,0);
  polygoni(3, -ss,sh, ss, -ss,sh,-ss,   0,th,0);
  glPopMatrix();
}
Exemple #4
0
static void drawWheel2(float radius, float width)
{
	glPushMatrix();
	glRotatef(-90 , 0, 1, 0);
	fetchTexture("wheel_side_texture.bmp");
	gluCylinder(qobj, radius, radius, 3, 50, 20);
	glTranslatef(0, 0, 0.3);
	fetchTexture("wheel_texture.bmp");
	//glBindTexture(GL_TEXTURE_2D, wheelTexture);
	gluDisk(qobj, 0, radius, 50, 20);
	glPopMatrix();
	glBindTexture(GL_TEXTURE_2D, 0);
}
Exemple #5
0
void Snow::draw(DrawingState* dr){

	glPushAttrib(GL_ALL_ATTRIB_BITS);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_COLOR_MATERIAL);
	glLightfv(GL_LIGHT0, GL_POSITION, &(vec4(1.0)[0]));
	glDisable(GL_CULL_FACE);
	glEnable(GL_TEXTURE_2D);
	glPushMatrix();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	fetchTexture("Snowflake.bmp");
	for (int i = 0; i < snowPos.size(); i++){	
		glPushMatrix();
		glTranslatef(snowPos[i].x, snowPos[i].y, snowPos[i].z);
		glBegin(GL_QUADS);
		glVertex3f(-1.5f, -1.5f, 0.0f); glTexCoord2f(0.0f, 0.0f);
		glVertex3f(-1.5f, 1.5f, 0.0f); glTexCoord2f(0.0f, 1.0f);
		glVertex3f(1.5f, 1.5f, 0.0f); glTexCoord2f(1.0f, 1.0f);
		glVertex3f(1.5f, -1.5f, 0.0f); glTexCoord2f(1.0f, 0.0f);
		glEnd();
		glBegin(GL_QUADS);
		glVertex3f(0.0f, -1.5f, -1.5f); glTexCoord2f(0.0f, 0.0f);
		glVertex3f(0.0f, 1.5f, -1.5f); glTexCoord2f(0.0f, 1.0f);
		glVertex3f(0.0f, 1.5f, 1.5f); glTexCoord2f(1.0f, 1.0f);
		glVertex3f(0.0f, -1.5f, 1.5f); glTexCoord2f(1.0f, 0.0f);
		glEnd();
		glPopMatrix();
	}
	
	glPopAttrib();
	glPopMatrix();
}
void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) {
    PROFILE_RANGE(render, __FUNCTION__);

    if (!_uiTexture) {
        _uiTexture = gpu::Texture::createExternal(OffscreenQmlSurface::getDiscardLambda());
        _uiTexture->setSource(__FUNCTION__);
    }
    // Once we move UI rendering and screen rendering to different
    // threads, we need to use a sync object to deteremine when
    // the current UI texture is no longer being read from, and only
    // then release it back to the UI for re-use
    auto offscreenUi = DependencyManager::get<OffscreenUi>();

    OffscreenQmlSurface::TextureAndFence newTextureAndFence;
    bool newTextureAvailable = offscreenUi->fetchTexture(newTextureAndFence);
    if (newTextureAvailable) {
        _uiTexture->setExternalTexture(newTextureAndFence.first, newTextureAndFence.second);
    }
    auto geometryCache = DependencyManager::get<GeometryCache>();
    gpu::Batch& batch = *renderArgs->_batch;
    geometryCache->useSimpleDrawPipeline(batch);
    batch.setProjectionTransform(mat4());
    batch.setModelTransform(Transform());
    batch.resetViewTransform();
    batch.setResourceTexture(0, _uiTexture);
    geometryCache->renderUnitQuad(batch, glm::vec4(1), _qmlGeometryId);
    batch.setResourceTexture(0, nullptr);
}
Exemple #7
0
void Sign::draw(DrawingState*)
{
  glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_MODULATE);
  fetchTexture(texName);
  glBegin(GL_POLYGON);
  glNormal3f(0,0,1);
  glColor3f(1,1,1);
  drawShape(0);
  glEnd();
  // back of the sign
  glBindTexture(GL_TEXTURE_2D,0);
  glNormal3f(0,0,-1);
  drawShape(-.1f);
  // post
  glBegin(GL_POLYGON);
    glNormal3f(0,0,1);
	glVertex3f(-.1f,h,0);
	glVertex3f( .1f,h,0);
	glVertex3f( .1f,0,0);
	glVertex3f(-.1f,0,0);
  glEnd();
  glFrontFace(GL_CW);
  glBegin(GL_POLYGON);
    glNormal3f(0,0,1);
	glVertex3f(-.1f,h,-.05f);
	glVertex3f( .1f,h,-.05f);
	glVertex3f( .1f,0,-.05f);
	glVertex3f(-.1f,0,-.05f);
  glEnd();
  glFrontFace(GL_CCW);	
}
Exemple #8
0
void SimpleHouse3::draw(DrawingState*)
{
  glColor3fv(&color.r);
  fetchTexture("simpleHouse2-front.png");
  polygoni(4, -20, 0,-20,  20, 0,-20,  20,30,-20,  -20,30,-20);
  fetchTexture("simpleHouse3-side.png");
  polygoni(4,  20, 0,-20,  20, 0, 20,  20,30, 20,   20,30,-20);
  fetchTexture("simpleHouse2-front.png");
  polygoni(4,  20, 0, 20, -20, 0, 20, -20,30, 20,   20,30, 20);
  fetchTexture("simpleHouse3-side.png");
  polygoni(4, -20, 0, 20, -20, 0,-20, -20,30,-20,  -20,30, 20);
  fetchTexture("roof3.png");
  polygoni(3, -20,30,-20,  20,30,-20,   0,45,0);
  polygoni(3,  20,30,-20,  20,30, 20,   0,45,0);
  polygoni(3,  20,30, 20, -20,30, 20,   0,45,0);
  polygoni(3, -20,30, 20, -20,30,-20,   0,45,0);
}
void TextureManager::initalize()
{
	if(loadTexture("./resources/sprites/world.png")) {
		GLtexture* texture = fetchTexture("./resources/sprites/world.png");
		mBlockWidth = texture->width;
		mBlockHeight = texture->height;
	}
	loadTexture("./resources/sprites/vistest.png");
}
Exemple #10
0
void AirportBldg::draw(DrawingState*)
{
	glColor3fv(&color.r);
	glPushMatrix();
	glRotatef(180, 0, 1, 0);
	
	drawBridge(100, 10, 20, 6);

	polygon(4, 0.0, 25.0, 0.0, 0.0, 0.0, 0.0, 100.0, 0.0, 0.0, 100.0, 25.0, 0.0);
	polygon(-4, 0.0, 25.0, 0.0, 0.0, 0.0, 0.0, -50.0, 0.0, 50.0, -50.0, 40.0, 50.0);
	polygon(4, 100.0, 25.0, 0.0, 100.0, 0.0, 0.0, 150.0, 0.0, 50.0, 150.0, 40.0, 50.0);
	polygon(4, 150.0, 40.0, 50.0, 150.0, 0.0, 50.0, -50.0, 0.0, 50.0, -50.0, 40.0, 50.0);
	polygon(4, 0.0, 25.0, 0.0, 100.0, 25.0, 0.0, 150.0, 40.0, 50.0, -50.0, 40.0, 50.0);
	
	glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_DECAL);

	fetchTexture("arsenal2.jpg");
	glBegin(GL_QUAD_STRIP);
	glTexCoord2f(1,0);
	glVertex3f(-50.04, 0, 50.01);
	glTexCoord2f(1,1);
	glVertex3f(-50.04, 40.01, 50.01);
	glTexCoord2f(0.75,0);
	glVertex3f(-0.01, -0.01, -0.01);
	glTexCoord2f(0.75,0.75);
	glVertex3f(-0.01, 25.01, -0.01);
	glTexCoord2f(0.25,0);
	glVertex3f(100.01, -0.01, -0.01);
	glTexCoord2f(0.25,0.75);
	glVertex3f(100.01, 25.01, -0.01);
	glTexCoord2f(0,0);
	glVertex3f(150.04, -0.01, 50.01);
	glTexCoord2f(0,1);
	glVertex3f(150.04, 40.01, 50.01);
	glEnd();
	
	glBegin(GL_QUAD_STRIP);
	glTexCoord2f(1,1);
	glVertex3f(-50.04, 40.01, 50.01);
	glTexCoord2f(0,1);
	glVertex3f(150.04, 40.01, 50.01);
	glTexCoord2f(0.75,0.75);
	glVertex3f(-0.01, 25.01, -0.01);
	glTexCoord2f(0.25,0.75);
	glVertex3f(100.01, 25.01, -0.01);
	glTexCoord2f(0.75,0);
	glVertex3f(0.01, -0.01, -0.01);
	glTexCoord2f(0.25,0);
	glVertex3f(100, -0.01, -0.01);
	glEnd();
	

	
	glColor3f(1.0, 1.0, 1.0);
	glPopMatrix();
	glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
Exemple #11
0
// note - we use a polygon offset to move road a little above ground
// to avoid Z-Fighting
void Road::draw(DrawingState*)
{
  glEnable(GL_POLYGON_OFFSET_FILL);
  glPolygonOffset(-1.,-2.);
  glColor3f(.6f,.6f,.6f);
  glNormal3f(0,1,0);
  fetchTexture("road2.jpg", true, true);
  roadDraw();
  glDisable(GL_POLYGON_OFFSET_FILL);

  // add yourself to the list of roads
  theRoads.push_back(this);
}
Exemple #12
0
void Ground::draw(DrawingState* ds) {
  glColor3f(1.0, 1.0, 1.0);
  if (ds->drGrTex)
    fetchTexture("metal.png", true, true);
  else {
    glBindTexture(GL_TEXTURE_2D, 0);
    glColor3f(0.25, 0.7, 0.3);
  }
  
  glNormal3f(0, 1, 0);
  
  glBegin(GL_QUADS);
  glTexCoord2f(0, 0);     glVertex3f(0, 0, 0);
  glTexCoord2f(0, 8);     glVertex3f(0, 0, 230);
  glTexCoord2f(18, 8);     glVertex3f(530, 0, 230);
  glTexCoord2f(18, 0);     glVertex3f(530, 0, 0);
  glEnd();

  glBindTexture(GL_TEXTURE_2D, 0);
}
Exemple #13
0
void Lawn::draw(DrawingState* d)
{
  // the catch here is that we need to use a polygon offset to draw
  // the lawn just above the ground...
  if (d->drGrTex)
	fetchTexture("grass.png",true,true);
  else
    glBindTexture(GL_TEXTURE_2D,0);
  glEnable(GL_POLYGON_OFFSET_FILL);
  glPolygonOffset(-2.,-2.);
  glNormal3f(0,1,0);
  glColor3f(0,1,1);
  glBegin(GL_POLYGON);
  glTexCoord2f(0,(z2-z1)/4.f);            glVertex3f(x1,0,z2);
  glTexCoord2f((x2-x1)/4.f, (z2-z1)/4.f); glVertex3f(x2,0,z2);
  glTexCoord2f((x2-x1)/4.f,0);            glVertex3f(x2,0,z1);
  glTexCoord2f(0,0);                      glVertex3f(x1,0,z1);
  glEnd();
  glDisable(GL_POLYGON_OFFSET_FILL);
  glBindTexture(GL_TEXTURE_2D,0);
}
Exemple #14
0
void Car::drawBody(DrawingState*)
{
	/*
	polygon(-4, -w,h,0., -w,h+t,0., w,h+t,0., w,h,0.);
	polygon(4, -w,h,r+f, -w,h+t,r+f, w,h+t,r+f, w,h,r+f);
	polygon(-4, w,t+h,0., -w,t+h,0., -w,t+h,f+r, w,t+h,f+r);
	polygon(4, w,h,0., -w,h,0., -w,h,f+r, w,h,f+r);
    polygon(-4, w,t+h,0., w,t+h,f+r, w,h,f+r, w,h,0.);
	polygon(4, -w,t+h,0., -w,t+h,f+r, -w,h,f+r, -w,h,0.);
	*/
	//=============================================================
	// Now the cars are simply boxes with different hights. 
    // TODO2: To make the cars look more realistic and add texutres. 
	// lamp

	fetchTexture("car_eye.bmp");
	polygon(-4, -w, h, 0., -w, h + m - a, 0., w, h + m - a, 0., w, h, 0.);
	glBindTexture(GL_TEXTURE_2D, 0);
	fetchTexture("car_hood_1.bmp");
	// hood
	polygon(-4, -w, h + m - a, 0., -w, h + m, f, w, h + m, f, w, h + m - a, 0.);
	glBindTexture(GL_TEXTURE_2D, 0);
	//fetchTexture("car_side_3.jpg");
	//fenders
	polygon(-4, -w, h, 0., -w, h, f, -w, h + m, f, -w, h + m - a, 0.); 
	polygon(4, w, h, 0., w, h, f, w, h + m, f, w, h + m - a, 0.);

	// top
	fetchTexture("car_top_1.bmp");
	polygon(-4, -w + sr, t + h, f, -w + sr, t + h, f + r - br, w - sr, t + h, f + r - br, w - sr, t + h, f);
	glBindTexture(GL_TEXTURE_2D, 0);
	if (!sideTexture)
	{
		sideTexture = fetchTexture("suv-side.png"); // fetch does the bind
		//sideTexture = fetchTexture("windshield_full.bmp");
		//sideTexture = fetchTexture("car_side_3.jpg");
	}
	else sideTexture->bind();
	// left side (x-), right side (x+), bottoms
	polygon(-4, -w, h + m, f - s, -w, h + m, f + r, -w + sr, t + h, f + r - br, -w + sr, t + h, f);
	polygon(4, w, h + m, f - s, w, h + m, f + r, w - sr, t + h, f + r - br, w - sr, t + h, f);// right buttom

	// left side (x-), right side (x+), tops
	
	glBindTexture(GL_TEXTURE_2D, 0);
	fetchTexture("car_side_2.bmp");
	polygon(-4, -w, h, f, -w, h, f + r, -w, m + h, f + r, -w, m + h, f);
	polygon(4, w, h, f, w, h, f + r, w, m + h, f + r, w, m + h, f);

	// Bind texture
	
	if (!frontTexture)
	{
		frontTexture = fetchTexture("suv-front.png"); // fetch does the bind
		//frontTexture = fetchTexture("windshield_full.jpg");
		
	}
	else frontTexture->bind();
	
	polygon(-4, -w, h + m, f - s, -w + sr, t + h, f, w - sr, t + h, f, w, h + m, f - s); 
	/*
	if (!backTexture)
	{
		backTexture = fetchTexture("windshield_full.bmp");; // fetch does the bind
		//frontTexture = fetchTexture("windshield_full.bmp");
	}
	else backTexture->bind();
	*/
	fetchTexture("suv-front.png");
	//fetchTexture("windshield_full.jpg");
	polygon(4, -w, h + m, f + r, -w + sr, t + h, f + r - br, w - sr, t + h, f + r - br, w, h + m, f + r);
	// remember to unbind the texture so that we don't keep using it
	glBindTexture(GL_TEXTURE_2D, 0);

	// rear
	fetchTexture("car_rear_1.bmp");
	polygon(4, -w, h, f + r, -w, h + m, f + r, w, h + m, f + r, w, h, f + r);
	glBindTexture(GL_TEXTURE_2D, 0);

}