void Health::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int healthLevel = -1; if( _isVisibleObject( overlay->type() ) ) { // Base set of visible objects needDrawAnimations = true; } else if( _flags.count( overlay->type() ) ) { needDrawAnimations = true; //city::Helper helper( _city() ); //drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } else if( overlay->type() == object::house ) { HousePtr house = ptr_cast<House>( overlay ); healthLevel = _getLevelValue( house ); needDrawAnimations = (house->spec().level() == 1) && (house->habitants().empty()); if( !needDrawAnimations ) { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } } else //other buildings { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( healthLevel > 0 ) { drawColumn( engine, screenPos, healthLevel ); } } tile.setWasDrawn(); }
void Unemployed::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); WorkingBuildingPtr workBuilding = overlay.as<WorkingBuilding>(); int worklessPercent = 0; if( _isVisibleObject( overlay->type() ) ) { needDrawAnimations = true; } else if( overlay->type() == object::house ) { HousePtr house = overlay.as<House>(); int worklessNumber = (int)house->getServiceValue( Service::recruter ); int matureNumber = (int)house->habitants().mature_n(); worklessPercent = math::percentage( worklessNumber, matureNumber ); needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty(); if( !needDrawAnimations ) { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } } else if( workBuilding.isValid() ) { worklessPercent = math::percentage( workBuilding->needWorkers(), workBuilding->maximumWorkers() ); needDrawAnimations = workBuilding->needWorkers() > 0; if( !needDrawAnimations ) drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( worklessPercent > 0 ) { drawColumn( engine, screenPos, worklessPercent ); } } tile.setWasDrawn(); }
void Religion::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int religionLevel = -1; if( _isVisibleObject( overlay->type() ) ) { // Base set of visible objects needDrawAnimations = true; } else if( overlay->type() == object::house ) { HousePtr house = ptr_cast<House>( overlay ); religionLevel = (int) house->getServiceValue(Service::religionMercury); religionLevel += house->getServiceValue(Service::religionVenus); religionLevel += house->getServiceValue(Service::religionMars); religionLevel += house->getServiceValue(Service::religionNeptune); religionLevel += house->getServiceValue(Service::religionCeres); religionLevel = math::clamp( religionLevel / (house->spec().minReligionLevel()+1), 0, 100 ); needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty(); if( !needDrawAnimations ) { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } } else { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( religionLevel > 0 ) { drawColumn( engine, screenPos, religionLevel ); } } tile.setWasDrawn(); }
void Tax::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int taxLevel = -1; if( _isVisibleObject( overlay->type() ) ) { // Base set of visible objects needDrawAnimations = true; } else if( overlay->type() == object::house ) { auto house = overlay.as<House>(); int taxAccess = house->getServiceValue( Service::forum ); taxLevel = math::clamp<int>( house->taxesThisYear(), 0, 100 ); needDrawAnimations = ((house->level() <= HouseLevel::hovel && house->habitants().empty()) || taxAccess < 25); if( !needDrawAnimations ) { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } } else { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( taxLevel > 0 ) { drawColumn( engine, screenPos, taxLevel ); } } tile.setRendered(); }
void Fire::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int fireLevel = 0; if( _isVisibleObject( overlay->type() ) ) { // Base set of visible objects needDrawAnimations = true; } else if( overlay->type() == object::house ) { HousePtr house = ptr_cast<House>( overlay ); fireLevel = (int)house->state( pr::fire ); needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty(); drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } else //other buildings { ConstructionPtr constr = ptr_cast<Construction>( overlay ); if( constr != 0 ) { fireLevel = (int)constr->state( pr::fire ); } drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( fireLevel >= 0) { _addColumn( screenPos, fireLevel ); } } tile.setWasDrawn(); }
void Sentiment::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int sentimentLevel = 0; if( _isVisibleObject( overlay->type() ) ) { needDrawAnimations = true; } else if( overlay->type() == object::house ) { HousePtr house = overlay.as<House>(); sentimentLevel = (int)house->state( pr::happiness ); needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty(); if( !needDrawAnimations ) { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } } else { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( sentimentLevel > 0 ) { drawColumn( engine, screenPos, 100 - sentimentLevel ); } } tile.setWasDrawn(); }
void Entertainment::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int entertainmentLevel = -1; if( _isVisibleObject( overlay->type() ) ) { // Base set of visible objects needDrawAnimations = true; } else if( _flags.count( overlay->type() ) > 0 ) { needDrawAnimations = true; } else if( overlay->type() == object::house ) { auto house = overlay.as<House>(); entertainmentLevel = _getLevelValue( house ); needDrawAnimations = (house->level() <= HouseLevel::hovel) && (house->habitants().empty()); drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } else { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( entertainmentLevel > 0 ) { drawColumn( engine, screenPos, entertainmentLevel ); } } tile.setRendered(); }
void MarketAccess::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int accessLevel = 0; if( _isVisibleObject( overlay->type() ) ) { needDrawAnimations = true; } else if( overlay->type() == object::house ) { auto house = overlay.as<House>(); accessLevel = (int)house->getServiceValue( Service::market ); needDrawAnimations = (house->level() <= HouseLevel::hovel) && house->habitants().empty(); if( !needDrawAnimations ) { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } } else { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( accessLevel >= 0 ) { drawColumn( engine, screenPos, accessLevel ); } } tile.setRendered(); }
void Aborigens::drawTile(Engine& engine, Tile& tile, const Point& offset) { Point screenPos = tile.mappos() + offset; if( tile.overlay().isNull() ) { //draw background //engine.draw( tile.picture(), screenPos ); drawPass( engine, tile, offset, Renderer::ground ); drawPass( engine, tile, offset, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int discontentLevel = 0; if( _isVisibleObject( overlay->type() ) ) { needDrawAnimations = true; } else if( overlay->type() == object::native_hut ) { auto nativeHut = overlay.as<NativeHut>(); discontentLevel = (int)nativeHut->discontent(); needDrawAnimations = false; drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase ); } else { drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base ); } if( needDrawAnimations ) { Layer::drawTile( engine, tile, offset ); registerTileForRendering( tile ); } else if( discontentLevel >= 0 ) { drawColumn( engine, screenPos, discontentLevel ); } } tile.setRendered(); }
void Crime::drawTile( const RenderInfo& rinfo, Tile& tile) { if( tile.overlay().isNull() ) { drawPass( rinfo, tile, Renderer::ground ); drawPass( rinfo, tile, Renderer::groundAnimation ); } else { bool needDrawAnimations = false; OverlayPtr overlay = tile.overlay(); int crime = -1; if( _isVisibleObject( overlay->type() ) ) { needDrawAnimations = true; } else if( overlay->type() == object::house ) { auto house = overlay.as<House>(); crime = (int)house->getServiceValue( Service::crime ); needDrawAnimations = (house->level() <= HouseLevel::hovel) && house->habitants().empty(); // In case of vacant terrain drawArea( rinfo, overlay->area(), config::layer.ground, config::tile.house ); } else { drawArea( rinfo, overlay->area(), config::layer.ground, config::tile.constr ); } if( needDrawAnimations ) { Layer::drawTile( rinfo, tile ); registerTileForRendering( tile ); } else if( crime >= 0) { Point screenPos = tile.mappos() + rinfo.offset; drawColumn( rinfo, screenPos, crime ); } } tile.setRendered(); }
void OGLRenderer::renderScene(void)const{ shader->bind(); { fboPass(); drawPass(); } shader->unbind(); glwsSwapBuffers(); }
void MapChunk::drawContour() { if (!DrawMapContour) return; glColor4f(1, 1, 1, 1); glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_ALPHA_TEST); if (Contour == 0) GenerateContourMap(); glBindTexture(GL_TEXTURE_2D, Contour); glEnable(GL_TEXTURE_GEN_S); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, CoordGen); drawPass(-1); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); }
void MapChunk::draw() { if (!gWorld->frustum.intersects(vmin, vmax)) return; float mydist = (gWorld->camera - vcenter).length() - r; if (mydist > (mapdrawdistance * mapdrawdistance)) return; // setup vertex buffers glBindBuffer(GL_ARRAY_BUFFER, vertices); glVertexPointer(3, GL_FLOAT, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, normals); glNormalPointer(GL_FLOAT, 0, 0); // ASSUME: texture coordinates set up already // first pass: base texture if (textureSet->num() == 0U) { OpenGL::Texture::setActiveTexture(0); OpenGL::Texture::disableTexture(); OpenGL::Texture::setActiveTexture(1); OpenGL::Texture::disableTexture(); glColor3f(1.0f, 1.0f, 1.0f); } else { textureSet->bindTexture(0, 0); OpenGL::Texture::setActiveTexture(1); OpenGL::Texture::disableTexture(); } glEnable(GL_LIGHTING); drawPass(-1); if (textureSet->num() > 1U) { //glDepthFunc(GL_EQUAL); // GL_LEQUAL is fine too...? glDepthMask(GL_FALSE); } // additional passes: if required for (size_t i = 1; i < textureSet->num(); ++i) { // this time, use blending: textureSet->bindTexture(i, 0); textureSet->bindAlphamap(i - 1, 1); drawPass(i); } if (textureSet->num() > 1U) { //glDepthFunc(GL_LEQUAL); glDepthMask(GL_TRUE); } // shadow map glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); Vec3D shc = gWorld->skies->colorSet[WATER_COLOR_DARK] * 0.3f; glColor4f(shc.x, shc.y, shc.z, 1); //glColor4f(1,1,1,1); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, shadow); glEnable(GL_TEXTURE_2D); drawPass(-1); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); drawContour(); if (terrainMode == 5) { // draw chunk white if impassible flag is set if (Flags & FLAG_IMPASS) { glColor4f(1, 1, 1, 0.6f); drawPass(-1); } } if (terrainMode == 6) { if (water) { glColor4f(0.2f, 0.2f, 0.8f, 0.6f); drawPass(-1); } } if (terrainMode == 4) { // draw chunks in color depending on AreaID and list color from environment if (Environment::getInstance()->areaIDColors.find(areaID) != Environment::getInstance()->areaIDColors.end()) { Vec3D colorValues = Environment::getInstance()->areaIDColors.find(areaID)->second; glColor4f(colorValues.x, colorValues.y, colorValues.z, 0.7f); drawPass(-1); } } if (terrainMode == 8) { glBindBuffer(GL_ARRAY_BUFFER, mccvEntry); glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0); glEnableClientState(GL_COLOR_ARRAY); drawPass(-1); glDisableClientState(GL_COLOR_ARRAY); } if (Environment::getInstance()->cursorType == 3) { if (gWorld->IsSelection(eEntry_MapChunk) && gWorld->GetCurrentSelection()->data.mapchunk == this && terrainMode != 3) { int poly = gWorld->GetCurrentSelectedTriangle(); glColor4f(1.0f, 1.0f, 0.0f, 1.0f); glPushMatrix(); glDisable(GL_CULL_FACE); glDepthMask(false); glDisable(GL_DEPTH_TEST); glBegin(GL_TRIANGLES); glVertex3fv(mVertices[gWorld->mapstrip2[poly + 0]]); glVertex3fv(mVertices[gWorld->mapstrip2[poly + 1]]); glVertex3fv(mVertices[gWorld->mapstrip2[poly + 2]]); glEnd(); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glDepthMask(true); glPopMatrix(); } } glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_LIGHTING); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }