void CMiniMap::DrawForReal(bool use_geo) { SCOPED_TIMER("MiniMap::DrawForReal"); //glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPushAttrib(GL_DEPTH_BUFFER_BIT); glDisable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glDepthMask(GL_FALSE); glDisable(GL_TEXTURE_2D); glMatrixMode(GL_MODELVIEW); if (minimized) { if (!slaveDrawMode) { DrawMinimizedButton(); } glPopAttrib(); glEnable(GL_TEXTURE_2D); return; } // draw the frameborder if (!slaveDrawMode && !globalRendering->dualScreenMode && !maximized) { glEnable(GL_BLEND); DrawFrame(); glDisable(GL_BLEND); } bool resetTextureMatrix = false; if (use_geo) { glPushMatrix(); // switch to normalized minimap coords if (globalRendering->dualScreenMode) { glViewport(xpos, ypos, width, height); glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); } else { glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); } /* FIXME: fix mouse handling too and make it fully customizable, so Lua can rotate the minimap to any angle CCameraController* camController = &camHandler->GetCurrentController(); COverheadController* taCam = dynamic_cast<COverheadController*>(camController); SmoothController* smCam = dynamic_cast<SmoothController*>(camController); if ((taCam && taCam->flipped) || (smCam && smCam->flipped)) { glTranslatef(1.0f, 1.0f, 0.0f); glScalef(-1.0f, -1.0f, 1.0f); glMatrixMode(GL_TEXTURE); glPushMatrix(); glTranslatef(1.0f, 1.0f, 0.0f); glScalef(-1.0f, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); resetTextureMatrix = true; }*/ } setSurfaceCircleFunc(DrawSurfaceCircle); setSurfaceSquareFunc(DrawSurfaceSquare); cursorIcons.Enable(false); glColor4f(0.6f, 0.6f, 0.6f, 1.0f); // don't mirror the map texture with flipped cameras glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); // draw the map glDisable(GL_BLEND); readmap->DrawMinimap(); glEnable(GL_BLEND); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); // clip everything outside of the minimap box { const double plane0[4] = {0,-1,0,1}; const double plane1[4] = {0,1,0,0}; const double plane2[4] = {-1,0,0,1}; const double plane3[4] = {1,0,0,0}; glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom glClipPlane(GL_CLIP_PLANE1, plane1); // clip top glClipPlane(GL_CLIP_PLANE2, plane2); // clip right glClipPlane(GL_CLIP_PLANE3, plane3); // clip left glEnable(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE1); glEnable(GL_CLIP_PLANE2); glEnable(GL_CLIP_PLANE3); } // switch to top-down map/world coords (z is twisted with y compared to the real map/world coords) glPushMatrix(); glTranslatef(0.0f, +1.0f, 0.0f); glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0f); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.0f); { GML_RECMUTEX_LOCK(unit); // DrawForReal unitDrawer->DrawUnitMiniMapIcons(); } glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); glPushMatrix(); glRotatef(-90.0f, +1.0f, 0.0f, 0.0f); // real 'world' coordinates glScalef(1.0f, 0.0f, 1.0f); // skip the y-coord (Lua's DrawScreen is perspective and so any z-coord in it influence the x&y, too) // draw the projectiles if (drawProjectiles) { glPointSize(1.0f); WorkaroundATIPointSizeBug(); projectileDrawer->DrawProjectilesMiniMap(); } // 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(); } lineDrawer.DrawAll(); // 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); } } } glPopMatrix(); // revert to the 2d xform if (!minimap->maximized) { // draw the camera frustum lines cam2->GetFrustumSides(0.0f, 0.0f, 1.0f, true); cam2->ClipFrustumLines(true, -10000.0f, 400096.0f); const std::vector<CCamera::FrustumLine>& negSides = cam2->negFrustumSides; // const std::vector<CCamera::FrustumLine>& posSides = cam2->posFrustumSides; std::vector<CCamera::FrustumLine>::const_iterator fli; CVertexArray* va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(negSides.size() * 2, 0, VA_SIZE_2D0); for (fli = negSides.begin(); fli != negSides.end(); ++fli) { if (fli->minz < fli->maxz) { va->AddVertex2dQ0(fli->base + (fli->dir * fli->minz), fli->minz); va->AddVertex2dQ0(fli->base + (fli->dir * fli->maxz), fli->maxz); } } glLineWidth(2.5f); glColor4f(0, 0, 0, 0.5f); va->DrawArray2d0(GL_LINES); glLineWidth(1.5f); glColor4f(1, 1, 1, 0.75f); va->DrawArray2d0(GL_LINES); glLineWidth(1.0f); } // selection box glColor4f(1.0f, 1.0f, 1.0f, 1.0f); CMouseHandler::ButtonPressEvt& 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()); float verts[] = { oldPos.x, oldPos.z, newPos.x, oldPos.z, newPos.x, newPos.z, oldPos.x, newPos.z, }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, verts); glDrawArrays(GL_LINE_LOOP, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glLineWidth(1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } DrawNotes(); // reset 1 if (resetTextureMatrix) { glMatrixMode(GL_TEXTURE_MATRIX); glPopMatrix(); } glMatrixMode(GL_MODELVIEW); if (use_geo) { glPopMatrix(); } // reset 2 glPopMatrix(); glPopAttrib(); glEnable(GL_TEXTURE_2D); { //! prepare ClipPlanes for Lua's DrawInMinimap Modelview matrix //! quote from glClipPlane spec: //! "When glClipPlane is called, equation is transformed by the inverse of the modelview matrix and stored in the resulting eye coordinates. //! Subsequent changes to the modelview matrix have no effect on the stored plane-equation components." //! -> we have to use the same modelview matrix when calling glClipPlane and later draw calls //! set the modelview matrix to the same as used in Lua's DrawInMinimap glPushMatrix(); glLoadIdentity(); glScalef(1.0f / width, 1.0f / height, 1.0f); const double plane0[4] = {0, -1, 0, double(height)}; const double plane1[4] = {0, 1, 0, 0}; const double plane2[4] = {-1, 0, 0, double(width)}; const double plane3[4] = {1, 0, 0, 0}; glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom glClipPlane(GL_CLIP_PLANE1, plane1); // clip top glClipPlane(GL_CLIP_PLANE2, plane2); // clip right glClipPlane(GL_CLIP_PLANE3, plane3); // clip left glPopMatrix(); } //! allow the LUA scripts to draw into the minimap eventHandler.DrawInMiniMap(); if (use_geo && globalRendering->dualScreenMode) glViewport(globalRendering->viewPosX,0,globalRendering->viewSizeX,globalRendering->viewSizeY); //FIXME: Lua modifies the matrices w/o reseting it! (quite complexe to fix because ClearMatrixStack() makes it impossible to use glPushMatrix) glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,1,0,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // disable ClipPlanes glDisable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE1); glDisable(GL_CLIP_PLANE2); glDisable(GL_CLIP_PLANE3); cursorIcons.Enable(true); setSurfaceCircleFunc(NULL); setSurfaceSquareFunc(NULL); }
/** * @param {short} xi_type 0 : RC pilot view * 1 : fly behind view * 2 : upper view * @return helicopter model, ground, sky and shadow on screen drawing **/ void DrawScene(short xi_type) { // statics (scene lighting definitions) static const GLfloat groundAmbient[4] = {0.02f, 0.3f, 0.1f, 1.0f}, local_ambient[4] = {0.7f, 0.7f, 0.7f, 1.0f}, ambient0[4] = {0.0f, 0.0f, 0.0f, 1.0f}, diffuse0[4] = {1.0f, 1.0f, 1.0f, 1.0f}, specular0[4] = {1.0f, 0.0f, 0.0f, 1.0f}, position0[4] = {2.0f, 100.5f, 1.5f, 1.0f}, ambient1[4] = {0.0f, 0.0f, 0.0f, 1.0f}, diffuse1[4] = {1.0f, 1.0f, 1.0f, 1.0f}, specular1[4] = {1.0f, 0.0f, 0.0f, 1.0f}, position1[4] = {-2.0f, 100.5f, 1.0f, 0.0f}; // statics (squashing matrix; 3D -> 2D) static const float mat[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; // locals int e; float X, Y, Z; double camera[3], destination[3], up[3]; // view port // scene light definitions glLightModelfv(GL_LIGHT_MODEL_AMBIENT, local_ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); glLightfv(GL_LIGHT0, GL_POSITION, position0); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); glLightfv(GL_LIGHT0, GL_SPECULAR, specular0); glEnable(GL_LIGHT1); glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1); glLightfv(GL_LIGHT1, GL_POSITION, position1); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1); glLightfv(GL_LIGHT1, GL_SPECULAR, specular1); // A/V position X = heli.cg.NED[_NORTH]; // North = X computer frame Y = -heli.cg.NED[_DOWN]; // Down = -Y computer frame Z = heli.cg.NED[_EAST]; // East = Z computer frame // clear view port glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // view port if (xi_type == 0) { camera[_X] = 1.0; camera[_Y] = 6.0; camera[_Z] = 30.0; destination[_X] = X; destination[_Y] = Y; destination[_Z] = Z; up[_X] = 0.0; up[_Y] = 1.0; up[_Z] = 0.0; } else if (xi_type == 1) { camera[_X] = X - 10 * cos(heli.cg.THETA[_PSI]); camera[_Y] = Y + 1; camera[_Z] = Z - 10 * sin(heli.cg.THETA[_PSI]); destination[_X] = X; destination[_Y] = Y; destination[_Z] = Z; up[_X] = 0.0; up[_Y] = 1.0; up[_Z] = 0.0; } else if (xi_type == 2){ camera[_X] = X; camera[_Y] = 50; camera[_Z] = Z; destination[_X] = X; destination[_Y] = Y; destination[_Z] = Z; up[_X] = 1.0; up[_Y] = 1.0; up[_Z] = 0.0; } gluLookAt(camera[_X], camera[_Y], camera[_Z], destination[_X], destination[_Y], destination[_Z], up[_X], up[_Y], up[_Z]); glEnable(GL_NORMALIZE); glDisable(GL_LIGHTING); // origin heli pad lines glLineWidth(3.0f); glColor3f(0.0f, 0.0f, 1.0f); glBegin(GL_LINES); glVertex3f( 0.0f, 1.0f, 0.0f); glVertex3f( 0.0f, 0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glEnd(); // origin heli pad circle DrawCircle(0.0, 0.0, 1.0, 8); glLineWidth(1.0f); //ground glEnable(GL_LIGHTING); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, groundAmbient); glBegin(GL_POLYGON); glNormal3f(0.0f, 1.0f, 0.0f); glVertex3f(31200.0f, -0.0f, -31200.0f); glVertex3f(-31200.0f, -0.0f, -31200.0f); glVertex3f(-31200.0f, -0.0f, 31200.0f); glVertex3f(31200.0f, -0.0f, 31200.0f); glEnd(); glDisable(GL_LIGHTING); for(e = -1000; e <= 1000; e += 50) { glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); glVertex3f(e, 0.8, -1000.0f); glVertex3f(e, 0.8, 1000.0f); glVertex3f(-1000.0f, 0.8, e); glVertex3f(1000.0f, 0.8, e); glEnd(); } glEnable(GL_LIGHTING); glPushMatrix(); glTranslatef(X, Y, Z); glRotatef(heli.cg.THETA[_PSI]*C_RAD2DEG, 0.0f, -1.0f, 0.0); glRotatef(heli.cg.THETA[_THETA]*C_RAD2DEG, 0.0f, 0.0f, 1.0f); glRotatef(heli.cg.THETA[_PHI]*C_RAD2DEG, 1.0f, 0.0f, 0.0f); DrawXcellModel(); glPopMatrix(); /* for (i = 0; i < 6; i++) { glPushMatrix(); glTranslatef(X + pow(-1, i)*i*6, Y + 2*i, Z - i*7); glRotatef(xcell.cg.THETA[_PSI]*C_RAD2DEG + i*50, 0.0f, -1.0f, 0.0); // heading glRotatef(xcell.cg.THETA[_THETA]*C_RAD2DEG - i*3, 0.0f, 0.0f, 1.0f); // pitch glRotatef(xcell.cg.THETA[_PHI]*C_RAD2DEG + i*4, 1.0f, 0.0f, 0.0f); // roll DrawXcellModel(); glPopMatrix(); } */ glPushMatrix(); // Draw the shadows glMultMatrixf(mat); // Everything now is flattened onto the ground glTranslatef(X, 0.01, Z); glRotatef(heli.cg.THETA[_PSI] * C_RAD2DEG, 0.0f, -1.0f, 0.0); glRotatef(heli.cg.THETA[_THETA] * C_RAD2DEG, 0.0f, 0.0f, 1.0f); glRotatef(heli.cg.THETA[_PHI] * C_RAD2DEG, 1.0f, 0.0f, 0.0f); DrawXcellShadowModel(); glPopMatrix(); }
void DrawGPSData( void ) { int tmp,barrapos,sinal,x,y; u8 str_buffer[0x10]; float valor; gps_data_t local_gps_data; get_gps_data(&local_gps_data); valor = local_gps_data.pos.lat; sprintf(str_buffer, "%03.6f", valor); GotoXY( 0, 0 ); PutText("LAT : ", LCD_PIXEL_ON); PutText(str_buffer, LCD_PIXEL_ON); valor = local_gps_data.pos.lon; sprintf(str_buffer, "%03.6f", valor); GotoXY( 0, 6 ); PutText("LON : ", LCD_PIXEL_ON); PutText(str_buffer, LCD_PIXEL_ON); valor = local_gps_data.pos.alt; sprintf(str_buffer, "%04.1f", valor); GotoXY( 0, 12 ); PutText("ALT : ", LCD_PIXEL_ON); PutText(str_buffer, LCD_PIXEL_ON); /* valor = local_gps_data.status.siu; sprintf(str_buffer, "%d", (int)valor); GotoXY( 70, 0 ); PutText("SAT : ", LCD_PIXEL_ON); PutText(str_buffer, LCD_PIXEL_ON); valor = local_gps_data.pos.cor; sprintf(str_buffer, "%d", (int)valor); GotoXY( 70, 6 ); PutText("CUR : ", LCD_PIXEL_ON); PutText(str_buffer, LCD_PIXEL_ON); valor = local_gps_data.pos.spd; sprintf(str_buffer, "%d", (int)valor); GotoXY( 70, 12 ); PutText("SPE : ", LCD_PIXEL_ON); PutText(str_buffer, LCD_PIXEL_ON); */ GotoXY( 0, 51 ); PutText(local_gps_data.datetime.date, LCD_PIXEL_ON); PutText(" ", LCD_PIXEL_ON); PutText(local_gps_data.datetime.time, LCD_PIXEL_ON); DrawCircle( 95,30,30, LCD_PIXEL_ON ); DrawCircle( 95,30,20, LCD_PIXEL_ON ); DrawCircle( 95,30,10, LCD_PIXEL_ON ); DrawCircle( 95,30,1, LCD_PIXEL_ON ); barrapos = 2; for(tmp = 0; tmp < 12; tmp++) { valor = local_gps_data.sat_inview[tmp].snr; sinal = (int)valor / 5; DrawRectangle( barrapos - 1,27, barrapos + 1, 49, LCD_PIXEL_ON); DrawFillRectangle( barrapos - 1,49 - sinal, barrapos + 1, 49, LCD_PIXEL_ON); barrapos += 5; if ( valor > 0) { x = 95 + (30 - local_gps_data.sat_inview[tmp].ele / 3 ) * cos(local_gps_data.sat_inview[tmp].azi); y = 30 + (30 - local_gps_data.sat_inview[tmp].ele / 3 ) * sin(local_gps_data.sat_inview[tmp].azi); DrawCircle( x,y,3, LCD_PIXEL_ON ); DrawCircle( x,y,2, LCD_PIXEL_ON ); DrawCircle( x,y,1, LCD_PIXEL_ON ); DrawPoint( x,y, LCD_PIXEL_ON ); GotoXY( x - 1, y - 2 ); sprintf(str_buffer, "%01d", (int)tmp); PutText(str_buffer, LCD_PIXEL_OFF); } } }
void Ball::draw(Canvas *canvas){ DrawCircle(canvas,x,y,0,color); }
/** * Draw a simple 2D version of the pixar lamp */ void DrawLamp(void) { glPushMatrix(); // draw the base of the lamp glTranslatef(lamp.x, lamp.y, 0); glRotatef(joint_1_rot, 0, 0, -1); // joint 1, lamp rotation glColor3f(1, 1, 0); // yellow // the base glBegin(GL_TRIANGLES); glVertex3f(-4, 0, 0); glVertex3f(4, 0, 0); glVertex3f(0, 2, 0); glEnd(); glLineWidth(10); // make lines thicker glPushMatrix(); // rotate by joint 2 rotation and move up glTranslatef(0, 2, 0); glRotatef(joint_2_rot, 0, 0, -1); DrawCircle(0.25); // draw the second joint // draw the lamp arm glBegin(GL_LINES); glVertex3f(0, 0, 0); glVertex3f(0, 4, 0); glEnd(); glPushMatrix(); // rotate joint 3 and move up glTranslatef(0, 4, 0); glRotatef(joint_3_rot, 0, 0, 1); DrawCircle(0.25); // joint 3 glBegin(GL_LINES); glVertex3f(0, 0, 0); glVertex3f(0, 4, 0); glEnd(); glPushMatrix(); // rotate joint 4 and move up glTranslatef(0, 4, 0); glRotatef(joint_4_rot, 0, 0, -1); DrawCircle(0.25); // joint 4 // draw the light of the lamp glBegin(GL_TRIANGLES); glVertex3f(-3, -3, 0); glVertex3f(3, -3, 0); glVertex3f(0, 0, 0); glEnd(); glPopMatrix(); glPopMatrix(); glPopMatrix(); glLineWidth(1); // restore line width glPopMatrix(); }
void HPlotter::PlotPlacement() { if (!IsEnabled()) return; for (HCells::PlaceableCellsEnumeratorW cell = m_hd.Cells.GetPlaceableCellsEnumeratorW(); cell.MoveNext(); ) { PlotCell(cell, _GetCellColor(cell)); } Color terminalColor = Color_Red; Color terminalBackColor = Color_Desktop; double startX, startY; double finishX, finishY; for (HCells::TerminalsEnumeratorW terminal = m_hd.Cells.GetTerminalsEnumeratorW(); terminal.MoveNext(); ) { //draw border of cells startX = terminal.X(); startY = terminal.Y(); finishX = terminal.X() + terminal.Width(); finishY = terminal.Y() + terminal.Height(); if ((startX < finishX) && (startY < finishY)) { DrawFilledRectangleWithBorder(startX, startY, finishX, finishY, terminalColor, terminalBackColor, false); } else { //Filled circle DrawCircle(startX, startY, 2, terminalBackColor, false, -1); } } //draw primary pins Color PIColor = Color_Green; Color POColor = Color_Red; double centerX, centerY; for (HPins::PrimariesEnumeratorW pin = m_hd.Pins.GetEnumeratorW(); pin.MoveNext(); ) { if (!::IsNull(pin.Net())) { centerX = pin.X(); centerY = pin.Y(); if (pin.IsPrimaryInput()) DrawCircle(centerX, centerY, 3, PIColor, false, -1); else DrawCircle(centerX, centerY, 3, POColor, false, -1); } } //draw placement region Color plBorderColor = Color_Red; startX = m_hd.Circuit.PlacementMinX(); startY = m_hd.Circuit.PlacementMinY(); finishX = m_hd.Circuit.PlacementMinX(); finishY = m_hd.Circuit.PlacementMaxY(); DrawLine(startX, startY, finishX, finishY, plBorderColor, false); startX = finishX; startY = finishY; finishX = m_hd.Circuit.PlacementMaxX(); finishY = m_hd.Circuit.PlacementMaxY(); DrawLine(startX, startY, finishX, finishY, plBorderColor, false); startX = finishX; startY = finishY; finishX = m_hd.Circuit.PlacementMaxX(); finishY = m_hd.Circuit.PlacementMinY(); DrawLine(startX, startY, finishX, finishY, plBorderColor, false); startX = finishX; startY = finishY; finishX = m_hd.Circuit.PlacementMinX(); finishY = m_hd.Circuit.PlacementMinY(); DrawLine(startX, startY, finishX, finishY, plBorderColor, false); //draw placement center centerX = (m_hd.Circuit.PlacementMinX() + m_hd.Circuit.PlacementMaxX()) / 2.0; centerY = (m_hd.Circuit.PlacementMinY() + m_hd.Circuit.PlacementMaxY()) / 2.0; DrawCircle(centerX, centerY, 4, Color_Black, false); DrawTextLine(); }
void CALLBACK WndProc(UINT32 message,UINT32 lParam,UINT32 wParam) { switch (message) { case WM_CREATE: { CDC *pDC=GetDC(); pDC->LCD_Init(); pDC->LCD_On(); pDC->Fill_Screen(WHITE); pDC->SetPixel(20,40,BLACK); pDC->MoveTo(20,20); pDC->LineTo(220,20); pDC->MoveTo(20,20); pDC->LineTo(20,300); pDC->MoveTo(20,300); pDC->LineTo(220,300); pDC->MoveTo(220,20); pDC->LineTo(220,300); //pDC->PrintAuthors(1,2); pDC->PrintMenu(50,100); char b[100]; IToA(b,154); PrintF("abc%d%def%d%s..",12,34,5,"nihao"); } break; case WM_TIMER: PrintF("WM_TIMER\n"); break; case WM_LBUTTONDOWN: if (flag == 1) { MoveTo(lParam,wParam); } if (flag == 2) { tempX = lParam; tempY = wParam; } //PrintF("WM_LBUTTONDOWN\n"); //PrintF("x=%d y=%d\n",lParam,wParam); break; case WM_LBUTTONUP: if (flag == 1) { LineTo(lParam,wParam); } if (flag == 2) { PrintF("%d,%d,%d\n",abs(wParam-tempY),tempX,tempY); if (abs(lParam - tempX) >= abs(wParam - tempY)) { DrawCircle((abs(wParam-tempY)/2+tempX),(tempY+wParam)/2,(abs(wParam - tempY)/2),BLACK); } else { DrawCircle((tempX+lParam)/2,(abs(tempX-lParam)/2+tempY),(abs(lParam - tempX)/2),BLACK); } } if (lParam < 176 && lParam > 50 && wParam > 100 && wParam < 116) { if(flag == 0) { flag = 1; Fill_Screen(WHITE); } } if (lParam < 200 && lParam > 40 && wParam > 173 && wParam < 183) { if (flag == 0) { flag = 2; Fill_Screen(WHITE); } } //PrintF("WM_LBUTTONUP\n"); //PrintF("x=%d y=%d\n",lParam,wParam); break; } }
void FUnrealEdUtils::DrawWidget(const FSceneView* View,FPrimitiveDrawInterface* PDI, const FMatrix& WidgetMatrix, int32 InInfo1, int32 InInfo2, EAxisList::Type HighlightAxis, EWidgetMovementMode bInMode, bool bHitTesting) { const FVector WidgetOrigin = WidgetMatrix.GetOrigin(); // Calculate size to draw widget so it takes up the same screen space. const float ZoomFactor = FMath::Min<float>(View->ViewMatrices.ProjMatrix.M[0][0], View->ViewMatrices.ProjMatrix.M[1][1]); const float WidgetRadius = View->Project(WidgetOrigin).W * (UnrealEd_WidgetSize / ZoomFactor); // Choose its color. Highlight manipulated axis in yellow. FColor XColor(255, 0, 0); FColor YColor(0, 255, 0); FColor ZColor(0, 0, 255); if(HighlightAxis == EAxisList::X) XColor = FColor(255, 255, 0); else if(HighlightAxis == EAxisList::Y) YColor = FColor(255, 255, 0); else if(HighlightAxis == EAxisList::Z) ZColor = FColor(255, 255, 0); const FVector XAxis = WidgetMatrix.GetScaledAxis( EAxis::X ); const FVector YAxis = WidgetMatrix.GetScaledAxis( EAxis::Y ); const FVector ZAxis = WidgetMatrix.GetScaledAxis( EAxis::Z ); if(bInMode == WMM_Rotate) { if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::X, WidgetMatrix, bInMode) ); DrawCircle(PDI,WidgetOrigin, YAxis, ZAxis, XColor, WidgetRadius, 24, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Y, WidgetMatrix, bInMode) ); DrawCircle(PDI,WidgetOrigin, XAxis, ZAxis, YColor, WidgetRadius, 24, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Z, WidgetMatrix, bInMode) ); DrawCircle(PDI,WidgetOrigin, XAxis, YAxis, ZColor, WidgetRadius, 24, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); } else { FMatrix WidgetTM; // Draw the widget arrows. if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::X, WidgetMatrix, bInMode) ); WidgetTM = FMatrix(XAxis, YAxis, ZAxis, WidgetOrigin); DrawDirectionalArrow(PDI,WidgetTM, XColor, WidgetRadius, 1.f, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Y, WidgetMatrix, bInMode) ); WidgetTM = FMatrix(YAxis, ZAxis, XAxis, WidgetOrigin); DrawDirectionalArrow(PDI,WidgetTM, YColor, WidgetRadius, 1.f, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bHitTesting) PDI->SetHitProxy( new HWidgetUtilProxy(InInfo1, InInfo2, EAxisList::Z, WidgetMatrix, bInMode) ); WidgetTM = FMatrix(ZAxis, XAxis, YAxis, WidgetOrigin); DrawDirectionalArrow(PDI,WidgetTM, ZColor, WidgetRadius, 1.f, SDPG_Foreground); if(bHitTesting) PDI->SetHitProxy( NULL ); if(bInMode == WMM_Scale) { FVector AlongX = WidgetOrigin + (XAxis * WidgetRadius * 0.3f); FVector AlongY = WidgetOrigin + (YAxis * WidgetRadius * 0.3f); FVector AlongZ = WidgetOrigin + (ZAxis * WidgetRadius * 0.3f); PDI->DrawLine(AlongX, AlongY, FColor(255,255,255), SDPG_Foreground); PDI->DrawLine(AlongY, AlongZ, FColor(255,255,255), SDPG_Foreground); PDI->DrawLine(AlongZ, AlongX, FColor(255,255,255), SDPG_Foreground); } } }
static bool HHVM_METHOD(ImagickDraw, circle, double ox, double oy, double px, double py) { auto wand = getDrawingWandResource(this_); DrawCircle(wand->getWand(), ox, oy, px, py); return true; }
void VisitCircle(const AirspaceCircle &airspace) { DrawCircle(airspace.GetReferenceLocation(), airspace.GetRadius()); }
void VisitCircle(const AirspaceCircle &airspace) { RasterPoint center = proj.GeoToScreen(airspace.GetReferenceLocation()); unsigned radius = proj.GeoToScreenDistance(airspace.GetRadius()); DrawCircle(center, radius); }
void GraphRenderer::RenderGraph(const Graph* const graph) { SDL_RenderClear(renderer); const std::vector<Node*>* const nodes = graph->GetNodes(); const size_t size = nodes->size(); const uint32_t depth = graph->GetDepth(); const uint32_t players = graph->GetPlayers(); static const uint32_t distance = (uint32_t)(screen_height / (depth * 2.5)); static const int32_t rootPosX = screen_width / 2; static const int32_t rootPosY = screen_height / 2; uint32_t currDistance = distance; float angle = 360.0f / (float)players; angle *= 0.01745f; uint32_t nodeId = 1; // skip root node const float offset = sin((float)currentTime / 300.0f) * 100.0f; for (size_t i = 0; i < depth; ++i) { int32_t nodeX = rootPosX + currDistance; int32_t nodeY = rootPosY + offset * (i + 1); for (size_t j = 0; j < players; ++j) { int32_t newNodeX = (int32_t)((nodeX - rootPosX) * cos(angle) - (nodeY - rootPosY) * sin(angle) + rootPosX); int32_t newNodeY = (int32_t)((nodeX - rootPosX) * sin(angle) + (nodeY - rootPosY) * cos(angle) + rootPosY); nodeX = newNodeX; nodeY = newNodeY; (*nodes)[nodeId]->SetPositionX(newNodeX); (*nodes)[nodeId]->SetPositionY(newNodeY); nodeId++; } currDistance += distance; } int32_t* RESTRICT const x = new int32_t[size]; int32_t* RESTRICT const y = new int32_t[size]; size_t i = 0; static const uint32_t nodeCircleRadius = (uint32_t)(screen_height / 16); static const uint32_t nodeBorderSize = (uint32_t)(nodeCircleRadius / 4); static const uint32_t pawnCircleRadius = (uint32_t)(nodeCircleRadius / 2); // draw graph lines for (const Node* const n : *nodes) { if (n != nullptr) { const std::vector<Node*>* const connections = n->GetConnections(); const int32_t nx = n->GetPositionX(); const int32_t ny = n->GetPositionY(); x[i] = nx; y[i] = ny; i++; for (const Node* const c : *connections) { if (c != nullptr) { const int32_t cx = c->GetPositionX(); const int32_t cy = c->GetPositionY(); DrawLine(Colours::black, nx, ny, cx, cy); } } } } // draw graph nodes DrawCircle(Colours::nodeInner, Colours::nodeOuter, x, y, nodeCircleRadius, nodeBorderSize, size); const Pawn* const currentPawn = game->GetCurrentPawn(); // draw pawns for (const Node* const n : *nodes) { if (n != nullptr) { const Pawn* const pawn = n->GetPawn(); if (pawn != nullptr) { const int32_t nx = n->GetPositionX(); const int32_t ny = n->GetPositionY(); if (currentPawn == pawn) { // pawn->color DrawCircle(Colours::pawnActive, nx, ny, pawnCircleRadius); } else { DrawCircle(Colours::pawn, nx, ny, pawnCircleRadius); } } } } SDL_RenderPresent(renderer); }
//画坐标 void CRadarMapCtrl::DrawCoordinate() { CPoint startPoint,endPoint; //画横轴 startPoint.x=0; startPoint.y=m_height/2; endPoint.x=m_width; endPoint.y=m_height/2; DrawLine(startPoint,endPoint); //画横轴箭头 startPoint.x=endPoint.x; startPoint.y=endPoint.y; endPoint.x=endPoint.x-5; endPoint.y=endPoint.y-5; DrawLine(startPoint,endPoint); startPoint.x=m_width; startPoint.y=m_height/2; endPoint.x=startPoint.x-5; endPoint.y=startPoint.y+5; DrawLine(startPoint,endPoint); //画纵轴 startPoint.x=m_width/2; startPoint.y=0; endPoint.x=m_width/2; endPoint.y=m_height; DrawLine(startPoint,endPoint); //画纵轴箭头 startPoint.x=startPoint.x; startPoint.y=startPoint.y; endPoint.x=startPoint.x-5; endPoint.y=startPoint.y+5; DrawLine(startPoint,endPoint); startPoint.x=m_width/2; startPoint.y=0; endPoint.x=startPoint.x+5; endPoint.y=startPoint.y+5; DrawLine(startPoint,endPoint); //画圆形刻度 for(int i=0;i<=m_map_totalPx/m_map_graduation;i++) { startPoint.x=m_width/2-i*m_map_graduation; startPoint.y=m_height/2-i*m_map_graduation; endPoint.x=m_width/2+i*m_map_graduation; endPoint.y=m_height/2+i*m_map_graduation; DrawCircle(startPoint.x,startPoint.y,endPoint.x,endPoint.y); } //画单位刻度表示的距离值 double mpergraduation=m_map_graduation/m_map_scale;//计算单位刻度表示的距离,单位:米,m CFont* pOldFont=m_dcMemory.SelectObject(&m_Font); m_dcMemory.SetTextColor(RGB(255,255,255)); CString str; str.Format("单位刻度:%2.2f 米",mpergraduation); CRect rfont; rfont.left=5; rfont.top=5; rfont.bottom=m_height-5; rfont.right=m_width-5; m_dcMemory.DrawText(str,&rfont,DT_LEFT); //m_dcMemory.SelectObject(pOldFont); }
void display(void) { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(1.0f, 1.0f, 1.0f); if (ps.renderMode == 0) { int i; glColor3f(0.3f, 0.8f, 1.0f); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glPointSize(5.0f); glBegin(GL_POINTS); for (i = 0; i < ps.pNum; i++) { // if(ps.p[i].phase == bubble) glColor3f(1.0f, 0.3f, 0.8f); else if(ps.p[i].phase == water) glColor3f(0.5f, 0.8f, 1.0f); else glColor3f(0.3f, 1.0f, 0.8f); glVertex2fv(&ps.p[i].pos.x); } glEnd(); glPointSize(1.0f); glDisable(GL_POINT_SMOOTH); glDisable(GL_BLEND); } else if (ps.renderMode > 0) { //glBindTexture(GL_TEXTURE_2D, waterTex); //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.texture); //glEnable(GL_TEXTURE_2D); //glBegin(GL_QUADS); //glTexCoord2f(0.0f, 0.0f); //glVertex2f(0.0f, 0.0f); //glTexCoord2f(1.0f, 0.0f); //glVertex2f(1.0f, 0.0f); //glTexCoord2f(1.0f, 1.0f); //glVertex2f(1.0f, 1.0f); //glTexCoord2f(0.0f, 1.0f); //glVertex2f(0.0f, 1.0f); //glEnd(); //glDisable(GL_TEXTURE_2D); if (ps.renderMode == 2) { int i; glColor3f(0.3f, 0.8f, 1.0f); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glLineWidth(1.5f); glBegin(GL_LINES); for (i = 0; i < ps.nLine0; i++) { glVertex2fv(&ps.line0[i].x); glVertex2fv(&ps.line1[i].x); } glEnd(); glColor3f(1.0f, 0.8f, 0.3f); glBegin(GL_LINES); for (i = 0; i < ps.nLine1; i++) { glVertex2fv(&ps.line2[i].x); glVertex2fv(&ps.line3[i].x); } glEnd(); glLineWidth(1.0f); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } // if (ps.renderMode == 1) { //int i; //glColor3f(0.3f, 0.8f, 1.0f); //glEnable(GL_BLEND); //glEnable(GL_POINT_SMOOTH); //glPointSize(5.0f); //glBegin(GL_POINTS); //for (i = 0; i < ps.pNum; i++) // glVertex2fv(&ps.p[i].pos.x); //glEnd(); //glPointSize(1.0f); //glDisable(GL_POINT_SMOOTH); ////draw contour //glLineWidth(1.5f); //glBegin(GL_LINES); //for (i = 0; i < ps.nLine; i++) { // glVertex2fv(&ps.line0[i].x); // glVertex2fv(&ps.line1[i].x); //} //glEnd(); //glLineWidth(1.0f); //glDisable(GL_LINE_SMOOTH); //glDisable(GL_BLEND); //glEnable(GL_TEXTURE_2D); glUseProgram(programObject); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, waterTex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.textureWater); waterLoc = glGetUniformLocation(programObject, "tex_water"); if(waterLoc >= 0) glUniform1i(waterLoc, 0); else printf("Uniform variable tex_water not found!\n"); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, iceTex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.textureIce); iceLoc = glGetUniformLocation(programObject, "tex_ice"); if(iceLoc >= 0) glUniform1i(iceLoc, 1); else printf("Uniform variable tex_ice not found!\n"); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glEnd(); //glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glUseProgram(0); /*glBindTexture(GL_TEXTURE_2D, iceTex); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, RENDER_SAMPLE, RENDER_SAMPLE, GL_RGBA, GL_FLOAT, ps.textureIce); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glEnd(); glDisable(GL_TEXTURE_2D);*/ //glColor3f(0.3f, 0.8f, 1.0f); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glPointSize(10.0f); //glBegin(GL_POINTS); int i; for (i = 0; i < ps.pNum; i++) { // if(ps.p[i].phase == bubble) { //glPointSize(10.0f * ps.p[i].volume); glColor3f(1.0f, 1.0f, 1.0f); DrawCircle(ps.p[i].pos.x, ps.p[i].pos.y, 0.005 * ps.p[i].volume, 10); //glVertex2fv(&ps.p[i].pos.x); } } //glEnd(); glPointSize(1.0f); glDisable(GL_POINT_SMOOTH); glDisable(GL_BLEND); } } if (systemRunning) { //if (frameNum % 10 == 0) //screenShot(frameNum / 10); frameNum++; } renderText(); glutSwapBuffers(); }
static void ParseDrawFunction(DviWidget dw, char *buf) { int v[DRAW_ARGS_MAX]; int i, no_move = 0; char *ptr; v[0] = v[1] = v[2] = v[3] = 0; if (buf[0] == '\0') return; ptr = buf+1; for (i = 0; i < DRAW_ARGS_MAX; i++) { if (sscanf(ptr, "%d", v + i) != 1) break; while (*ptr == ' ') ptr++; while (*ptr != '\0' && *ptr != ' ') ptr++; } switch (buf[0]) { case 'l': /* draw a line */ DrawLine(dw, v[0], v[1]); break; case 'c': /* circle */ DrawCircle(dw, v[0]); break; case 'C': DrawFilledCircle(dw, v[0]); break; case 'e': /* ellipse */ DrawEllipse(dw, v[0], v[1]); break; case 'E': DrawFilledEllipse(dw, v[0], v[1]); break; case 'a': /* arc */ DrawArc(dw, v[0], v[1], v[2], v[3]); break; case 'p': DrawPolygon(dw, v, i); break; case 'P': DrawFilledPolygon(dw, v, i); break; case '~': /* wiggly line */ DrawSpline(dw, v, i); break; case 't': dw->dvi.line_thickness = v[0]; break; case 'f': if (i > 0 && v[0] >= 0 && v[0] <= DVI_FILL_MAX) dw->dvi.fill = v[0]; no_move = 1; break; default: #if 0 warning("unknown drawing function %s", buf); #endif no_move = 1; break; } if (!no_move) { if (buf[0] == 'e') { if (i > 0) dw->dvi.state->x += v[0]; } else { while (--i >= 0) { if (i & 1) dw->dvi.state->y += v[i]; else dw->dvi.state->x += v[i]; } } } }
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); } // 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->projectiles.render_size()>0) { CVertexArray* lines=GetVertexArray(); CVertexArray* points=GetVertexArray(); lines->Initialize(); lines->EnlargeArrays(ph->projectiles.render_size()*2,0,VA_SIZE_C); points->Initialize(); points->EnlargeArrays(ph->projectiles.render_size(),0,VA_SIZE_C); for(ThreadListSimRender<CProjectile*>::render_iterator psi = ph->projectiles.render_begin(); psi != ph->projectiles.render_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::ButtonPressEvt& 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); }
void HPlotter::PlotCriticalPathSteinerTree(HCriticalPath path, Color color) { HCriticalPathWrapper pointW = m_hd[path]; HCriticalPath::PointsEnumeratorW pointsEnumeratorW = pointW.GetEnumeratorW(); pointsEnumeratorW.MoveNext(); HSteinerPointWrapper srcPoint = m_hd[m_hd.SteinerPoints[m_hd.TimingPoints.Get<HTimingPoint::Pin, HPin>(m_hd.CriticalPathPoints.Get<HCriticalPathPoint::TimingPoint, HTimingPoint>(pointsEnumeratorW))]]; HSteinerPointWrapper nextPoint = srcPoint; DrawCircle(srcPoint.X(), srcPoint.Y(), 4, color, false); int pointCount = pointW.PointsCount(); int pc = 1; TemplateTypes<HSteinerPoint>::stack points; points.push(srcPoint); while (!points.empty()) { srcPoint = points.top(); points.pop(); if (srcPoint.HasLeft()) { nextPoint = srcPoint.Left(); DrawLine(srcPoint.X(), srcPoint.Y(), nextPoint.X(), nextPoint.Y(), color, false); points.push(nextPoint); if (srcPoint.HasRight()) { nextPoint = srcPoint.Right(); DrawLine(srcPoint.X(), srcPoint.Y(), nextPoint.X(), nextPoint.Y(), color, false); points.push(nextPoint); } } else { HCriticalPath::PointsEnumeratorW nextCriticalPathPointW = pointsEnumeratorW; nextCriticalPathPointW.MoveNext(); HSteinerPointWrapper nextSteinerPoint = m_hd[m_hd.SteinerPoints[m_hd.TimingPoints.Get<HTimingPoint::Pin, HPin>(nextCriticalPathPointW.TimingPoint())]]; bool isCriticalPathLeaf = true; if (nextSteinerPoint == srcPoint) { if (pointsEnumeratorW.MoveNext()) { if (pointsEnumeratorW.MoveNext()) { pc+=2; isCriticalPathLeaf = false; srcPoint = m_hd[m_hd.SteinerPoints[m_hd.TimingPoints.Get<HTimingPoint::Pin, HPin>(pointsEnumeratorW.TimingPoint())]]; DrawCircle(srcPoint.X(), srcPoint.Y(), 4, color, false); bool f = false; if (srcPoint.HasLeft()) { f = true; nextPoint = srcPoint.Left(); DrawLine(srcPoint.X(), srcPoint.Y(), nextPoint.X(), nextPoint.Y(), color, false); points.push(nextPoint); if (srcPoint.HasRight()) { nextPoint = srcPoint.Right(); DrawLine(srcPoint.X(), srcPoint.Y(), nextPoint.X(), nextPoint.Y(), color, false); points.push(nextPoint); } } if (!f) ALERT("Error source not left!!!"); } } } if (isCriticalPathLeaf) { DrawCircle(srcPoint.X(), srcPoint.Y(), 1, color, false); } } } if (pc != (pointCount - 1)) ALERT("error point count in !!!!!!!!pc = %d\tpoint count = %d", pc, pointCount); }
void DrawStream(int t) { int i; int scr_x = 32; int scr_y = 0; int strm_scrl; SDL_Rect draw_from, draw_to; for (i = 0; i < 256; i++) { ending_pal[i].r = i; ending_pal[i].g = (i * 7 / 8) + 16 + sin( (float)t / 8 )*16; ending_pal[i].b = (i * 3 / 4) + 32 + sin( (float)t / 8 )*32; } if (t >= 300) { scr_x = 32 + rand()%32 - rand()%32; scr_y = rand()%8; } if (t < 10) { scr_y = (20 - t * 2); } DrawLevel(scr_x, scr_y, 0, 0); DrawPlayer(344 - scr_x, 228 - scr_y, 0, 0); for (i = 0; i < 7; i++) { strm_scrl = (t * 20) % 128; draw_to.x = 0 - strm_scrl - scr_x + (128*i); draw_to.y = 19 - scr_y; if (i >= 300) { draw_to.y += rand()%4; draw_to.y -= rand()%4; } SDL_BlitSurface(streamspr, NULL, screen, &draw_to); } // glitter for (i = 0; i < 20; i++) { draw_from.x = (rand()%3)*32; draw_from.y = 0; draw_from.w = 32; draw_from.h = 32; draw_to.x = rand()%(640+32)-32; draw_to.y = (rand()%(124)) + 3; SDL_BlitSurface(glitter, &draw_from, screen, &draw_to); } if (t > 250) { if (t < 300) { if (t == 251) { SND_CircuitRelease(1000); } DrawCircle(320+32 - scr_x, 240 - scr_y, (t - 254) * 10, 255); DrawCircle(320+32 - scr_x, 240 - scr_y, (t - 252) * 10, 225); DrawCircle(320+32 - scr_x, 240 - scr_y, (t - 250) * 10, 195); } } UpdatePalette(); VideoUpdate(); }
//----------------------------------------------------------------------------------- // レンダリング //----------------------------------------------------------------------------------- void display(void) { // クロックの更新 clock_pre = clock_now; clock_now = get_clock_now(); // 1秒で1日分動くとする if( flg_play ) day += (clock_now - clock_pre); // フレームバッファのクリア glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // 視点の設定 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 0.0, distance, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glRotatef( -pitch, 1.0, 0.0, 0.0 ); glRotatef( -yaw, 0.0, 1.0, 0.0 ); // 惑星の軌道を描く glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_default_color); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_default_color); DrawCircle( orbit_radius_earth ); //惑星を描く glPushMatrix(); { // 太陽 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_sun); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_sun); glPushMatrix(); { // 太陽の自転の計算式 glRotatef ( day * rot_vel_sun , 0.0, 1.0, 0.0); DrawPlanet( radius_sun ); } glPopMatrix(); // 水星 glPushMatrix(); { glRotatef ( day * rev_vel_mercury, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_mercury, 0.0, 0.0); glRotatef ( day * rot_vel_mercury, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_mercury); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_mercury); DrawPlanet( planet_radius_mercury ); } glPopMatrix(); // 金星 glPushMatrix(); { glRotatef ( day * rev_vel_venus, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_venus, 0.0, 0.0); glRotatef ( day * rot_vel_venus, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_venus); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_venus); DrawPlanet( planet_radius_venus ); } glPopMatrix(); // 地球 glPushMatrix(); { glRotatef ( day * rev_vel_earth, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_earth, 0.0, 0.0); glRotatef ( day * rot_vel_earth, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_earth); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_earth); DrawPlanet( planet_radius_earth ); // 月 glPushMatrix(); { glRotatef ( day * rev_vel_moon, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_moon, 0.0, 0.0); glRotatef ( day * rot_vel_moon, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_moon); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_moon); DrawPlanet( planet_radius_moon ); } glPopMatrix(); } glPopMatrix(); //火星 glPushMatrix(); { glRotatef ( day * rev_vel_mars, 0.0, 1.0, 0.0); glTranslatef (orbit_radius_mars, 0.0, 0.0); glRotatef ( day * rot_vel_mars, 0.0, 1.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_color_mars); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_color_mars); DrawPlanet( planet_radius_mars ); } glPopMatrix(); } glPopMatrix(); glutSwapBuffers(); }
void VisitCircle(const AirspaceCircle &airspace) { if (SetupCanvas(airspace)) DrawCircle(airspace.GetCenter(), airspace.GetRadius()); }
void ClientGame::Render() { glHint(GL_LINE_SMOOTH_HINT, GL_NICEST ); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST ); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); if (m_gameState == GameState_MainMenu) { RenderMainMenu(); return; } if (m_gameState == GameState_WaitingForServer) { return; } glClearColor( 0.97f * 0.9f, 0.96f * 0.9f, 0.89f * 0.9f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glDisable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(m_mapX, m_mapX + m_xSize * m_mapScale, m_mapY + m_ySize * m_mapScale, m_mapY); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); const int outerBorder = 35; // Draw the background. glColor(0xFFFFFFFF); glBegin(GL_QUADS); glVertex2i(-outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, m_yMapSize + outerBorder); glVertex2i(-outerBorder, m_yMapSize + outerBorder); glEnd(); // Outer thick border of the map glColor(0xFF7FD6F2); glLineWidth(2); glBegin(GL_LINE_LOOP); glVertex2i(-outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, -outerBorder); glVertex2i(m_xMapSize + outerBorder, m_yMapSize + outerBorder); glVertex2i(-outerBorder, m_yMapSize + outerBorder); glEnd(); // Grid glColor(0xFF7FD6F2); glLineWidth(1); glBegin(GL_LINES); for (int x = 0; x < m_xMapSize / m_gridSpacing; ++x) { glVertex2i(x * m_gridSpacing, 0); glVertex2i(x * m_gridSpacing, m_yMapSize); } glVertex2i(m_xMapSize, 0); glVertex2i(m_xMapSize, m_yMapSize); for (int y = 0; y < m_yMapSize / m_gridSpacing; ++y) { glVertex2i(0, y * m_gridSpacing); glVertex2i(m_xMapSize, y * m_gridSpacing); } glVertex2i(0, m_yMapSize); glVertex2i(m_xMapSize, m_yMapSize); glEnd(); // Buildings. glEnable(GL_TEXTURE_2D); glColor(0xFFFFFFFF); for (int i = 0; i < m_map.GetNumStops(); ++i) { const Stop& stop = m_map.GetStop(i); Vec2 position = stop.point; const Texture* texture = NULL; switch (stop.structureType) { case StructureType_Bank: texture = &m_buildingBankTexture; break; case StructureType_Tower: texture = &m_buildingTowerTexture; break; case StructureType_Police: texture = &m_buildingPoliceTexture; break; } if (texture != NULL) { Render_DrawSprite(*texture, static_cast<int>(position.x) - texture->xSize / 2, static_cast<int>(position.y) - texture->ySize / 2); } } for (int i = 0; i < m_state.GetNumEntities(); ++i) { const Entity* entity = m_state.GetEntity(i); switch (entity->GetTypeId()) { case EntityTypeId_Building: { const BuildingEntity* building = static_cast<const BuildingEntity*>(entity); Vec2 position = m_map.GetStop(building->m_stop).point; if (building->m_raided) { Render_DrawSprite(m_buildingRaidedHouseTexture, static_cast<int>(position.x) - m_buildingRaidedHouseTexture.xSize / 2, static_cast<int>(position.y) - m_buildingHouseTexture.ySize / 2); } else { Render_DrawSprite(m_buildingHouseTexture, static_cast<int>(position.x) - m_buildingHouseTexture.xSize / 2, static_cast<int>(position.y) - m_buildingHouseTexture.ySize / 2); } } break; } } glDisable(GL_TEXTURE_2D); // Rails. glLineWidth(8.0f / m_mapScale); glBegin(GL_LINES); for (int i = 0; i < m_map.GetNumRails(); ++i) { const Rail& rail = m_map.GetRail(i); const Stop& stop1 = m_map.GetStop(rail.stop1); const Stop& stop2 = m_map.GetStop(rail.stop2); assert(rail.line >= 0); unsigned long color = m_map.GetLineColor(rail.line); // Draw the rails partially transparent to make the buldings more readable. color = (color & 0x00FFFFFF) | 0x90000000; glColor( color ); glVertex(stop1.point); glVertex(stop2.point); } glEnd(); // Stops. for (int i = 0; i < m_map.GetNumStops(); ++i) { const Stop& stop = m_map.GetStop(i); float inflate = 0.0f; if (i == m_hoverStop) { inflate = 5.0f; } if (stop.line == -1) { glColor( 0xFF000000 ); DrawCircle(stop.point, 8.0f + inflate); glColor( 0xFFFFFFFF ); DrawCircle(stop.point, 6.0f + inflate); } else { glColor( m_map.GetLineColor(stop.line) ); DrawCircle(stop.point, 8.0f + inflate); } } // Draw the legend of the grid. Font_BeginDrawing(m_font); glColor(0xFF7FD6F2); int fontHeight = Font_GetTextHeight(m_font); for (int x = 0; x < m_xMapSize / m_gridSpacing; ++x) { char buffer[32]; sprintf(buffer, "%d", x); int textWidth = Font_GetTextWidth(m_font, buffer); Font_DrawText(buffer, x * m_gridSpacing + m_gridSpacing / 2 - textWidth / 2, -outerBorder + 5); Font_DrawText(buffer, x * m_gridSpacing + m_gridSpacing / 2 - textWidth / 2, m_yMapSize + 5); } for (int y = 0; y < m_yMapSize / m_gridSpacing; ++y) { char buffer[32]; sprintf(buffer, "%c", 'A' + y); Font_DrawText(buffer, -outerBorder + 10, y * m_gridSpacing + m_gridSpacing / 2 - fontHeight / 2); Font_DrawText(buffer, m_xMapSize + 10, y * m_gridSpacing + m_gridSpacing / 2 - fontHeight / 2); } Font_EndDrawing(); glEnable(GL_TEXTURE_2D); // DL: How about blinking for showing selection? const float kBlinkDuration = 0.2f; const float kBlinkCycleDuration = 1.0f; float blinkT = fmodf(m_time, kBlinkCycleDuration); float blinkAlpha = 1.0f; if (blinkT < kBlinkDuration) { blinkAlpha = (cosf(2.0f*kPi*blinkT/kBlinkDuration)+1.0f)/2.0f; } unsigned long blinkColor = (static_cast<int>(blinkAlpha*255.0f) << 24) | 0xffffff; // Entities int index = 0; const AgentEntity* agent; while (m_state.GetNextEntityWithType(index, agent)) { if (m_selectedAgent == agent->GetId() && m_pathLength == 0) { glColor(blinkColor); } else { glColor(0xFFFFFFFF); } Vec2 position = GetAgentPosition(agent); if (agent->m_state == AgentEntity::State_Hacking) { Render_DrawSprite(m_agentHackingTexture, static_cast<int>(position.x) - m_agentHackingTexture.xSize / 2, static_cast<int>(position.y) - m_agentHackingTexture.ySize / 2); } else if (agent->m_state == AgentEntity::State_Stakeout) { Render_DrawSprite(m_agentStakeoutTexture, static_cast<int>(position.x) - m_agentStakeoutTexture.xSize / 2, static_cast<int>(position.y) - m_agentStakeoutTexture.ySize / 2); } else if (agent->m_intel != -1) { Render_DrawSprite(m_agentIntelTexture, static_cast<int>(position.x) - m_agentIntelTexture.xSize / 2, static_cast<int>(position.y) - m_agentIntelTexture.ySize / 2); } else { Render_DrawSprite(m_agentTexture, static_cast<int>(position.x) - m_agentTexture.xSize / 2, static_cast<int>(position.y) - m_agentTexture.ySize / 2); } } m_mapParticles.Draw(); // Draw the UI. glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, m_xSize, m_ySize, 0); glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glBegin(GL_QUADS); glVertex2i(0, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize); glVertex2i(0, m_ySize); glEnd(); glColor(0xFF86DDEE); glLineWidth(1); glBegin(GL_LINE_LOOP); glVertex2i(0, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize - yStatusBarSize); glVertex2i(m_xSize, m_ySize); glVertex2i(0, m_ySize); glEnd(); glEnable(GL_TEXTURE_2D); for (int i = 0; i < ButtonId_NumButtons; ++i) { if (m_button[i].enabled) { int xButton, yButton, xButtonSize, yButtonSize; GetButtonRect((ButtonId)i, xButton, yButton, xButtonSize, yButtonSize); if (m_button[i].toggled) { glColor(0xFFB0E8E1); } else { glColor(0xFFFFFFFF); } int buttonOffset = 0; int shadowOffset = 10; Render_DrawSprite( m_buttonShadowTexture, xButton + shadowOffset, yButton + shadowOffset ); if (m_activeButton == i && m_activeButtonDown) { buttonOffset = 5; } Render_DrawSprite( m_buttonTexture[i], xButton + buttonOffset, yButton + buttonOffset ); } } m_notificationLog.Draw(); const int maxPlayers = 32; const PlayerEntity* player[maxPlayers] = { NULL }; int numPlayers = m_state.GetEntitiesWithType(player, maxPlayers); // Show the players. const int playerBoxHeight = 150; glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glLineWidth(1); glBegin(GL_QUADS); for (int i = 0; i < numPlayers; ++i) { int x = m_xSize - 300; int y = 10 + (playerBoxHeight + 15) * i; glVertex2i( x, y ); glVertex2i( m_xSize, y ); glVertex2i( m_xSize, y + playerBoxHeight ); glVertex2i( x, y + playerBoxHeight ); } glEnd(); glColor(0xFF86DDEE); glBegin(GL_LINE_LOOP); for (int i = 0; i < numPlayers; ++i) { int x = m_xSize - 300; int y = 10 + (playerBoxHeight + 15) * i; glVertex2i( x, y ); glVertex2i( m_xSize, y ); glVertex2i( m_xSize, y + playerBoxHeight ); glVertex2i( x, y + playerBoxHeight ); } glEnd(); glEnable(GL_TEXTURE_2D); glColor(0xFFFFFFFF); const int scaledAgentWidth = (m_agentTexture.xSize * fontHeight) / m_agentTexture.ySize; const int scaledHouseWidth = (m_buildingHouseTexture.xSize * fontHeight) / m_buildingHouseTexture.ySize; const int scaledIntelWidth = (m_intelTexture.xSize * fontHeight) / m_intelTexture.ySize; for (int i = 0; i < numPlayers; ++i) { Render_DrawSprite(m_playerPortraitTexture, m_xSize - 290, 20 + (playerBoxHeight + 15) * i); int offset = 0; if (player[i]->m_hackingBank) { Render_DrawSprite(m_playerBankHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerBankHackedTexture.ySize); offset += m_playerBankHackedTexture.xSize; } if (player[i]->m_hackingTower) { Render_DrawSprite(m_playerCellHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerCellHackedTexture.ySize); offset += m_playerCellHackedTexture.xSize; } if (player[i]->m_hackingPolice) { Render_DrawSprite(m_playerPoliceHackedTexture, m_xSize - m_playerPortraitTexture.xSize - 60 + offset, 20 + (playerBoxHeight + 15) * i + 90 - m_playerPoliceHackedTexture.ySize); offset += m_playerPoliceHackedTexture.xSize; } Render_DrawSprite(m_agentTexture, m_xSize - 280, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledAgentWidth, fontHeight); Render_DrawSprite(m_buildingHouseTexture, m_xSize - 180, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledHouseWidth, fontHeight); Render_DrawSprite(m_intelTexture, m_xSize - 80, playerBoxHeight - 25 +(playerBoxHeight + 15) * i, scaledIntelWidth, fontHeight); } Font_BeginDrawing(m_font); glColor(0xFF000000); for (int i = 0; i < numPlayers; ++i) { Font_DrawText(player[i]->m_name, m_xSize - m_playerPortraitTexture.xSize - 60, 20 + (playerBoxHeight + 15) * i); char buffer[32]; sprintf(buffer, "x%d", player[i]->m_numAgents); Font_DrawText(buffer, m_xSize - 280 + scaledAgentWidth + 5, playerBoxHeight - 25 + (playerBoxHeight + 15) * i); sprintf(buffer, "x%d", player[i]->m_numSafeHouses); Font_DrawText(buffer, m_xSize - 180 + scaledHouseWidth + 5, playerBoxHeight - 25 + (playerBoxHeight + 15) * i); sprintf(buffer, "x%d", player[i]->m_numIntels); Font_DrawText(buffer, m_xSize - 80 + scaledHouseWidth + 5, playerBoxHeight - 25 + (playerBoxHeight + 15) * i); } glColor(0xFF000000); Font_EndDrawing(); // Tool tip. const char* toolTip = NULL; if (m_hoverButton == ButtonId_Capture) { toolTip = "Search and capture any enemy agents\nat this location"; } else if (m_hoverButton == ButtonId_Stakeout) { toolTip = "Put the agent into stakeout mode\nso any enemy agents passing through\nthe stop will be detected"; } else if (m_hoverButton == ButtonId_Infiltrate) { toolTip = "Search and infiltrate enemy safe\nhouses at this location"; } else if (m_hoverButton == ButtonId_Hack) { toolTip = "Hack the building to gather\ninformation"; } else if (m_hoverButton == ButtonId_Intel) { toolTip = "Pickup/drop the intel"; } if (toolTip != NULL) { int xTipSize = 510; int yTipSize = 120; int xTip = 10; int yTip = m_ySize - yStatusBarSize - yTipSize - 10; glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glLineWidth(1); glBegin(GL_QUADS); glVertex2i( xTip, yTip ); glVertex2i( xTip + xTipSize, yTip ); glVertex2i( xTip + xTipSize, yTip + yTipSize ); glVertex2i( xTip, yTip + yTipSize ); glEnd(); glColor(0xFF86DDEE); glBegin(GL_LINE_LOOP); glVertex2i( xTip, yTip ); glVertex2i( xTip + xTipSize, yTip ); glVertex2i( xTip + xTipSize, yTip + yTipSize ); glVertex2i( xTip, yTip + yTipSize ); glEnd(); glColor(0xFF000000); Font_BeginDrawing(m_font); Font_DrawText(toolTip, xTip + 10, yTip + 10); Font_EndDrawing(); } glEnable(GL_TEXTURE_2D); glColor(0xFFFFFFFF); for (int i = 0; i < numPlayers; ++i) { if (player[i]->m_eliminated) { Render_DrawSprite(m_playerEliminatedTexture, m_xSize - 250, 20 + (playerBoxHeight + 15) * i); } } m_screenParticles.Draw(); if (m_gameState == GameState_GameOver) { const int windowWidth = 200; const int widonwHeight = 100; glDisable(GL_TEXTURE_2D); glColor(0xB0DBEDF7); glLineWidth(1); glBegin(GL_QUADS); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glEnd(); glColor(0xFF86DDEE); glBegin(GL_LINE_LOOP); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize - widonwHeight) / 2 ); glVertex2i( (m_xSize + windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glVertex2i( (m_xSize - windowWidth) / 2, (m_ySize + widonwHeight) / 2 ); glEnd(); glEnable(GL_TEXTURE_2D); Font_BeginDrawing(m_font); const char* text = m_isWinner ? "You WIN!" : "GAME OVER"; glColor(0xff000000); int textWidth = Font_GetTextWidth(m_font, text); Font_DrawText(text, (m_xSize - textWidth)/2, (m_ySize - fontHeight)/2); Font_EndDrawing(); } }
void DrawShips( GdkDrawable *drawable, GdkGC* gc, GdkPoint sz ) { GdkColor color; GdkRectangle rc; int r = int(ShipRadius*Scale); for( int j = 0; j < 2; ++j ) for( int i = 0; i < ShipTotal; i++ ) { // Draw trajectory if( ship_owners[i] != pNONE && i == SelectedShip ) { GdkPoint gp1, gp2; DPoint2D pnt[2], g, *p1 = NULL, *p2 = NULL; DPoint2D v( ships_vx[i], ships_vy[i] ); double angle = ships_angle[i]; double angle_chg = chg_angle[i]; double energy = ships_energy[i]; double acc = Acceler[i]; pnt[0].Init( ships_x[i], ships_y[i] ); GdkColor base_col = (ship_owners[i] == pWHITE ? SHIP_COLOR1 : SHIP_COLOR2), col; double brightness; for( int n = 0; n < ShipTrajDisplayLength; ++n ) { p1 = &pnt[n%2]; p2 = &pnt[1-n%2]; *p2 = *p1; MoveShip( *p2, v, angle, angle_chg, energy, acc ); gp1.x = XToScreen(p1->x, sz); gp1.y = YToScreen(p1->y, sz); gp2.x = XToScreen(p2->x, sz); gp2.y = YToScreen(p2->y, sz); brightness = 0.1 + 0.5*(1 - 1.0*n/ShipTrajDisplayLength); col.red = guint16( base_col.red * brightness ); col.green = guint16( base_col.green * brightness ); col.blue = guint16( base_col.blue * brightness ); gdk_gc_set_rgb_fg_color( gc, &col ); gdk_draw_line( drawable, gc, gp1.x, gp1.y, gp2.x, gp2.y ); angle_chg = 0; acc = 0; } } GdkPoint p = { XToScreen(ships_x[i], sz), YToScreen(ships_y[i], sz) }; GdkPoint d = { int(cos(ships_angle[i])*ShipRadius*Scale), -int(sin(ships_angle[i])*ShipRadius*Scale) }; // Atack direction // Draw nozzle fire if( ship_owners[i] != pNONE && Acceler[i] >= NULL_DOUBLE ) { double mul = Acceler[i]/MaxAcceleration; gdk_gc_set_rgb_fg_color( gc, &RED ); gdk_draw_line( drawable, gc, int(p.x - d.x*(1+mul)), int(p.y - d.y*(1+mul)), p.x - d.x, p.y - d.y ); gdk_draw_line( drawable, gc, p.x - d.x, p.y - d.y, int(p.x - d.x*(1+mul/2)), int(p.y - d.y*(1+mul/2)) ); } if( j==0 ? ship_owners[i] != pNONE : ship_owners[i] == pNONE ) continue; // this is needed to display destroyed ships first // Draw the vehicle DrawCircle( drawable, gc, true, p, r, ship_owners[i]==pWHITE ? SHIP_COLOR1 : ship_owners[i]==pBLACK ? SHIP_COLOR2 : Owners[i]==pWHITE ? DIM_SHIP_COLOR1 : DIM_SHIP_COLOR2 ); if( i == SelectedShip ) DrawCircle( drawable, gc, false, p, r, RED ); // Draw state bars rc.x = p.x-r; rc.y = p.y+r; rc.width = 2*r; rc.height = 4; // Fill the bars with white gdk_gc_set_rgb_fg_color( gc, &WHITE ); gdk_draw_line( drawable, gc, rc.x, rc.y+1, rc.x + rc.width, rc.y+1 ); gdk_draw_line( drawable, gc, rc.x, rc.y+3, rc.x + rc.width, rc.y+3 ); // Energy if( ships_energy[i] > 0 ) { gdk_gc_set_rgb_fg_color( gc, &CYAN ); gdk_draw_line( drawable, gc, rc.x, rc.y+1, int(rc.x+rc.width*ships_energy[i]), rc.y+1 ); } // Health if( ships_health[i] > 0 && ship_owners[i] != pNONE ) { gdk_gc_set_rgb_fg_color( gc, &RED ); gdk_draw_line( drawable, gc, rc.x, rc.y+3, int(rc.x+rc.width*ships_health[i]), rc.y+3 ); } // Atack direction gdk_gc_set_rgb_fg_color( gc, &RED ); gdk_draw_line( drawable, gc, p.x, p.y, p.x+d.x, p.y+d.y ); } // Laser atacks double k = 155.0/MaxShootEnergy; for( int i = 0; i < ShootsCount; i++ ) { color = RGB( int(Shoots[i][4]*k)+100, 0, 0 ); gdk_gc_set_rgb_fg_color( gc, &color ); gdk_draw_line( drawable, gc, XToScreen(Shoots[i][0], sz), YToScreen(Shoots[i][1], sz), XToScreen(Shoots[i][2], sz), YToScreen(Shoots[i][3], sz) ); } }
void iAnt_qt_user_functions::DrawInWorld() { foodPositions = loopFunctions->GetFoodPositions(); pheromonePositions = loopFunctions->GetPheromonePositions(); fidelityPositions = loopFunctions->GetFidelityPositions(); CVector3 np(nestPosition.GetX(), nestPosition.GetY(), 0.001f); Real height = foodRadius / 2.0; //#ifdef __APPLE__ CQuaternion q; //#endif // draw the nest //#ifdef __APPLE__ DrawCircle(np, q, nestRadius, CColor::GRAY80); //#else // DrawCircle(nestRadius, np, CColor::GRAY80); //#endif if(foodPositions.size() > 0) { Real x, y; CVector3 p3d; // draw the food items for(size_t i = 0; i < foodPositions.size(); i++) { x = foodPositions[i].GetX(); y = foodPositions[i].GetY(); p3d = CVector3(x, y, 0.0); //#ifdef __APPLE__ DrawCylinder(p3d, q, foodRadius, height, CColor::BLACK); //#else // DrawCylinder(foodRadius, height, p3d, CColor::BLACK); //#endif } // draw the pheromone positions for(size_t i = 0; i < pheromonePositions.size(); i++) { if(pheromonePositions[i] != nestPosition) { x = pheromonePositions[i].GetX(); y = pheromonePositions[i].GetY(); p3d = CVector3(x, y, 0.0); //#ifdef __APPLE__ DrawCylinder(p3d, q, foodRadius, height, CColor::RED); //#else // DrawCylinder(foodRadius, height, p3d, CColor::RED); //#endif } } // draw the fidelity positions for(size_t i = 0; i < fidelityPositions.size(); i++) { if(fidelityPositions[i] != nestPosition) { x = fidelityPositions[i].GetX(); y = fidelityPositions[i].GetY(); p3d = CVector3(x, y, 0.0); //#ifdef __APPLE__ DrawCylinder(p3d, q, foodRadius, height, CColor::BLUE); //#else // DrawCylinder(foodRadius, height, p3d, CColor::BLUE); //#endif } } } }
void Camera::drawCircleOnWindowFixed(Vec2D pos_center, int r, Color_RGB color, bool fill) { if (!this->isVisibleForWindowPos(pos_center, Size(2 * r, 2 * r))) return; Color_RGB col = color*this->shield_ratio; DrawCircle((int)pos_center.x, (int)pos_center.y, r, col.toColor(), fill); }
void CRoundButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ASSERT(lpDrawItemStruct != NULL); CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rect = lpDrawItemStruct->rcItem; UINT state = lpDrawItemStruct->itemState; UINT nStyle = GetStyle(); int nRadius = m_nRadius; int nSavedDC = pDC->SaveDC(); pDC->SelectStockObject(NULL_BRUSH); pDC->FillSolidRect(rect, ::GetSysColor(COLOR_BTNFACE)); // Draw the focus circle around the button if ((state & ODS_FOCUS) && m_bDrawDashedFocusCircle) DrawCircle(pDC, m_ptCentre, nRadius--, RGB(0,0,0)); // Draw the raised/sunken edges of the button (unless flat) if (nStyle & BS_FLAT) { DrawCircle(pDC, m_ptCentre, nRadius--, RGB(0,0,0)); DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DHIGHLIGHT)); } else { if ((state & ODS_SELECTED)) { DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHIGHLIGHT)); DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT)); } else { DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DHIGHLIGHT), ::GetSysColor(COLOR_3DDKSHADOW)); DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW)); } } // draw the text if there is any CString strText; GetWindowText(strText); if (!strText.IsEmpty()) { CRgn rgn; rgn.CreateEllipticRgn(m_ptCentre.x-nRadius, m_ptCentre.y-nRadius, m_ptCentre.x+nRadius, m_ptCentre.y+nRadius); pDC->SelectClipRgn(&rgn); CSize Extent = pDC->GetTextExtent(strText); CPoint pt = CPoint( m_ptCentre.x - Extent.cx/2, m_ptCentre.x - Extent.cy/2 ); if (state & ODS_SELECTED) pt.Offset(1,1); pDC->SetBkMode(TRANSPARENT); if (state & ODS_DISABLED) pDC->DrawState(pt, Extent, strText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL); else pDC->TextOut(pt.x, pt.y, strText); pDC->SelectClipRgn(NULL); rgn.DeleteObject(); } // Draw the focus circle on the inside of the button if ((state & ODS_FOCUS) && m_bDrawDashedFocusCircle) DrawCircle(pDC, m_ptCentre, nRadius-2, RGB(0,0,0), TRUE); pDC->RestoreDC(nSavedDC); }
void wxSVGCanvas::RenderElement(wxSVGElement* elem, const wxSVGRect* rect, const wxSVGMatrix* parentMatrix, const wxCSSStyleDeclaration* parentStyle, wxSVGSVGElement* ownerSVGElement, wxSVGElement* viewportElement, wxProgressDialog* progressDlg) { wxSVGMatrix matrix(*parentMatrix); wxCSSStyleRef style(*parentStyle); elem->SetOwnerSVGElement(ownerSVGElement); elem->SetViewportElement(viewportElement); switch (elem->GetDtd()) { case wxSVG_SVG_ELEMENT: { wxSVGSVGElement* element = (wxSVGSVGElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; if (element->GetWidth().GetAnimVal().GetUnitType() == wxSVG_LENGTHTYPE_UNKNOWN) ((wxSVGAnimatedLength&) element->GetWidth()).SetAnimVal( wxSVGLength(wxSVG_LENGTHTYPE_PERCENTAGE, 100)); if (element->GetHeight().GetAnimVal().GetUnitType() == wxSVG_LENGTHTYPE_UNKNOWN) ((wxSVGAnimatedLength&) element->GetHeight()).SetAnimVal( wxSVGLength(wxSVG_LENGTHTYPE_PERCENTAGE, 100)); element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); if (rect && element->GetParent()) { wxSVGRect rect2 = *rect; wxSVGElement* parent = (wxSVGElement*) element->GetParent(); wxSVGTransformable* transformable = wxSVGTransformable::GetSVGTransformable(*parent); if (transformable) rect2 = rect2.MatrixTransform(transformable->GetCTM().Inverse()); RenderChilds(elem, &rect2, &matrix, &style, element, element, progressDlg); } else RenderChilds(elem, rect, &matrix, &style, element, element, progressDlg); break; } case wxSVG_G_ELEMENT: { wxSVGGElement* element = (wxSVGGElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); RenderChilds(elem, rect, &matrix, &style, ownerSVGElement, viewportElement, progressDlg); break; } case wxSVG_LINE_ELEMENT: { wxSVGLineElement* element = (wxSVGLineElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawLine(element, &matrix, &style); break; } case wxSVG_POLYLINE_ELEMENT: { wxSVGPolylineElement* element = (wxSVGPolylineElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawPolyline(element, &matrix, &style); break; } case wxSVG_POLYGON_ELEMENT: { wxSVGPolygonElement* element = (wxSVGPolygonElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawPolygon(element, &matrix, &style); break; } case wxSVG_RECT_ELEMENT: { wxSVGRectElement* element = (wxSVGRectElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawRect(element, &matrix, &style); break; } case wxSVG_CIRCLE_ELEMENT: { wxSVGCircleElement* element = (wxSVGCircleElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawCircle(element, &matrix, &style); break; } case wxSVG_ELLIPSE_ELEMENT: { wxSVGEllipseElement* element = (wxSVGEllipseElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawEllipse(element, &matrix, &style); break; } case wxSVG_PATH_ELEMENT: { wxSVGPathElement* element = (wxSVGPathElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawPath(element, &matrix, &style); break; } case wxSVG_TSPAN_ELEMENT: break; case wxSVG_TEXT_ELEMENT: { wxSVGTextElement* element = (wxSVGTextElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawText(element, &matrix, &style); break; } case wxSVG_IMAGE_ELEMENT: { wxSVGImageElement* element = (wxSVGImageElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN || element->GetOpacity() == 0) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); DrawImage(element, &matrix, &style, rect, progressDlg); break; } case wxSVG_VIDEO_ELEMENT: { wxSVGVideoElement* element = (wxSVGVideoElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN || element->GetOpacity() == 0) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); #ifdef USE_LIBAV DrawVideo(element, &matrix, &style); #else wxSVGGElement* gElem = new wxSVGGElement(); gElem->SetOwnerSVGElement(ownerSVGElement); gElem->SetViewportElement(viewportElement); gElem->SetStyle(element->GetStyle()); wxSVGRectElement* rectElem = new wxSVGRectElement(); rectElem->SetX(element->GetX().GetAnimVal()); rectElem->SetY(element->GetY().GetAnimVal()); rectElem->SetWidth(element->GetWidth().GetAnimVal()); rectElem->SetHeight(element->GetHeight().GetAnimVal()); rectElem->SetFill(wxSVGPaint(0,0,0)); gElem->AppendChild(rectElem); wxSVGTextElement* textElem = new wxSVGTextElement; textElem->SetX((double)element->GetX().GetAnimVal()); textElem->SetY(element->GetY().GetAnimVal()+(double)element->GetHeight().GetAnimVal()/10); textElem->SetFontSize((double)element->GetHeight().GetAnimVal()/15); textElem->SetFill(wxSVGPaint(255,255,255)); textElem->SetStroke(wxSVGPaint(255,255,255)); textElem->AddChild(new wxSvgXmlNode(wxSVGXML_TEXT_NODE, wxT(""), wxT(" [") + element->GetHref() + wxT("]"))); gElem->AppendChild(textElem); // render RenderElement(gElem, rect, &matrix, &style, ownerSVGElement, viewportElement, progressDlg); // delete shadow tree delete gElem; #endif break; } case wxSVG_USE_ELEMENT: { wxSVGUseElement* element = (wxSVGUseElement*) elem; if (element->GetVisibility() == wxCSS_VALUE_HIDDEN) break; element->UpdateMatrix(matrix); style.Add(element->GetStyle()); style.Add(element->GetAnimStyle()); // test if visible if (element->GetWidth().GetAnimVal().GetUnitType() != wxSVG_LENGTHTYPE_UNKNOWN && element->GetHeight().GetAnimVal().GetUnitType() != wxSVG_LENGTHTYPE_UNKNOWN) { if (rect && !ownerSVGElement->CheckIntersection(*elem, *rect)) break; wxSVGPoint point(element->GetX().GetAnimVal() + element->GetWidth().GetAnimVal(), element->GetY().GetAnimVal() + element->GetHeight().GetAnimVal()); point = point.MatrixTransform(matrix); if (point.GetX() < 0 || point.GetY() < 0) break; } // get ref element wxString href = element->GetHref(); if (href.length() == 0 || href.GetChar(0) != wxT('#')) break; href.Remove(0, 1); wxSVGElement* refElem = (wxSVGElement*) ownerSVGElement->GetElementById(href); if (!refElem) break; // create shadow tree wxSVGGElement* gElem = new wxSVGGElement(); gElem->SetOwnerDocument(elem->GetOwnerDocument()); gElem->SetOwnerSVGElement(ownerSVGElement); gElem->SetViewportElement(viewportElement); gElem->SetStyle(element->GetStyle()); if (element->GetX().GetAnimVal().GetUnitType() != wxSVG_LENGTHTYPE_UNKNOWN) gElem->Translate(element->GetX().GetAnimVal(), element->GetY().GetAnimVal()); if (refElem->GetDtd() == wxSVG_SYMBOL_ELEMENT || refElem->GetDtd() == wxSVG_SVG_ELEMENT) { wxSVGSVGElement* svgElem; if (refElem->GetDtd() == wxSVG_SVG_ELEMENT) svgElem = (wxSVGSVGElement*) refElem->CloneNode(); else { svgElem = new wxSVGSVGElement(); wxSvgXmlElement* child = refElem->GetChildren(); while (child) { svgElem->AddChild(child->CloneNode()); child = child->GetNext(); } svgElem->SetViewBox(((wxSVGSymbolElement*) refElem)->GetViewBox()); svgElem->SetPreserveAspectRatio(((wxSVGSymbolElement*) refElem)->GetPreserveAspectRatio()); } if (element->GetWidth().GetAnimVal().GetUnitType() != wxSVG_LENGTHTYPE_UNKNOWN) svgElem->SetWidth(element->GetWidth().GetAnimVal()); if (element->GetHeight().GetAnimVal().GetUnitType() != wxSVG_LENGTHTYPE_UNKNOWN) svgElem->SetHeight(element->GetHeight().GetAnimVal()); gElem->AddChild(svgElem); LoadImages(refElem, svgElem, progressDlg); } else gElem->AddChild(refElem->CloneNode()); // render RenderElement(gElem, rect, &matrix, &style, ownerSVGElement, viewportElement, progressDlg); // delete shadow tree delete gElem; break; } default: break; } }
void CGUIWindowTestPatternGL::DrawContrastBrightnessPattern(int top, int left, int bottom, int right) { int x5p = (int) (left + (0.05f * (right - left))); int y5p = (int) (top + (0.05f * (bottom - top))); int x12p = (int) (left + (0.125f * (right - left))); int y12p = (int) (top + (0.125f * (bottom - top))); int x25p = (int) (left + (0.25f * (right - left))); int y25p = (int) (top + (0.25f * (bottom - top))); int x37p = (int) (left + (0.375f * (right - left))); int y37p = (int) (top + (0.375f * (bottom - top))); int x50p = left + (right - left) / 2; int y50p = top + (bottom - top) / 2; int x62p = (int) (left + (0.625f * (right - left))); int y62p = (int) (top + (0.625f * (bottom - top))); int x75p = (int) (left + (0.75f * (right - left))); int y75p = (int) (top + (0.75f * (bottom - top))); int x87p = (int) (left + (0.875f * (right - left))); int y87p = (int) (top + (0.875f * (bottom - top))); int x95p = (int) (left + (0.95f * (right - left))); int y95p = (int) (top + (0.95f * (bottom - top))); m_blinkFrame = (m_blinkFrame + 1) % TEST_PATTERNS_BLINK_CYCLE; // draw main quadrants glColor3f(1, 1, 1); glRecti(x50p, top, right, y50p); glRecti(left, y50p, x50p, bottom); // draw border lines glBegin(GL_LINES); glColor3f(1, 1, 1); glVertex2d(left, y5p); glVertex2d(x50p, y5p); glVertex2d(x5p, top); glVertex2d(x5p, y50p); glVertex2d(x50p, y95p); glVertex2d(right, y95p); glVertex2d(x95p, y50p); glVertex2d(x95p, bottom); glColor3f(0, 0, 0); glVertex2d(x50p, y5p); glVertex2d(right, y5p); glVertex2d(x5p, y50p); glVertex2d(x5p, bottom); glVertex2d(left, y95p); glVertex2d(x50p, y95p); glVertex2d(x95p, top); glVertex2d(x95p, y50p); glEnd(); // draw inner rectangles glColor3f(1, 1, 1); glRecti(x12p, y12p, x37p, y37p); glRecti(x62p, y62p, x87p, y87p); glColor3f(0, 0, 0); glRecti(x62p, y12p, x87p, y37p); glRecti(x12p, y62p, x37p, y87p); // draw inner circles if (m_blinkFrame < TEST_PATTERNS_BLINK_CYCLE / 2) glColor3f(0.05f, 0.05f, 0.05f); else glColor3f(0, 0, 0); DrawCircle(x25p, y75p, (y37p - y12p) / 3); DrawCircle(x75p, y25p, (y37p - y12p) / 3); if (m_blinkFrame < TEST_PATTERNS_BLINK_CYCLE / 2) glColor3f(0.95f, 0.95f, 0.95f); else glColor3f(1, 1, 1); DrawCircle(x25p, y25p, (y37p - y12p) / 3); DrawCircle(x75p, y75p, (y37p - y12p) / 3); }
void CCircle::Draw(){ DrawCircle( Left , Top , Radius , Color , true ); }
/* char tmps[512]; sprintf(tmps, "%5.2f %5.2f %5.2f %5.2f", plCam.x, plCam.y, plCam.z, plCam.w ); MessageBoxA(NULL, tmps, tmps, MB_OK); */ void CGizmoTransformRotate::Draw() { if (m_pMatrix) { ComputeScreenFactor(); tvector3 right,up,frnt,dir; //glDisable(GL_DEPTH_TEST); tvector3 orig(m_pMatrix->GetTranslation()); tvector3 plnorm(m_CamSrc-orig); plnorm.Normalize(); tplane plCam = vector4(plnorm,0); dir = orig-m_CamSrc; dir.Normalize(); right.Cross(dir,GetTransformedVector(1)); right.Normalize(); up.Cross(dir,right); up.Normalize(); right.Cross(dir,up); right.Normalize(); tvector3 axeX(1,0,0),axeY(0,1,0),axeZ(0,0,1); if (mLocation == LOCATE_LOCAL) { axeX.TransformVector(*m_pMatrix); axeY.TransformVector(*m_pMatrix); axeZ.TransformVector(*m_pMatrix); axeX.Normalize(); axeY.Normalize(); axeZ.Normalize(); } // Twin if (mMask&AXIS_TRACKBALL) { if (m_RotateTypePredict != ROTATE_TWIN) DrawCircle(orig, 0.2f,0.2f,0.2f,right*GetScreenFactor(),up*GetScreenFactor()); else DrawCircle(orig, 1,1,1,right*GetScreenFactor(),up*GetScreenFactor()); } // Screen if (mMask&AXIS_SCREEN) { if (m_RotateTypePredict != ROTATE_SCREEN) DrawCircle(orig, 1.0f,0.3f,1.0f,up*1.2f*GetScreenFactor(),right*1.2f*GetScreenFactor()); else DrawCircle(orig, 1,1,1,up*1.2f*GetScreenFactor(),right*1.2f*GetScreenFactor()); } // X right.Cross(dir, axeX); right.Normalize(); frnt.Cross(right, axeX); frnt.Normalize(); if (mMask&AXIS_X) { if (m_RotateTypePredict != ROTATE_X) DrawCircleHalf(orig, 1,0,0,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam); else DrawCircleHalf(orig, 1,1,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam); } // Y right.Cross(dir, axeY); right.Normalize(); frnt.Cross(right, axeY); frnt.Normalize(); if (mMask&AXIS_Y) { if (m_RotateTypePredict != ROTATE_Y) DrawCircleHalf(orig, 0,1,0,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam); else DrawCircleHalf(orig, 1,1,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam); } // Z right.Cross(dir, axeZ); right.Normalize(); frnt.Cross(right, axeZ); frnt.Normalize(); if (mMask&AXIS_Z) { if (m_RotateTypePredict != ROTATE_Z) DrawCircleHalf(orig, 0,0,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam); else DrawCircleHalf(orig, 1,1,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam); } // camembert if ( (m_RotateType != ROTATE_NONE) && (m_RotateType != ROTATE_TWIN ) ) DrawCamem(orig,m_Vtx*GetScreenFactor(),m_Vty*GetScreenFactor(),-m_Ng2); /* // debug glPointSize(20); glBegin(GL_POINTS); glVertex3fv(&ptd.x); glEnd(); glEnable(GL_DEPTH_TEST); */ #if 0 #ifdef WIN32 GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); GDD->GetD3D9Device()->SetRenderState(D3DRS_CULLMODE , D3DCULL_NONE ); GDD->GetD3D9Device()->SetRenderState(D3DRS_ZENABLE , D3DZB_TRUE); GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHATESTENABLE , FALSE); GDD->GetD3D9Device()->SetRenderState(D3DRS_ZWRITEENABLE , TRUE); #endif extern RenderingState_t GRenderingState; GRenderingState.mAlphaTestEnable = 0; GRenderingState.mZWriteEnable = 1; GRenderingState.mBlending = 0; GRenderingState.mCulling = 0; GRenderingState.mZTestType = 1; #endif } }
void DrawWireCapsule(const NxCapsule& capsule, const NxVec3& color) { NxReal r = capsule.radius; NxVec3 dir = capsule.p0 - capsule.p1; NxReal h = dir.magnitude(); NxMat34 pose; pose.t = (capsule.p0 + capsule.p1)*0.5f; if(h!=0.0f) { dir/=h; NxVec3 right, up; computeBasis(dir, right, up); pose.M.setColumn(0, right); pose.M.setColumn(1, dir); pose.M.setColumn(2, up); } else { pose.M.id(); } // NxMat34 pose = capsule->getGlobalPose(); // const NxReal & r = capsule->isCapsule()->getRadius(); // const NxReal & h = capsule->isCapsule()->getHeight(); NxSegment SG; pose.M.getColumn(1, SG.p1); SG.p1 *= 0.5f*h; SG.p0 = -SG.p1; SG.p0 += pose.t; SG.p1 += pose.t; NxVec3 c0; pose.M.getColumn(0, c0); NxVec3 c1; pose.M.getColumn(1, c1); NxVec3 c2; pose.M.getColumn(2, c2); DrawLine(SG.p0 + c0*r, SG.p1 + c0*r, color); DrawLine(SG.p0 - c0*r, SG.p1 - c0*r, color); DrawLine(SG.p0 + c2*r, SG.p1 + c2*r, color); DrawLine(SG.p0 - c2*r, SG.p1 - c2*r, color); pose.M.setColumn(0, -c1); pose.M.setColumn(1, -c0); pose.M.setColumn(2, c2); pose.t = SG.p0; DrawCircle(20, pose, color, r, true); //halfcircle -- flipped pose.M.setColumn(0, c1); pose.M.setColumn(1, -c0); pose.M.setColumn(2, c2); pose.t = SG.p1; DrawCircle(20, pose, color, r, true); pose.M.setColumn(0, -c1); pose.M.setColumn(1, c2); pose.M.setColumn(2, c0); pose.t = SG.p0; DrawCircle(20, pose, color, r, true);//halfcircle -- good pose.M.setColumn(0, c1); pose.M.setColumn(1, c2); pose.M.setColumn(2, c0); pose.t = SG.p1; DrawCircle(20, pose, color, r, true); pose.M.setColumn(0, c2); pose.M.setColumn(1, c0); pose.M.setColumn(2, c1); pose.t = SG.p0; DrawCircle(20, pose, color, r); //full circle pose.t = SG.p1; DrawCircle(20, pose, color, r); }