void CProjectileHandler::DrawProjectilesMiniMap(const ProjectileContainer& pc) { if (pc.render_size() > 0) { CVertexArray* lines = GetVertexArray(); CVertexArray* points = GetVertexArray(); lines->Initialize(); lines->EnlargeArrays(pc.render_size() * 2, 0, VA_SIZE_C); points->Initialize(); points->EnlargeArrays(pc.render_size(), 0, VA_SIZE_C); for (ProjectileContainer::render_iterator pci = pc.render_begin(); pci != pc.render_end(); ++pci) { CProjectile* p = *pci; if ((p->owner() && (p->owner()->allyteam == gu->myAllyTeam)) || gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam)) { p->DrawOnMinimap(*lines, *points); } } lines->DrawArrayC(GL_LINES); points->DrawArrayC(GL_POINTS); } }
void CProjectileDrawer::DrawProjectilesMiniMap() { GML_RECMUTEX_LOCK(proj); // DrawProjectilesMiniMap typedef std::set<CProjectile*> ProjectileSet; typedef std::set<CProjectile*>::const_iterator ProjectileSetIt; typedef std::map<int, ProjectileSet> ProjectileBin; typedef std::map<int, ProjectileSet>::const_iterator ProjectileBinIt; for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { const ProjectileBin& projectileBin = modelRenderers[modelType]->GetProjectileBin(); if (!projectileBin.empty()) { for (ProjectileBinIt binIt = projectileBin.begin(); binIt != projectileBin.end(); ++binIt) { CVertexArray* lines = GetVertexArray(); CVertexArray* points = GetVertexArray(); lines->Initialize(); lines->EnlargeArrays((binIt->second).size() * 2, 0, VA_SIZE_C); points->Initialize(); points->EnlargeArrays((binIt->second).size(), 0, VA_SIZE_C); for (ProjectileSetIt setIt = (binIt->second).begin(); setIt != (binIt->second).end(); ++setIt) { CProjectile* p = *setIt; CUnit *owner = p->owner(); if ((owner && (owner->allyteam == gu->myAllyTeam)) || gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam)) { p->DrawOnMinimap(*lines, *points); } } lines->DrawArrayC(GL_LINES); points->DrawArrayC(GL_POINTS); } } } if (!renderProjectiles.empty()) { CVertexArray* lines = GetVertexArray(); CVertexArray* points = GetVertexArray(); lines->Initialize(); lines->EnlargeArrays(renderProjectiles.size() * 2, 0, VA_SIZE_C); points->Initialize(); points->EnlargeArrays(renderProjectiles.size(), 0, VA_SIZE_C); for (std::set<CProjectile*>::iterator it = renderProjectiles.begin(); it != renderProjectiles.end(); ++it) { CProjectile* p = *it; const CUnit* owner = p->owner(); if ((owner && (owner->allyteam == gu->myAllyTeam)) || gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam)) { p->DrawOnMinimap(*lines, *points); } } lines->DrawArrayC(GL_LINES); points->DrawArrayC(GL_POINTS); } }
void CMiniMap::DrawForReal() { SCOPED_TIMER("Draw minimap"); setSurfaceCircleFunc(DrawSurfaceCircle); setSurfaceSquareFunc(DrawSurfaceSquare); cursorIcons.Enable(false); //glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthFunc(GL_LEQUAL); if (minimized) { if (!slaveDrawMode) { DrawMinimizedButton(); } cursorIcons.Enable(true); setSurfaceCircleFunc(NULL); setSurfaceSquareFunc(NULL); return; } glViewport(xpos, ypos, width, height); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0e6, +1.0e6); glMatrixMode(GL_MODELVIEW); glColor4f(0.6f, 0.6f, 0.6f, 1.0f); // draw the map glDisable(GL_BLEND); readmap->DrawMinimap(); glEnable(GL_BLEND); // move some of the transform to the GPU glTranslatef(0.0f, +1.0f, 0.0f); glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.0f); GML_RECMUTEX_LOCK(unit); // DrawForReal // draw the units std::list<CUnit*>::iterator ui; for (ui = uh->renderUnits.begin(); ui != uh->renderUnits.end(); ui++) { DrawUnit(*ui); } // GML_RECMUTEX_LOCK(quad); // getselectunit accesses quadfield // highlight the selected unit CUnit* unit = GetSelectUnit(GetMapPosition(mouse->lastx, mouse->lasty)); if (unit != NULL) { DrawUnitHighlight(unit); } glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); left.clear(); // add restraints for camera sides GetFrustumSide(cam2->bottom); GetFrustumSide(cam2->top); GetFrustumSide(cam2->rightside); GetFrustumSide(cam2->leftside); if (!minimap->maximized) { // draw the camera lines std::vector<fline>::iterator fli,fli2; for(fli=left.begin();fli!=left.end();fli++){ for(fli2=left.begin();fli2!=left.end();fli2++){ if(fli==fli2) continue; float colz=0; if(fli->dir-fli2->dir==0) continue; colz=-(fli->base-fli2->base)/(fli->dir-fli2->dir); if(fli2->left*(fli->dir-fli2->dir)>0){ if(colz>fli->minz && colz<400096) fli->minz=colz; } else { if(colz<fli->maxz && colz>-10000) fli->maxz=colz; } } } glColor4f(1,1,1,0.5f); glBegin(GL_LINES); for(fli = left.begin(); fli != left.end(); fli++) { if(fli->minz < fli->maxz) { DrawInMap2D(fli->base + (fli->dir * fli->minz), fli->minz); DrawInMap2D(fli->base + (fli->dir * fli->maxz), fli->maxz); } } glEnd(); } glRotatef(-90.0f, +1.0f, 0.0f, 0.0f); // real 'world' coordinates // draw the projectiles if (drawProjectiles) { GML_RECMUTEX_LOCK(proj); // DrawForReal if(ph->ps.size()>0) { CVertexArray* lines=GetVertexArray(); CVertexArray* points=GetVertexArray(); lines->Initialize(); lines->EnlargeArrays(ph->ps.size()*2,0,VA_SIZE_C); points->Initialize(); points->EnlargeArrays(ph->ps.size(),0,VA_SIZE_C); Projectile_List::iterator psi; for(psi = ph->ps.begin(); psi != ph->ps.end(); ++psi) { CProjectile* p = *psi; if ((p->owner() && (p->owner()->allyteam == gu->myAllyTeam)) || gu->spectatingFullView || loshandler->InLos(p, gu->myAllyTeam)) { p->DrawOnMinimap(*lines, *points); } } lines->DrawArrayC(GL_LINES); points->DrawArrayC(GL_POINTS); } } // draw the queued commands // // NOTE: this needlessly adds to the CursorIcons list, but at least // they are not drawn (because the input receivers are drawn // after the command queues) LuaUnsyncedCtrl::DrawUnitCommandQueues(); if ((drawCommands > 0) && guihandler->GetQueueKeystate()) { selectedUnits.DrawCommands(); } glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // draw the selection shape, and some ranges if (drawCommands > 0) { guihandler->DrawMapStuff(!!drawCommands); } GML_RECMUTEX_LOCK(sel); // DrawForReal // draw unit ranges const float radarSquare = radarhandler->radarDiv; CUnitSet& selUnits = selectedUnits.selectedUnits; for(CUnitSet::iterator si = selUnits.begin(); si != selUnits.end(); ++si) { CUnit* unit = *si; if (unit->radarRadius && !unit->beingBuilt && unit->activated) { glColor3fv(cmdColors.rangeRadar); DrawCircle(unit->pos, (unit->radarRadius * radarSquare)); } if (unit->sonarRadius && !unit->beingBuilt && unit->activated) { glColor3fv(cmdColors.rangeSonar); DrawCircle(unit->pos, (unit->sonarRadius * radarSquare)); } if (unit->jammerRadius && !unit->beingBuilt && unit->activated) { glColor3fv(cmdColors.rangeJammer); DrawCircle(unit->pos, (unit->jammerRadius * radarSquare)); } // change if someone someday create a non stockpiled interceptor const CWeapon* w = unit->stockpileWeapon; if((w != NULL) && w->weaponDef->interceptor) { if (w->numStockpiled) { glColor3fv(cmdColors.rangeInterceptorOn); } else { glColor3fv(cmdColors.rangeInterceptorOff); } DrawCircle(unit->pos, w->weaponDef->coverageRange); } } glRotatef(+90.0f, +1.0f, 0.0f, 0.0f); // revert to the 2d xform // selection box glColor4f(1.0f, 1.0f, 1.0f, 1.0f); CMouseHandler::ButtonPress& bp = mouse->buttons[SDL_BUTTON_LEFT]; if (selecting && fullProxy && (bp.movement > 4)) { const float3 oldPos = GetMapPosition(bp.x, bp.y); const float3 newPos = GetMapPosition(mouse->lastx, mouse->lasty); glColor4fv(cmdColors.mouseBox); glBlendFunc((GLenum)cmdColors.MouseBoxBlendSrc(), (GLenum)cmdColors.MouseBoxBlendDst()); glLineWidth(cmdColors.MouseBoxLineWidth()); glBegin(GL_LINE_LOOP); DrawInMap2D(oldPos.x, oldPos.z); DrawInMap2D(newPos.x, oldPos.z); DrawInMap2D(newPos.x, newPos.z); DrawInMap2D(oldPos.x, newPos.z); glEnd(); glLineWidth(1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } DrawNotes(); // allow the LUA scripts to draw into the minimap eventHandler.DrawInMiniMap(); // reset the modelview glLoadIdentity(); if (!slaveDrawMode) { DrawButtons(); // outline glLineWidth(1.51f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glViewport(xpos - 1, ypos - 1, width + 2, height + 2); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glViewport(xpos - 2, ypos - 2, width + 4, height + 4); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.0f); } glViewport(gu->viewPosX, 0, gu->viewSizeX, gu->viewSizeY); cursorIcons.Enable(true); setSurfaceCircleFunc(NULL); setSurfaceSquareFunc(NULL); }