GLuint createAtmosphereDisplayList() { GLuint dispList= glGenLists(1); const int ResoV = 12, ResoH = 12; glNewList(dispList, GL_COMPILE); for(int j=-ResoV; j<ResoV-1; j++){ float y1 = float(j) / float(ResoV-1); float y2 = float(j+1) / float(ResoV-1); float r1 = 1.f - y1 * y1; float r2 = 1.f - y2 * y2; Vector c1 = skyColor(y1); Vector c2 = skyColor(y2); glBegin(GL_QUAD_STRIP); for(int i=0; i<ResoH; i++){ float x = cosf(i * 2 * Pi / (ResoH-1)); float z = sinf(i * 2 * Pi / (ResoH-1)); glColor(c1); glVertex3f(x*r1, y1, z*r1); glColor(c2); glVertex3f(x*r2, y2, z*r2); } glEnd(); } glEndList(); return dispList; }
void MouseTool::display(GLContextData& contextData) const { if(transformEnabled&&factory->crosshairSize>Scalar(0)) { /* Draw crosshairs at the virtual device's current position: */ glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); glPushMatrix(); glMultMatrix(transformedDevice->getTransformation()); glLineWidth(3.0f); Color lineCol=getBackgroundColor(); glColor(lineCol); glBegin(GL_LINES); glVertex(-factory->crosshairSize,Scalar(0),Scalar(0)); glVertex( factory->crosshairSize,Scalar(0),Scalar(0)); glVertex(Scalar(0),Scalar(0),-factory->crosshairSize); glVertex(Scalar(0),Scalar(0), factory->crosshairSize); glEnd(); glLineWidth(1.0f); for(int i=0; i<3; ++i) lineCol[i]=1.0f-lineCol[i]; glColor(lineCol); glBegin(GL_LINES); glVertex(-factory->crosshairSize,Scalar(0),Scalar(0)); glVertex( factory->crosshairSize,Scalar(0),Scalar(0)); glVertex(Scalar(0),Scalar(0),-factory->crosshairSize); glVertex(Scalar(0),Scalar(0), factory->crosshairSize); glEnd(); glPopMatrix(); glPopAttrib(); } }
void CylinderPrimitive::glRenderAction(GLContextData& contextData) const { /* Retrieve the data item: */ DataItem* dataItem=contextData.retrieveDataItem<DataItem>(this); glPushAttrib(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT|GL_LINE_BIT|GL_POLYGON_BIT); glDisable(GL_LIGHTING); /* Draw the cylinder's central axis: */ glLineWidth(3.0f); glColor(surfaceColor); glBegin(GL_LINES); Vector z=axis*Math::div2(length); glVertex(center-z); glVertex(center+z); glEnd(); glEnable(GL_BLEND); glDepthMask(GL_FALSE); /* Draw the surface: */ glColor(surfaceColor); glCallList(dataItem->displayListId); /* Draw the grid: */ glColor(gridColor); glCallList(dataItem->displayListId+1); glPopAttrib(); }
void renderLoadoutZone(Color theColor, Vector<Point> &bounds, Rect extent) { F32 alpha = 0.5; glColor(theColor * 0.5); glBegin(GL_POLYGON); for(S32 i = 0; i < bounds.size(); i++) glVertex2f(bounds[i].x, bounds[i].y); glEnd(); glColor(theColor * 0.7); glBegin(GL_LINE_LOOP); for(S32 i = 0; i < bounds.size(); i++) glVertex2f(bounds[i].x, bounds[i].y); glEnd(); Point extents = extent.getExtents(); Point center = extent.getCenter(); glPushMatrix(); glTranslatef(center.x, center.y, 0); if(extents.x < extents.y) glRotatef(90, 0, 0, 1); glColor(theColor); renderCenteredString(Point(0,0), 25, "LOADOUT ZONE"); glPopMatrix(); }
void DrawFrameX (int x, int y, int w, int h, int line, const TColor& backcol, const TColor& framecol, ETR_DOUBLE transp) { float yy = Winsys.resolution.height - y - h; if (x < 0) x = (Winsys.resolution.width -w) / 2; glPushMatrix(); glDisable(GL_TEXTURE_2D); glEnableClientState(GL_VERTEX_ARRAY); glColor(framecol, transp); glTranslatef(x, yy, 0); const GLshort frame [] = { 0, 0, GLshort(w), 0, GLshort(w), GLshort(h), 0, GLshort(h) }; glVertexPointer(2, GL_SHORT, 0, frame); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glColor(backcol, transp); const GLshort back [] = { GLshort(0 + line), GLshort(0 + line), GLshort(w - line), GLshort(0 + line), GLshort(w - line), GLshort(h - line), GLshort(0 + line), GLshort(h - line) }; glVertexPointer(2, GL_SHORT, 0, back); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glEnable (GL_TEXTURE_2D); glPopMatrix(); }
void DesktopDeviceNavigationTool::display(GLContextData& contextData) const { if(factory->showScreenCenter&&isActive()) { Color bgColor=getBackgroundColor(); Color fgColor; for(int i=0;i<3;++i) fgColor[i]=1.0f-bgColor[i]; fgColor[3]=bgColor[3]; ONTransform screenT=getMainScreen()->getScreenTransformation(); Point screenCenter=screenT.transform(Point(getMainScreen()->getWidth()*Scalar(0.5),getMainScreen()->getHeight()*Scalar(0.5),Scalar(0))); Vector x=screenT.transform(Vector(getMainScreen()->getWidth()*Scalar(0.5),Scalar(0),Scalar(0))); Vector y=screenT.transform(Vector(Scalar(0),getMainScreen()->getHeight()*Scalar(0.5),Scalar(0))); glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); glDepthFunc(GL_LEQUAL); glLineWidth(3.0f); glColor(bgColor); glBegin(GL_LINES); glVertex(screenCenter-x); glVertex(screenCenter+x); glVertex(screenCenter-y); glVertex(screenCenter+y); glEnd(); glLineWidth(1.0f); glColor(fgColor); glBegin(GL_LINES); glVertex(screenCenter-x); glVertex(screenCenter+x); glVertex(screenCenter-y); glVertex(screenCenter+y); glEnd(); glPopAttrib(); } }
void AngledCornerRectangle(const GG::Pt& ul, const GG::Pt& lr, GG::Clr color, GG::Clr border, int angle_offset, int thick, bool upper_left_angled/* = true*/, bool lower_right_angled/* = true*/, bool draw_bottom/* = true*/) { glDisable(GL_TEXTURE_2D); GG::GL2DVertexBuffer vert_buf; vert_buf.reserve(14); GG::Pt thick_pt = GG::Pt(GG::X(thick), GG::Y(thick)); BufferStoreAngledCornerRectangleVertices(vert_buf, ul + thick_pt, lr - thick_pt, angle_offset, upper_left_angled, lower_right_angled, draw_bottom); glDisable(GL_TEXTURE_2D); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); vert_buf.activate(); glColor(color); glDrawArrays(GL_TRIANGLE_FAN, 0, vert_buf.size()); if (thick > 0) { glColor(border); glLineWidth(thick); glDrawArrays(GL_LINE_STRIP, 0, vert_buf.size()); glLineWidth(1.0f); } glPopClientAttrib(); glEnable(GL_TEXTURE_2D); }
void FleetButton::RenderUnpressed() { GG::Pt ul = UpperLeft(), lr = LowerRight(); const double midX = static_cast<double>(Value(ul.x + lr.x))/2.0; const double midY = static_cast<double>(Value(ul.y + lr.y))/2.0; if (m_selected && m_selection_texture) { double sel_ind_scale = GetOptionsDB().Get<double>("UI.fleet-selection-indicator-size"); double sel_ind_half_size = Value(Width()) * sel_ind_scale / 2.0; GG::Pt sel_ul = GG::Pt(GG::X(static_cast<int>(midX - sel_ind_half_size)), GG::Y(static_cast<int>(midY - sel_ind_half_size))); GG::Pt sel_lr = GG::Pt(GG::X(static_cast<int>(midX + sel_ind_half_size)), GG::Y(static_cast<int>(midY + sel_ind_half_size))); glColor(GG::CLR_WHITE); m_selection_texture->OrthoBlit(sel_ul, sel_lr); } glColor(Color()); if (m_vertex_components.empty()) { if (m_size_icon) m_size_icon->OrthoBlit(ul); for (std::vector<boost::shared_ptr<GG::Texture> >::iterator it = m_head_icons.begin(); it != m_head_icons.end(); ++it) (*it)->OrthoBlit(ul); } else { std::vector<double> vertsXY; vertsXY.push_back(midX + m_vertex_components[0]); vertsXY.push_back(midY + m_vertex_components[1]); vertsXY.push_back(midX + m_vertex_components[2]); vertsXY.push_back(midY + m_vertex_components[3]); vertsXY.push_back(midX + m_vertex_components[4]); vertsXY.push_back(midY + m_vertex_components[5]); vertsXY.push_back(midX + m_vertex_components[6]); vertsXY.push_back(midY + m_vertex_components[7]); for (std::vector<boost::shared_ptr<GG::Texture> >::iterator it = m_head_icons.begin(); it != m_head_icons.end(); ++it) RenderTexturedQuad(vertsXY, *it); RenderTexturedQuad(vertsXY, m_size_icon); } // Scanlines for not currently-visible objects? int empire_id = HumanClientApp::GetApp()->EmpireID(); if (!scanline_shader || empire_id == ALL_EMPIRES || !GetOptionsDB().Get<bool>("UI.system-fog-of-war")) return; bool at_least_one_fleet_visible = false; for (std::vector<int>::const_iterator it = m_fleets.begin(); it != m_fleets.end(); ++it) { if (GetUniverse().GetObjectVisibilityByEmpire(*it, empire_id) >= VIS_BASIC_VISIBILITY) { at_least_one_fleet_visible = true; break; } } if (at_least_one_fleet_visible) return; float fog_scanline_spacing = static_cast<float>(GetOptionsDB().Get<double>("UI.system-fog-of-war-spacing")); scanline_shader->Use(); scanline_shader->Bind("scanline_spacing", fog_scanline_spacing); CircleArc(ul, lr, 0.0, TWO_PI, true); scanline_shader->stopUse(); }
void Triangle(Pt pt1, Pt pt2, Pt pt3, Clr color, Clr border_color, float border_thick) { GLfloat vertices[6] = {GLfloat(Value(pt1.x)), GLfloat(Value(pt1.y)), GLfloat(Value(pt2.x)), GLfloat(Value(pt2.y)), GLfloat(Value(pt3.x)), GLfloat(Value(pt3.y))}; glDisable(GL_TEXTURE_2D); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, 0, vertices); glColor(color); glDrawArrays(GL_TRIANGLES, 0, 3); if (border_color != GG::CLR_ZERO) { glLineWidth(border_thick); glColor(border_color); glDrawArrays(GL_LINE_LOOP, 0, 3); glLineWidth(1.0f); } glPopClientAttrib(); glEnable(GL_TEXTURE_2D); }
void MouseDialogNavigationTool::display(GLContextData& contextData) const { if(showScreenCenter) { /* Save and set up OpenGL state: */ glPushAttrib(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT|GL_LINE_BIT|GL_TEXTURE_BIT); glDisable(GL_LIGHTING); glDepthFunc(GL_LEQUAL); /* Go to screen coordinates: */ glPushMatrix(); Scalar viewport[4]; glMultMatrix(getMouseScreenTransform(mouseAdapter,viewport)); /* Determine the crosshair colors: */ Color bgColor=getBackgroundColor(); Color fgColor; for(int i=0;i<3;++i) fgColor[i]=1.0f-bgColor[i]; fgColor[3]=bgColor[3]; /* Calculate the window's or screen's center: */ Scalar centerPos[2]; for(int i=0;i<2;++i) centerPos[i]=Math::mid(viewport[2*i+0],viewport[2*i+1]); /* Calculate the endpoints of the screen's crosshair lines in screen coordinates: */ Point l=Point(viewport[0],centerPos[1],Scalar(0)); Point r=Point(viewport[1],centerPos[1],Scalar(0)); Point b=Point(centerPos[0],viewport[2],Scalar(0)); Point t=Point(centerPos[0],viewport[3],Scalar(0)); /* Draw the screen crosshairs: */ glLineWidth(3.0f); glColor(bgColor); glBegin(GL_LINES); glVertex(l); glVertex(r); glVertex(b); glVertex(t); glEnd(); glLineWidth(1.0f); glColor(fgColor); glBegin(GL_LINES); glVertex(l); glVertex(r); glVertex(b); glVertex(t); glEnd(); /* Go back to physical coordinates: */ glPopMatrix(); /* Restore OpenGL state: */ glPopAttrib(); } }
void ScaleBar::draw(GLContextData& contextData) const { /* Save and set OpenGL state: */ glPushAttrib(GL_COLOR_BUFFER_BIT|GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); /* Calculate the scale bar layout: */ GLfloat x0=getInterior().origin[0]+(getInterior().size[0]-GLfloat(currentPhysLength))*0.5f; GLfloat x1=x0+GLfloat(currentPhysLength); const GLLabel::Box::Vector& labelSize=lengthLabel->getLabelSize(); GLfloat y0=getInterior().origin[1]+(getInterior().size[1]-labelSize[1]*2.0f)*0.5f; GLfloat y1=y0+labelSize[1]; GLfloat y2=y1+labelSize[1]; /* Draw the scale bar: */ glLineWidth(5.0f); glBegin(GL_LINES); glColor(getBackgroundColor()); glVertex2f(x0,y1); glVertex2f(x1,y1); glEnd(); glLineWidth(3.0f); glBegin(GL_LINES); glVertex2f(x0,y0); glVertex2f(x0,y2); glVertex2f(x1,y0); glVertex2f(x1,y2); glColor(getForegroundColor()); glVertex2f(x0,y1); glVertex2f(x1,y1); glEnd(); glLineWidth(1.0f); glBegin(GL_LINES); glVertex2f(x0,y0); glVertex2f(x0,y2); glVertex2f(x1,y0); glVertex2f(x1,y2); glEnd(); /* Install a temporary deferred renderer: */ { GLLabel::DeferredRenderer dr(contextData); /* Draw the length and scale labels: */ // glEnable(GL_ALPHA_TEST); // glAlphaFunc(GL_GREATER,0.0f); lengthLabel->draw(contextData); scaleLabel->draw(contextData); } /* Restore OpenGL state: */ glPopAttrib(); }
void renderTurret(Color c, Point anchor, Point normal, bool enabled, F32 health, F32 barrelAngle, F32 aimOffset) { glColor(c); Point cross(normal.y, -normal.x); Point aimCenter = anchor + normal * aimOffset; glBegin(GL_LINE_STRIP); for(S32 x = -10; x <= 10; x++) { F32 theta = x * FloatHalfPi * 0.1; Point pos = normal * cos(theta) + cross * sin(theta); glVertex(aimCenter + pos * 15); } glEnd(); glLineWidth(3); glBegin(GL_LINES); Point aimDelta(cos(barrelAngle), sin(barrelAngle)); glVertex(aimCenter + aimDelta * 15); glVertex(aimCenter + aimDelta * 30); glEnd(); glLineWidth(DefaultLineWidth); if(enabled) glColor3f(1,1,1); else glColor3f(0.6, 0.6, 0.6); glBegin(GL_LINE_LOOP); glVertex(anchor + cross * 18); glVertex(anchor + cross * 18 + normal * aimOffset); glVertex(anchor - cross * 18 + normal * aimOffset); glVertex(anchor - cross * 18); glEnd(); glColor(c); S32 lineHeight = U32(28 * health); glBegin(GL_LINES); for(S32 i = 0; i < lineHeight; i += 2) { Point lsegStart = anchor - cross * (14 - i) + normal * 5; Point lsegEnd = lsegStart + normal * (aimOffset - 10); glVertex(lsegStart); glVertex(lsegEnd); } Point lsegStart = anchor - cross * 14 + normal * 3; Point lsegEnd = anchor + cross * 14 + normal * 3; Point n = normal * (aimOffset - 6); glVertex(lsegStart); glVertex(lsegEnd); glVertex(lsegStart + n); glVertex(lsegEnd + n); glEnd(); }
void Barrier::render(U32 layerIndex) { Color b(0,0,0.15), f(0,0,1); //Color b(0.0,0.0,0.075), f(.3 ,0.3,0.8); if(layerIndex == 0) { Vector<Point> colPoly; getCollisionPoly(colPoly); glColor(b); glBegin(GL_POLYGON); for(S32 i = 0; i < colPoly.size(); i++) glVertex2f(colPoly[i].x, colPoly[i].y); glEnd(); } else if(layerIndex == 1) { if(mLastBarrierChangeIndex != mBarrierChangeIndex) { mLastBarrierChangeIndex = mBarrierChangeIndex; mRenderLineSegments.clear(); Vector<Point> colPoly; getCollisionPoly(colPoly); S32 last = colPoly.size() - 1; for(S32 i = 0; i < colPoly.size(); i++) { mRenderLineSegments.push_back(colPoly[last]); mRenderLineSegments.push_back(colPoly[i]); last = i; } static Vector<GameObject *> fillObjects; fillObjects.clear(); Rect bounds(start, end); bounds.expand(Point(mWidth, mWidth)); findObjects(BarrierType, fillObjects, bounds); for(S32 i = 0; i < fillObjects.size(); i++) { colPoly.clear(); if(fillObjects[i] != this && fillObjects[i]->getCollisionPoly(colPoly)) clipRenderLinesToPoly(colPoly); } } glColor(f); glBegin(GL_LINES); for(S32 i = 0; i < mRenderLineSegments.size(); i++) glVertex2f(mRenderLineSegments[i].x, mRenderLineSegments[i].y); glEnd(); } }
void CUIWnd::Render() { GG::Pt ul = UpperLeft(); GG::Pt lr = LowerRight(); GG::Pt cl_ul = ClientUpperLeft(); GG::Pt cl_lr = ClientLowerRight(); if (!m_minimized) { AngledCornerRectangle(ul, lr, ClientUI::WndColor(), ClientUI::WndOuterBorderColor(), OUTER_EDGE_ANGLE_OFFSET, 1, false, !m_resizable); // show notched bottom-right corner if not resizable, pointed corner if resizable // use GL to draw the lines glDisable(GL_TEXTURE_2D); // draw inner border, including extra resize-tab lines glBegin(GL_LINE_STRIP); glColor(ClientUI::WndInnerBorderColor()); glVertex(cl_ul.x, cl_ul.y); glVertex(cl_lr.x, cl_ul.y); if (m_resizable) { glVertex(cl_lr.x, cl_lr.y - INNER_BORDER_ANGLE_OFFSET); glVertex(cl_lr.x - INNER_BORDER_ANGLE_OFFSET, cl_lr.y); } else { glVertex(cl_lr.x, cl_lr.y); } glVertex(cl_ul.x, cl_lr.y); glVertex(cl_ul.x, cl_ul.y); glEnd(); if (m_resizable) { glBegin(GL_LINES); // draw the extra lines of the resize tab GG::Clr tab_lines_colour = m_mouse_in_resize_tab ? ClientUI::WndInnerBorderColor() : ClientUI::WndOuterBorderColor(); glColor(tab_lines_colour); glVertex(cl_lr.x, cl_lr.y - RESIZE_HASHMARK1_OFFSET); glVertex(cl_lr.x - RESIZE_HASHMARK1_OFFSET, cl_lr.y); glVertex(cl_lr.x, cl_lr.y - RESIZE_HASHMARK2_OFFSET); glVertex(cl_lr.x - RESIZE_HASHMARK2_OFFSET, cl_lr.y); glEnd(); } glEnable(GL_TEXTURE_2D); } else { GG::FlatRectangle(ul, lr, ClientUI::WndColor(), ClientUI::WndOuterBorderColor(), 1); } GG::BeginScissorClipping(ul, lr); glColor(ClientUI::TextColor()); boost::shared_ptr<GG::Font> font = ClientUI::GetTitleFont(); font->RenderText(GG::Pt(ul.x + BORDER_LEFT, ul.y + TITLE_OFFSET), Name()); GG::EndScissorClipping(); }
void Label::draw() { const Size& size = getSize(); const int width = size.getWidth(); const int height = size.getHeight(); gltext::FontPtr font = getFont(); // draw the label background glColor(getBackgroundColor()); glBegin(GL_TRIANGLE_FAN); { glVertex2i(0, 0 ); glVertex2i(width, 0 ); glVertex2i(width, height); glVertex2i(0, height); } glEnd(); // draw text glColor(getForegroundColor()); gltext::FontRendererPtr renderer = gltext::CreateRenderer(gltext::PIXMAP, font); double labelWidth = double(renderer->getWidth(mText.c_str())); double fontHeight = double(font->getAscent() + font->getDescent()); //Lets store the Matrix so we don't piss anyone off glPushMatrix(); //These checks see if the button Label fits inside the //button. If not start in the lower left-hand corner of //the button and render the text. double yLoc = (height - fontHeight)/2.0; if (yLoc < 0) { yLoc = 0; } double xLoc = (width - labelWidth)/2.0; if (xLoc < 0) { xLoc = 0; } glTranslatef(GLfloat(xLoc), GLfloat(height - yLoc), 0.0f); renderer->render(mText.c_str()); //Lets restore the Matrix glPopMatrix(); }
void Button::Draw() { if (this -> _isActive) { //glColor(this->_color.Modify()); Color newColor = this -> _color.Modify(); glColor(newColor); } else { glColor(this -> _color); } glRecti(this -> _x1+this -> _shapeWidth, this -> _y1, this -> _x2 , this -> _y2-this -> _shapeWidth); glBegin(GL_POINTS); glColor(this-> _shapeColor); for (int i = this -> _x1 + 2; i < this -> _x2 - 1; ++i) { glVertex2i(i,this->_y1); glVertex2i(i,this->_y2); } for (int j = this -> _y1 + 2; j < this -> _y2 - 1; ++j) { glVertex2i(this -> _x1, j); glVertex2i(this -> _x2, j); } glEnd(); glColor(LIGHTGRAY); glRasterPos2i(this -> _x1 + 5, this -> _y1 + 20); int len = strlen(this -> _caption.c_str()); for (int i = 0; i < len; ++i) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, this -> _caption[i]); } glColor(this -> _shapeColor); glBegin(GL_POINTS); glVertex2i(this->_x1+1, this -> _y1 + 1); glVertex2i(this->_x2-1, this -> _y1 + 1); glVertex2i(this->_x1+1, this -> _y2 - 1); glVertex2i(this->_x2-1, this -> _y2 - 1); glEnd(); glutSwapBuffers(); }
void EnergyGaugeRenderer::render(S32 energy) { // Create fade static const F32 colors[] = { Colors::blue.r, Colors::blue.g, Colors::blue.b, 1, // Fade from Colors::blue.r, Colors::blue.g, Colors::blue.b, 1, Colors::cyan.r, Colors::cyan.g, Colors::cyan.b, 1, // Fade to Colors::cyan.r, Colors::cyan.g, Colors::cyan.b, 1, }; GaugeRenderer::render(energy, Ship::EnergyMax, colors, GaugeBottomMargin, GaugeHeight, Ship::EnergyCooldownThreshold); #ifdef SHOW_SERVER_SITUATION ServerGame *serverGame = GameManager::getServerGame(); if((serverGame && serverGame->getClientInfo(0)->getConnection()->getControlObject())) { S32 actDiff = static_cast<Ship *>(serverGame->getClientInfo(0)->getConnection()->getControlObject())->getEnergy(); S32 p = F32(actDiff) / Ship::EnergyMax * GaugeWidth; glColor(Colors::magenta); drawVertLine(xul + p, yul - SafetyLineExtend - 1, yul + GaugeHeight + SafetyLineExtend); //Or, perhaps, just this: //renderGauge(energy, Ship::EnergyMax, Colors::blue, Colors::cyan, GaugeBottomMargin, GaugeHeight); } #endif }
void Polygon() { GLsizei count = Vertex_Cur - Vertex_Data; if (count > 1) { vertex_vector_t b = Vertex_Data[0]; for (GLsizei i = 1; i < count; i++) { b = Max(b, Vertex_Data[i]); } Cover_Matrix(); v2_t p = XY*Raster; v2_t d = WH*Raster; glTranslated(p.x,p.y,0); glRotated(Angle, 0, 0, 1); glScaled(d.x, d.y, 1); glTranslated(-Pin.x*b.x,-Pin.y*b.y,0); //glColor4d(Color.r,Color.g,Color.b,Opacity); glColor(); glDisable(GL_TEXTURE_2D); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glBindBuffer(GL_ARRAY_BUFFER, 0); glVertexPointer(sizeof(vertex_vector_t)/sizeof(vertex_real_t), GL_Type(Vertex_Data), 0, Vertex_Data); glDrawArrays(GL_TRIANGLE_FAN, 0, count); } Stack_Set(Vertex_Data); Vertex_Data = 0; }
/* TODO: * add 8bit support */ void visualizePlayingSMP(void) { int off = getPlayingSample(); short * buffer = &((short*)(getoutBuf()))[off]; if(visualizer == NORMAL) { glBegin( GL_TRIANGLE_STRIP); glBindTexture( 0, 0 ); int i, j = (cur_codec.getSampleRate()/60)/128; static int status = 0; static int clr[3] = { 31, 0, 0 }; glColor(RGB15(clr[0], clr[1], clr[2])); int st_1 = (status + 1) % 3; clr[status] --; clr[st_1] ++; if (clr[status] == 0) status = st_1; for(i = 0; i<128; i++) { int val1 = (buffer[0]>>8); int val2 = (buffer[1]>>8); if(cur_codec.getnChannels()>1) { val1+=(buffer[STREAM_BUF_SIZE]>>8); val1>>=1; val2+=(buffer[STREAM_BUF_SIZE+1]>>8); val2>>=1; } drawLine(i*2, val1+96, i*2+2, val2+96); buffer+=j; if(buffer >= (((short*)getoutBuf()) + STREAM_BUF_SIZE)) buffer -= STREAM_BUF_SIZE; }
void GLFont::String::draw(const GLFont::Vector& origin,GLContextData& contextData) const { /* Retrieve the context data item: */ DataItem* dataItem=contextData.retrieveDataItem<DataItem>(this); /* Render a textured quad: */ glPushAttrib(GL_TEXTURE_BIT); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,dataItem->textureObjectId); glTexEnvMode(GLTexEnvEnums::TEXTURE_ENV,GLTexEnvEnums::BLEND); glTexEnvColor(GLTexEnvEnums::TEXTURE_ENV,foregroundColor); glColor(backgroundColor); Box offsetBox=box.offset(origin); glBegin(GL_QUADS); glNormal3f(0.0,0.0,1.0); glTexCoord(texCoord.getCorner(0)); glVertex(offsetBox.getCorner(0)); glTexCoord(texCoord.getCorner(1)); glVertex(offsetBox.getCorner(1)); glTexCoord(texCoord.getCorner(3)); glVertex(offsetBox.getCorner(3)); glTexCoord(texCoord.getCorner(2)); glVertex(offsetBox.getCorner(2)); glEnd(); glBindTexture(GL_TEXTURE_2D,0); glPopAttrib(); }
void TTextField::Draw() const { const TColor& col = focus?colDYell:colWhite; FT.SetColor (col); DrawFrameX (mouseRect.left, mouseRect.top, mouseRect.width, mouseRect.height, 3, colMBackgr, col, 1.0); FT.AutoSizeN (5); FT.DrawString (mouseRect.left+20, mouseRect.top, text); if (cursor && focus) { int x = mouseRect.left + 20 + 1; //if (cursorPos != 0) { string temp = text.substr (0, text.length()/*cursorPos*/); x += FT.GetTextWidth (temp); //} int w = 3; int h = 26 * Winsys.scale; int scrheight = Winsys.resolution.height; glDisable (GL_TEXTURE_2D); glColor(colYellow); const GLshort vtx[] = { GLshort(x), GLshort(scrheight - mouseRect.top - h - 9), GLshort(x + w), GLshort(scrheight - mouseRect.top - h - 9), GLshort(x + w), GLshort(scrheight - mouseRect.top - 9), GLshort(x), GLshort(scrheight - mouseRect.top - 9) }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_SHORT, 0, vtx); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); glEnable (GL_TEXTURE_2D); } }
void GrapheinClient::GrapheinTool::display(GLContextData& contextData) const { if(client==0) return; if(active) { /* Retrieve the current curve: */ CurveMap::Iterator cIt=client->localCurves.findEntry(currentCurveId); if(!cIt.isFinished()) { /* Render the last segment of the current curve: */ glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); glLineWidth(cIt->getDest()->lineWidth); glPushMatrix(); glMultMatrix(Vrui::getNavigationTransformation()); glColor(cIt->getDest()->color); glBegin(GL_LINES); glVertex(lastPoint); glVertex(currentPoint); glEnd(); glPopMatrix(); glPopAttrib(); } } }
void BiovisionDisplay::draw(const KinematicModel<BiovisionJoint> &model, const Vector3D &colour, bool drawAxis) { for(int i = 0; i < model.njoints(); i++) { const BiovisionJoint &joint = model.joints(i); if(drawAxis) { glPushMatrix(); glTranslate(joint.global_position()); glRotate(joint.global_orientation()); glBegin(GL_LINES); glColor3f(1.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(20.0, 0., 0.0); glColor3f(0.0, 1.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 20.0, 0.0); glColor3f(0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 20.0); glEnd(); glPopMatrix(); } if(joint.parent() >= 0) { glBegin(GL_LINES); glVertex(joint.global_position()); glVertex(model.getParent(joint).global_position()); glEnd(); Vector3D global_direction = (joint.global_position()-model.getParent(joint).global_position()).direction(); double length = joint.local_position().length(); glColor(colour); glPushMatrix(); glTranslate(joint.global_position()); glTranslate(-global_direction*length*0.5); //align bone Vector3D zAxis = Vector3D(0.0, 0.0, 1.0); Vector3D newAxis = zAxis ^ global_direction; double newAngle = acos(zAxis *global_direction); glRotateRad(newAngle, newAxis); //draw bone GLUquadricObj *qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); gluQuadricNormals(qobj, GLU_SMOOTH); glScalef(0.25, 0.25, 1.0); gluSphere(qobj, length*0.5, 20, 20); gluDeleteQuadric(qobj); glPopMatrix(); } } }
void Font::ParseSpecial(const char * text, uint32& pos, bool active) const { switch (text[pos+1]) { case 'c': { for (uint8 i = 1; i <= 8; i++) { char c = text[pos+i+1]; if (!((c >= '0') && (c <= '9')) && !((c >= 'a') && (c <= 'f')) && !((c >= 'A') && (c <= 'F'))) { pos += i; break; } else if (i == 8) { if (active == true) { uint32 colorValues = StringToHex32(text, pos + 2); ColorARGB newColor(colorValues); glColor(newColor); } pos += 9; } } break; } default: { pos++; break; } } }
void WalkNavigationToolFactory::initContext(GLContextData& contextData) const { if(drawMovementCircles) { /* Create a new data item: */ DataItem* dataItem=new DataItem; contextData.addDataItem(this,dataItem); /* Create the tool model display list: */ glNewList(dataItem->modelListId,GL_COMPILE); /* Set up OpenGL state: */ glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT); glDisable(GL_LIGHTING); glLineWidth(1.0f); glColor(movementCircleColor); /* Create a coordinate system for the floor plane: */ Vector y=centerViewDirection; Vector x=Geometry::cross(y,floorPlane.getNormal()); x.normalize(); /* Draw the inner circle: */ glBegin(GL_LINE_LOOP); for(int i=0;i<64;++i) { Scalar angle=Scalar(2)*Math::Constants<Scalar>::pi*Scalar(i)/Scalar(64); glVertex(Point::origin-x*(Math::sin(angle)*innerRadius)+y*(Math::cos(angle)*innerRadius)); } glEnd(); /* Draw the outer circle: */ glBegin(GL_LINE_LOOP); for(int i=0;i<64;++i) { Scalar angle=Scalar(2)*Math::Constants<Scalar>::pi*Scalar(i)/Scalar(64); glVertex(Point::origin-x*(Math::sin(angle)*outerRadius)+y*(Math::cos(angle)*outerRadius)); } glEnd(); /* Draw the inner angle: */ glBegin(GL_LINE_STRIP); glVertex(Point::origin-x*(Math::sin(innerAngle)*innerRadius)+y*(Math::cos(innerAngle)*innerRadius)); glVertex(Point::origin); glVertex(Point::origin-x*(Math::sin(-innerAngle)*innerRadius)+y*(Math::cos(-innerAngle)*innerRadius)); glEnd(); /* Draw the outer angle: */ glBegin(GL_LINE_STRIP); glVertex(Point::origin-x*(Math::sin(outerAngle)*outerRadius)+y*(Math::cos(outerAngle)*outerRadius)); glVertex(Point::origin); glVertex(Point::origin-x*(Math::sin(-outerAngle)*outerRadius)+y*(Math::cos(-outerAngle)*outerRadius)); glEnd(); /* Reset OpenGL state: */ glPopAttrib(); glEndList(); } }
void draw_aa_line(Line l,float width,vec4 color,float stipple) { // stretch line to quad vec2 linedir = normalized(l.p2 - l.p1); // line direction vector linedir *= 0.001 * width; // scale normalized vector with line width vec2 p1_a = vec2(+linedir[1],-linedir[0]) + l.p1; // rotate vector 90 degrees and add to p1 vec2 p1_b = vec2(-linedir[1],+linedir[0]) + l.p1; // rotate vector 270 degrees and add to p1 vec2 p2_a = vec2(+linedir[1],-linedir[0]) + l.p2; // rotate vector 90 degrees and add to p2 vec2 p2_b = vec2(-linedir[1],+linedir[0]) + l.p2; // rotate vector 270 degrees and add to p2 float len = length(l.p2 - l.p1); glBindTexture(GL_TEXTURE_2D,g_resources.texture_line); len *= stipple; g_resources.shader_line->use(); my_glUniform1f(g_resources.shader_line->get_uni_loc("stipple"),clamp_0_1(stipple)); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor(color); glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex(p1_a); glTexCoord2f(0.0,1.0); glVertex(p1_b); glTexCoord2f(len,1.0); glVertex(p2_b); glTexCoord2f(len,0.0); glVertex(p2_a); glEnd(); g_resources.shader_line->unuse(); glDisable(GL_TEXTURE_2D); }
void GameOverPanel::render(Scene& parent) { SDL_Window * win = parent.app().getWindow(); int width, height; SDL_GetWindowSize(win, &width, &height); Rect rect = getBoundingRect(win); glPushAttrib(GL_ENABLE_BIT); { glMatrixMode(GL_PROJECTION); glDisable(GL_LIGHTING); glPushMatrix(); { glLoadIdentity(); glOrtho(0, width, 0, height, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); { glLoadIdentity(); glBindTexture(texture); float alpha = 0; float translateY = 0; if(animTime > coolDownTime) { float diff = (animTime - coolDownTime) / (animTotalTime - coolDownTime); if(diff > 1) diff = 1; alpha = diff; translateY = translationYLength * (1 - diff) * (1 - diff); } glTranslate(Vector3::down * translateY); glColor(Vector3::one, alpha); glBegin(GL_QUADS); { glTexCoord2f(0, 0); glVertex2f(rect.left(), height - rect.top()); glTexCoord2f(0, 1); glVertex2f(rect.left(), height - rect.bottom()); glTexCoord2f(1, 1); glVertex2f(rect.right(), height - rect.bottom()); glTexCoord2f(1, 0); glVertex2f(rect.right(), height - rect.top()); } glEnd(); } glPopMatrix(); } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } glPopAttrib(); if(animTime < animTotalTime) { animTime += parent.app().getFrameTime(); } }
void Margin::draw(GLContextData& contextData) const { /* Draw the grandparent class widget: */ Container::draw(contextData); if(child!=0) { /* Draw the margin around the child widget: */ glBegin(GL_QUAD_STRIP); glColor(backgroundColor); glNormal3f(0.0f,0.0f,1.0f); glVertex(child->getExterior().getCorner(0)); glVertex(getInterior().getCorner(0)); glVertex(child->getExterior().getCorner(1)); glVertex(getInterior().getCorner(1)); glVertex(child->getExterior().getCorner(3)); glVertex(getInterior().getCorner(3)); glVertex(child->getExterior().getCorner(2)); glVertex(getInterior().getCorner(2)); glVertex(child->getExterior().getCorner(0)); glVertex(getInterior().getCorner(0)); glEnd(); /* Draw the child widgets: */ child->draw(contextData); } }
void LightPathsWidget::render_light_path(const size_t light_path_index) const { const auto& path = m_light_paths[light_path_index]; assert(path.m_vertex_end_index - path.m_vertex_begin_index >= 2); const auto& light_path_recorder = m_project.get_light_path_recorder(); LightPathVertex v0; light_path_recorder.get_light_path_vertex(path.m_vertex_begin_index, v0); for (size_t i = path.m_vertex_begin_index + 1; i < path.m_vertex_end_index; ++i) { LightPathVertex v1; light_path_recorder.get_light_path_vertex(i, v1); auto radiance = Color3f::from_array(v1.m_radiance); radiance /= sum_value(radiance); radiance = linear_rgb_to_srgb(radiance); glColor(radiance); glVertex3f(v0.m_position[0], v0.m_position[1], v0.m_position[2]); glVertex3f(v1.m_position[0], v1.m_position[1], v1.m_position[2]); v0 = v1; } }
void Pager::draw(GLContextData& contextData) const { /* Draw the parent class widget: */ Container::draw(contextData); /* Bail out if there are no children: */ if(children.empty()) return; /* Draw a margin around the page buttons and the child widget area: */ glBegin(GL_TRIANGLE_FAN); glColor(backgroundColor); glNormal3f(0.0f,0.0f,1.0f); glVertex(getInterior().getCorner(0)); glVertex(getInterior().getCorner(1)); glVertex(childBox.getCorner(1)); glVertex(childBox.getCorner(0)); glVertex(childBox.getCorner(2)); glVertex(buttonBox.getCorner(0)); glVertex(buttonBox.getCorner(2)); glVertex(getInterior().getCorner(2)); glEnd(); glBegin(GL_TRIANGLE_FAN); glVertex(getInterior().getCorner(3)); glVertex(getInterior().getCorner(2)); glVertex(buttonBox.getCorner(2)); for(ButtonList::const_iterator pbIt=pageButtons.begin();pbIt!=pageButtons.end();++pbIt) glVertex((*pbIt)->getExterior().getCorner(3)); glVertex(buttonBox.getCorner(3)); glVertex(buttonBox.getCorner(1)); glVertex(getInterior().getCorner(1)); glEnd(); glBegin(GL_TRIANGLE_FAN); glVertex(childBox.getCorner(3)); glVertex(childBox.getCorner(1)); glVertex(getInterior().getCorner(1)); glVertex(buttonBox.getCorner(1)); for(ButtonList::const_reverse_iterator pbIt=pageButtons.rbegin();pbIt!=pageButtons.rend();++pbIt) glVertex((*pbIt)->getExterior().getCorner(1)); glVertex(buttonBox.getCorner(0)); glVertex(childBox.getCorner(2)); glEnd(); /* Fill the empty space next to the page buttons: */ glBegin(GL_QUADS); glVertex(pageButtons.back()->getExterior().getCorner(1)); glVertex(buttonBox.getCorner(1)); glVertex(buttonBox.getCorner(3)); glVertex(pageButtons.back()->getExterior().getCorner(3)); glEnd(); /* Draw the page buttons: */ for(ButtonList::const_iterator pbIt=pageButtons.begin();pbIt!=pageButtons.end();++pbIt) (*pbIt)->draw(contextData); /* Draw the currently displayed child widget: */ children[currentChildIndex]->draw(contextData); }