Пример #1
0
//--------------------------------------------------------------
// render the world
void ChunkWorld::render()
{
  m_chunkLock->lock();

  // figure which chunk we are in
  mgPoint3 eyePt;
  mgDisplay->getEyePt(eyePt);
  int viewX = (int) floor(eyePt.x / CHUNK_SIZE);
  int viewZ = (int) floor(eyePt.z / CHUNK_SIZE);

  drawHorizon(viewX, viewZ);

  // render all neighbors in the view list
  for (int i = m_viewListCount-1; i >= 0; i--)
  {
    ChunkOrigin* origin = &m_viewList[i];
    int x = CHUNK_SIZE*(viewX + origin->x);
    int z = CHUNK_SIZE*(viewZ + origin->z);

    const void* value;
    if (!m_chunkTable.lookup(x, 0, z, value))
      continue;  // outside world bounds
    ChunkObj* chunk = (ChunkObj*) value;

    // if chunk loaded and within view, render it
    if (chunk->m_status == CHUNK_INDISPLAY ||
        chunk->m_status == CHUNK_NEEDSUPDATE)
    {
      chunk->render(this);
    }
    else drawWater(x, z);
  }

  m_chunkLock->unlock();
}
Пример #2
0
void draw()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    drawWorld(scene->world);
    drawWater(scene->water);
}
Пример #3
0
// debug mode/retro style
void drawGame_TEST(Game * game)
{
	drawWater();
	drawTESTspikes(game);
	drawPlatform(game,5);
	drawTESTmissile(game);
	drawMissilesExp(game);
	drawTESTguy(game);
}
Пример #4
0
static void display()
{
   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   
   drawEnclosure();
   drawShowerHead();
   drawCrossBar();
   drawWater();
   
   glutSwapBuffers();
}
Пример #5
0
// all draw functions that get called in render funciton
void drawGame_Textures(Game * game)
{
	
	drawBackground(game);
	drawSpike(game);
	glBindTexture(GL_TEXTURE_2D, 0);	
	drawWater();
	drawPlatform(game,5);
	drawMissile(game);
	drawSkeleton(game);
	// used to allow non textures objects to maintain their color
	glBindTexture(GL_TEXTURE_2D, 0);	
}
void ComputeWaterSimulation::draw(void)
{
	glClearColor( 0.25f, 0.25f, 0.25f, 1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if (mReset) {
		mReset = false;
        doReset();
		mTweakBar->syncValues();
	}

	runWaterSimulation();
	drawWater();

	CHECK_GL_ERROR();
}
Пример #7
0
void renderScene(void) {
    mainPlane.manageHealth();
    
    //GLfloat lightpos[] = {-x,-z,-y};
    //glTranslatef(lightpos[0], lightpos[1], lightpos[2]);
    glColor3f(1, 1, 1);
    //glutSolidSphere(30, 20, 20);
    //glTranslatef(-lightpos[0], -lightpos[1], -lightpos[2]);
    //glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
	if (deltaMove)
		moveMeFlat(deltaMove);
	if (deltaAngle) {
		angle += deltaAngle;
		orientMe(angle);
        //rotateMe(angle);
	}
    if (rotationAngleDelta) {
        rotationAngle+=rotationAngleDelta;
        rotationAngleDelta=0;
        rotateMe(rotationAngle);
    }
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Draw ground
    glPushMatrix();
    //glLoadIdentity();
    //glTranslatef(x, y, z);
    //glRotatef(rotationAngle+90, 0, 1, 0);
    explosives.drawExplosions();
    //glTranslatef(-x, -y, -z);
    glPopMatrix();
	
    float minX=200000,maxX=0,minY=20000,maxY=0;
    glBegin(GL_QUADS);
    for (int i = 20; i <tiles.size()-20; i++) {
        for (int j = 20; j <tiles.size()-20; j++) {
            if(tiles[i][j].xMax>maxX) maxX = tiles[i][j].xMax;
            if(tiles[i][j].yMax>maxY) maxY = tiles[i][j].yMax;
            if(tiles[i][j].x<minX) minX = tiles[i][j].x;
            if(tiles[i][j].y<minY) minY = tiles[i][j].y;
            if (tiles[i][j].z>-.7) {
                tiles[i][j].drawTile();
            }
            
            
        }
    }
    drawWater(maxX*40,maxY*40,minX*40,minY*40);
	glEnd();
    
    drawTrees();
    drawBuildings();
    advanceLevel();
    drawPlane();
    
    
    //drawSilos();
    drawCarrierGroup();
    
    
    calculateFPS();
	glutSwapBuffers();
    //std::cout<<"hello";
    indexer++;
    if (loadBuildings) {
        loadBuildings = 0;
        cDetector.buildings = &buildings;
    }
    cDetector.detectCollisions();
    //glLoadIdentity();
    
    
}
static void
snowglobePaintInside (CompScreen *s,
                      const ScreenPaintAttrib *sAttrib,
                      const CompTransform     *transform,
                      CompOutput              *output,
                      int                     size)
{
    SNOWGLOBE_SCREEN (s);
    CUBE_SCREEN (s);

    int i;

    as->waterHeight = 50000;

    if (as->hsize!=s->hsize) updateSnowglobe (s);


    static const float mat_shininess[] = { 60.0 };
    static const float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
    static const float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
    static const float mat_ambient[] = { 0.1, 0.1, 0.3, 1.0 };
    static const float lmodel_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
    static const float lmodel_localviewer[] = { 0.0 };

    ScreenPaintAttrib sA = *sAttrib;
    CompTransform mT = *transform;

    if (snowglobeGetShowWater(s))
        updateHeight(as->water);

    sA.yRotate += cs->invert * (360.0f / size) *
                  (cs->xRotations - (s->x* cs->nOutput));

    (*s->applyScreenTransform)(s, &sA, output, &mT);

    glPushMatrix();

    glLoadMatrixf(mT.m);

    glTranslatef(cs->outputXOffset, -cs->outputYOffset, 0.0f);

    glScalef(cs->outputXScale, cs->outputYScale, 1.0f);

    Bool enabledCull = FALSE;

    glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT);

    glEnable(GL_BLEND);

    if (glIsEnabled(GL_CULL_FACE))
    {
        enabledCull = TRUE;
    }

    int cull;

    glGetIntegerv(GL_CULL_FACE_MODE, &cull);
    glEnable(GL_CULL_FACE);

    glCullFace(~cull & (GL_FRONT | GL_BACK));

    if (snowglobeGetShowWater(s))
    {
        glColor4usv(snowglobeGetWaterColor(s));
        drawWater(as->water, TRUE, FALSE);
    }
    glCullFace(cull);

    if (snowglobeGetShowGround(s))
    {
        glColor4f(0.8, 0.8, 0.8, 1.0);
        drawGround(NULL, as->ground);

    }

    glPushMatrix();

    glColor4usv(defaultColor);

    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);

    glEnable(GL_NORMALIZE);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT0);

    glEnable(GL_COLOR_MATERIAL);

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    for (i = 0; i < as->numSnowflakes; i++)
    {
        glPushMatrix();
        SnowflakeTransform(&(as->snow[i]));

        float scale = 0.01*as->snow[i].size;
        glScalef(scale, scale, scale);

        initDrawSnowflake();
        glCallList(as->snowflakeDisplayList);
        finDrawSnowflake();
        glPopMatrix();
    }

    if (snowglobeGetShowSnowman(s))
    {
        glPushMatrix();

        float bottom = -0.5;
        if (snowglobeGetShowGround(s))
            bottom = getHeight(as->ground, 0, 0);
        glTranslatef(0, bottom, 0);

        float scale = 0.4*snowglobeGetSnowmanSize(s)*(0.5-bottom);
        glScalef(scale, scale, scale);

        glColor4f(1.0, 1.0, 1.0, 1.0);

        DrawSnowman(0);
        glPopMatrix();
    }

    glPopMatrix();

    if (snowglobeGetShowWater(s))
    {
        glEnable(GL_CULL_FACE);
        glColor4usv(snowglobeGetWaterColor(s));
        drawWater(as->water, snowglobeGetShowWater(s), 0);
    }

    if (snowglobeGetShowGround(s))
    {
        glColor4f(0.8, 0.8, 0.8, 1.0);
        drawBottomGround(s->hsize * cs->nOutput, cs->distance, -0.4999);
    }

    glDisable(GL_LIGHT1);
    glDisable(GL_NORMALIZE);

    if (!s->lighting)
        glDisable(GL_LIGHTING);

    glDisable(GL_DEPTH_TEST);

    if (enabledCull)
        glDisable(GL_CULL_FACE);

    glPopMatrix();

    glPopAttrib();

    as->damage = TRUE;

    UNWRAP (as, cs, paintInside);
    (*cs->paintInside)(s, sAttrib, transform, output, size);
    WRAP (as, cs, paintInside, snowglobePaintInside);
}