void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) { sScanLineData line; // sort on height, y if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); if ( F32_A_GREATER_B ( a->Pos.y , c->Pos.y ) ) swapVertexPointer(&a, &c); if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); lockedSurface = (tVideoSample*)RenderTarget->lock(); #ifdef USE_ZBUFFER lockedDepthBuffer = (fp24*) DepthBuffer->lock(); #endif renderLine ( a, b ); renderLine ( b, c ); renderLine ( a, c ); RenderTarget->unlock(); #ifdef USE_ZBUFFER DepthBuffer->unlock(); #endif }
void FontImpl::render(Game* game, const Image* image, unsigned x, unsigned y, const char* text, unsigned maxWidth /* = 0xffffffff */) const { unsigned xOrig = x; unsigned len = std::strlen(text); const Character* chars[len]; unsigned i = 0; while(text[i] == ' ') { i++; } unsigned firstCol = i; unsigned lastSpace = i; while(i < len) { if(text[i] == ' ') { lastSpace = i; } auto chrIt = _charMap.find(text[i]); if(chrIt == _charMap.end()) { chrIt = _charMap.find('?'); } chars[i] = &(chrIt->second); if(maxWidth < 0xffffffff && x + chars[i]->_xadv > xOrig + maxWidth) { if(lastSpace == firstCol) { lastSpace = i; } renderLine(game, image, xOrig, y, chars, firstCol, lastSpace); if(i != lastSpace) { i = lastSpace + 1; } while(text[i] == ' ') { i++; } lastSpace = firstCol = i; x = xOrig; y += _baseLine; continue; } x += chars[i]->_xadv; i++; } renderLine(game, image, xOrig, y, chars, firstCol, len); }
void SkeletonModel::renderOrientationDirections(int jointIndex, glm::vec3 position, const glm::quat& orientation, float size) { auto geometryCache = DependencyManager::get<GeometryCache>(); if (!_jointOrientationLines.contains(jointIndex)) { OrientationLineIDs jointLineIDs; jointLineIDs._up = geometryCache->allocateID(); jointLineIDs._front = geometryCache->allocateID(); jointLineIDs._right = geometryCache->allocateID(); _jointOrientationLines[jointIndex] = jointLineIDs; } OrientationLineIDs& jointLineIDs = _jointOrientationLines[jointIndex]; glm::vec3 pRight = position + orientation * IDENTITY_RIGHT * size; glm::vec3 pUp = position + orientation * IDENTITY_UP * size; glm::vec3 pFront = position + orientation * IDENTITY_FRONT * size; glm::vec3 red(1.0f, 0.0f, 0.0f); geometryCache->renderLine(position, pRight, red, jointLineIDs._right); glm::vec3 green(0.0f, 1.0f, 0.0f); geometryCache->renderLine(position, pUp, green, jointLineIDs._up); glm::vec3 blue(0.0f, 0.0f, 1.0f); geometryCache->renderLine(position, pFront, blue, jointLineIDs._front); }
void dx11render::outlineRect(const rect& r, const color& c) { renderLine(point(r.getX(), r.getY()), point(r.getX() + r.getW() - 1, r.getY()), c); //TopLeft to TopRight renderLine(point(r.getX(), r.getY()), point(r.getX(), r.getY() + r.getH() - 1), c); //TopLeft to BottomLeft renderLine(point(r.getX() + r.getW() - 1, r.getY()), point(r.getX() + r.getW() - 1, r.getY() + r.getH() - 1), c); //TopRight to BottomRight renderLine(point(r.getX(), r.getY() + r.getH() - 1), point(r.getX() + r.getW(), r.getY() + r.getH() - 1), c); //BottomLeft to BottomRight }
void CTRTextureWire2::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) { sScanLineData line; // sort on height, y if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); renderLine ( a, b ); renderLine ( b, c ); renderLine ( a, c ); }
void VectorGraphic::draw(HCanvas& canvas, const Point& offset) const { Point previous = myPath[0]; for (Points::size_type i = 1; i < myPath.size(); ++i) { renderLine(canvas, previous + offset, myPath[i] + offset); previous = myPath[i]; } if (myShapeStyle == Closed) { renderLine(canvas, previous + offset, myPath[0] + offset); } }
void PathGroup::render() { Renderer* g = ARK2D::getRenderer(); g->setDrawColor(Color::white); // render points. for(unsigned int i = 0; i < paths.size(); i++) { for(unsigned int j = 0; j < paths.at(i)->subpaths.at(0)->points.size(); j++) { Vector2<float>* p = paths.at(i)->subpaths.at(0)->points.at(j); renderPoint(p->getX(), p->getY(), (j == 0 || j == paths.at(i)->subpaths.at(0)->points.size()-1)); } } // render curve. renderCurve(); // render straight lines. for(unsigned int i = 0; i < paths.size(); i++) { SubPath* mainPath = paths.at(i)->subpaths.at(0); for(unsigned int j = 0; j < mainPath->points.size(); j++) { if (j+1 != mainPath->points.size()) { renderLine( mainPath->points.at(j)->getX(), mainPath->points.at(j)->getY(), mainPath->points.at(j+1)->getX(), mainPath->points.at(j+1)->getY() ); } } } }
void Line3DOverlay::render(RenderArgs* args) { if (!_visible) { return; // do nothing if we're not visible } float alpha = getAlpha(); xColor color = getColor(); const float MAX_COLOR = 255.0f; glm::vec4 colorv4(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); auto batch = args->_batch; if (batch) { batch->setModelTransform(_transform); auto geometryCache = DependencyManager::get<GeometryCache>(); geometryCache->bindSimpleProgram(*batch, false, false, true, true); if (getIsDashedLine()) { // TODO: add support for color to renderDashedLine() geometryCache->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID); } else { geometryCache->renderLine(*batch, _start, _end, colorv4, _geometryCacheID); } } }
void asciimage::Shape::render(QPainter* painter, int scale, const Style& style) const { painter->save(); if (style.isCutting()) { painter->setCompositionMode(QPainter::CompositionMode_Clear); } switch (type()) { case Type::EMPTY: // nothing to do break; case Type::POINT: renderPoint(painter, scale, style); break; case Type::LINE: renderLine(painter, scale, style); break; case Type::POLYGON: renderPolygon(painter, scale, style); break; case Type::ELLIPSE: renderEllipse(painter, scale, style); break; } painter->restore(); }
void RenderableCurve::render(){ shader::setShaderUseTexture(0); shader::setShaderColor(color); glBindTexture(GL_TEXTURE_2D, 0); glBindVertexArray(getDefaultVaoId()); float dX = x2 - x, dY = y2 - y; float lastX = x, lastY = y; float currentX = 0, currentY = 0; float pfac = 0, fac = 0; for(int i = 1; i <= segments; i++){ pfac = (i + 0.0) / segments; fac = sin(2 * 3.14 * pfac); if(fac > 0){ currentX = x + dX * pfac + dx1 * fac;// + dx1 * fac + dx2 * (1 - fac); currentY = y + dY * pfac + dy1 * fac;// + dy1 * fac + dy2 * (1 - fac); } else{ currentX = x + dX * pfac - dx2 * fac;// + dx1 * fac + dx2 * (1 - fac); currentY = y + dY * pfac - dy2 * fac;// + dy1 * fac + dy2 * (1 - fac); } renderLine(lastX, lastY, currentX, currentY, thickness); lastX = currentX; lastY = currentY; } glBindVertexArray(0); }
void TextBase :: render(GemState *) { unsigned int i=0; if (m_theText.empty() || !m_font)return; // step through the lines for(i=0; i<m_theText.size(); i++) { renderLine(m_theText[i].c_str(), m_lineDist[i]*m_fontSize); } }
void LineOrientedVT100Client::paint() { int maximumNumberOfLinesToDraw = std::min(numberOfLines(), static_cast<size_t>(charactersWide())); int linesToDraw = calculateHowManyLinesFitWithWrapping(maximumNumberOfLinesToDraw); int currentBaseline = 0; for (size_t i = linesToDraw; i > 0; i--) { renderLine(linesToDraw - i, currentBaseline); } }
void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b) { // query access to TexMaps // sort on height, y if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); renderLine ( a, b ); }
void UINodeSlider::render (int x, int y) const { UINode::render(x, y); x += getRenderX(); y += getRenderY(); const int w = getRenderWidth(); const int h = getRenderHeight(); const int deltaHeight = h / 2; const float steps = _max - _min + 1.0f; const float stepDelta = w / steps * (_stepWidth < 1.0f ? 1.0f : _stepWidth); const int sliderX = x + (_value - _min) / steps * w; renderLine(x, y + deltaHeight, x + w, y + deltaHeight, _lineColor); renderFilledRect(sliderX, y, stepDelta, h, _sliderColor); }
// ================================================ // render // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv void osgParticleHPS::ParticleTrail::render(const osg::Vec3 &xpos, const osg::Vec3 &px, const osg::Vec3 &py ) const { // set the color for the particle glColor4f( current_color_.x(), current_color_.y(), current_color_.z(), current_color_.w() ); //std::cout << "ParticleTrail::render - ratio " << (t0_ - timestampForLastNewPoint_) / timeBetweenPoints_ << std::endl; //std::cout << "ParticleTrail::render - xpos " << xpos << std::endl; //std::cout << "ParticleTrail::render - num points in trail: " << positions_.size() << std::endl; //std::cout << "roll is " << osg::RadiansToDegrees( angle_[0] ) << std::endl; if( !positions_.empty() ) { switch( trailType_ ) { case BUILT_IN_SHAPE: // cast away const-ness (sigh...) ((osgParticleHPS::ParticleTrail*)this)->renderBuiltInShape( px, py ); break; case LINE: renderLine(); break; case RIBBON: renderRibbon(); break; case CROSS_RIBBON: renderCrossRibbon(); break; case DEBUG: renderDebug( current_size_.x() ); break; default: break; } } }
void CTRTextureWire2::drawLine ( const s4DVertex *a,const s4DVertex *b) { // query access to TexMaps // sort on height, y if ( a->Pos.y > b->Pos.y ) swapVertexPointer(&a, &b); lockedSurface = (tVideoSample*)RenderTarget->lock(); #ifdef USE_ZBUFFER lockedDepthBuffer = (fp24*) DepthBuffer->lock(); #endif renderLine ( a, b ); RenderTarget->unlock(); #ifdef USE_ZBUFFER DepthBuffer->unlock(); #endif }
void carSimulation(std::vector<Car*> cars, std::vector<Wall>* walls, std::vector<glm::vec3>* path, std::vector<double>* distances, GLFWwindow* window) { //TODO: Move this junk to main, or a common class GLuint programID = LoadShaders( "SimpleTransform.vertexshader", "SingleColor.fragmentshader" ); GLuint MatrixID = glGetUniformLocation(programID, "MVP"); GLuint ColorID = glGetUniformLocation(programID, "inColor"); GLuint carbuffer; GLuint carVAO; glGenBuffers(1, &carbuffer); glBindBuffer(GL_ARRAY_BUFFER, carbuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(carData), carData, GL_STATIC_DRAW); glGenVertexArrays(1, &carVAO); glBindVertexArray(carVAO); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); GLuint wallbuffer; GLuint wallVAO; glGenBuffers(1, &wallbuffer); glBindBuffer(GL_ARRAY_BUFFER, wallbuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(wallData), wallData, GL_STATIC_DRAW); glGenVertexArrays(1, &wallVAO); glBindVertexArray(wallVAO); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); GLuint linebuffer; GLuint lineVAO; glGenBuffers(1, &linebuffer); glBindBuffer(GL_ARRAY_BUFFER, linebuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(lineData), lineData, GL_STATIC_DRAW); glGenVertexArrays(1, &lineVAO); glBindVertexArray(lineVAO); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); glm::mat4 Projection = glm::ortho(-50.0,50.0,-50.0,50.0,0.0,100.0); // In world coordinates int nextPoint = 1; int nbFrames = 0; double StartTime = glfwGetTime(); double time = StartTime; double frameLastTime = StartTime; double oldTime = StartTime; printf("starting\n"); while(cars.size() > 0 && time < 60 * 1) { time = glfwGetTime() - StartTime; // Measure speed double currentTime = glfwGetTime(); nbFrames++; if ( currentTime - frameLastTime >= 1.0 ) { // printf and reset timer printf("%f ms/frame\n", 1000.0/double(nbFrames)); nbFrames = 0; frameLastTime += 1.0; } double now = glfwGetTime(); double deltaTime = now - oldTime; oldTime = now; //test position /* glm::vec3 distance = myCar.getCenter() - path.at(nextPoint); */ /* printf("Next: %i (%f)\n", nextPoint, glm::dot(distance, distance)); */ /* if(glm::dot(distance, distance) < distances.at(nextPoint)*distances.at(nextPoint)) { */ /* nextPoint++; */ /* if (nextPoint > path.size() - 1) { */ /* nextPoint = 0; */ /* } */ /* } */ /* std::vector<Car*> carList = Car::getCarList(); */ glClear( GL_COLOR_BUFFER_BIT ); //start drawing for(std::vector<Car*>::iterator it = cars.begin(); it != cars.end();) { int increment = 1; (*it)->update(deltaTime,*walls); double input[LINE_COUNT + 1]; //For biasing input[0] = 1.0; glm::mat4 carMatrix = Projection * Car::getCamera() * (*it)->getMatrix(); render(programID, MatrixID, ColorID, carbuffer, carVAO, carMatrix, CAR_COLOR); std::vector<DetectLine> lines = (*it)->getLineList(); int i = 0; for (std::vector<DetectLine>::iterator lIt = lines.begin(); lIt != lines.end(); lIt++) { renderLine(programID, MatrixID, ColorID, linebuffer, lineVAO, Projection * Car::getCamera() * lIt->getMatrix(), LINE_COLOR); double closest = -1; for (std::vector<Wall>::iterator wIt = walls->begin(); wIt != walls->end(); wIt++) { glm::mat4 wallMatrix = wIt->getMatrix(); glm::vec3 wallB = glm::vec3(wallMatrix * glm::vec4(1.0,0.0,0.0,1.0)); glm::vec3 wallA = glm::vec3(wallMatrix * glm::vec4(-1.0,0.0,0.0,1.0)); //printf("A:%s, B:%s\n", glm::to_string(wallA).c_str(), glm::to_string(wallB).c_str()); double out = 0; if (collisionLineLine(lIt->getCenter(), lIt->getEnd(), wallA , wallB, &out) == true) { if (closest == -1 || out < closest) { closest = out; } } } input[i+1] = closest; i++; /* printf("Closest:%f\n",closest); */ lIt->setDistance(closest); } NEAT::Organism* org = (*it)->getOrganism(); if (org) { NEAT::Network* net = org->net; net->load_sensors(input); if (!(net->activate())) return; std::vector<NEAT::NNode*>::iterator out_iter = net->outputs.begin(); double steering = (*out_iter)->activation; out_iter++; double accel = (*out_iter)->activation; (*it)->input(accel, steering); glm::vec3 distance = (*it)->getCenter() - path->at(nextPoint); glm::vec3 totalDistance = path->at(nextPoint-1) - path->at(nextPoint); double newFit = (*it)->pointDist + glm::dot(totalDistance, totalDistance)- glm::dot(distance, distance); //remember, distance is squared double deltaFit = org->fitness - newFit; if (deltaFit < 1 && deltaFit > -1) { /* printf("Stuck: %i\n", (*it)->stuckTimer); */ (*it)->stuckTimer += 1; if ((*it)->stuckTimer > 500) { delete (*it); it = cars.erase(it); increment = 0; } } else { (*it)->stuckTimer = 0; } org->fitness = newFit; if(glm::dot(distance, distance) < distances->at(nextPoint)*distances->at(nextPoint)) { (*it)->pointDist += glm::dot(distance, distance); nextPoint++; if (nextPoint > path->size() - 1) { nextPoint = 0; } } /* printf("Fitness: %f\n", org->fitness); */ } if (increment) it++; } for(int i = 0; i < walls->size(); i++) { glm::mat4 wallMatrix = Projection * Car::getCamera() * walls->at(i).getMatrix(); render(programID, MatrixID, ColorID, wallbuffer, wallVAO, wallMatrix, WALL_COLOR); } //finish drawing glfwSwapBuffers(window); glClear( GL_COLOR_BUFFER_BIT ); glfwPollEvents(); } //Done, clean up for(std::vector<Car*>::iterator it = cars.begin(); it != cars.end(); it++) { delete (*it); } cars.clear(); }
void MapperRoomRender::renderHole(int x, int y, const Room *r) { CRect rp(x, y, x + m_size, y + m_size); int cs = m_csize; // corridor size to draw (included) int ds = 2; // doors offset to draw (included) - x= lefx - ds, len = cs + ds + ds int rs = (cs - m_roomsizeDeflate) * 2; rp.DeflateRect(cs, cs, rs, rs); // start points for corridors - top, bottom, left, right int offset = (rp.right - rp.left - cs) / 2; int leftx = rp.left + offset; int topy = rp.top + offset; POINT ct = { leftx, rp.top }; POINT cb = { leftx, rp.bottom }; POINT cl = { rp.left, topy }; POINT cr = { rp.right, topy }; int w = rp.right-rp.left + 1; int h = rp.bottom-rp.top + 1; HPEN old = m_hdc.SelectPen(m_white); bool skip_north_line = false; if (r->dirs[RD_NORTH].exist) { if (anotherZone(r, RD_NORTH)) { int x = ct.x - 1; int y = ct.y; int len = cs + 4; renderLine(x,y,len,0); renderLine(x,y-1,len,0); renderLine(x,y-2,len,0); } else if (neighbor(r, RD_NORTH)) { int x = ct.x; int x2 = ct.x + cs; int y = ct.y; int len = x - rp.left+1; renderLine(x, y, -len, 0); renderLine(x, y, 0, -len); renderLine(x2, y, len, 0); renderLine(x2, y, 0, -len); skip_north_line = true; } else { int x = ct.x + cs / 2; int y = ct.y; renderLine(x, y, 0, -3); renderLine(x + 1, y, 0, -3); } } if (!skip_north_line) { renderLine(rp.left,rp.top,w,0); } bool skip_south_line = false; if (r->dirs[RD_SOUTH].exist) { if (anotherZone(r, RD_SOUTH)) { int x = cb.x - 1; int y = cb.y; int len = cs + 4; renderLine(x, y, len, 0); renderLine(x, y + 1, len, 0); renderLine(x, y + 2, len, 0); } else if (neighbor(r, RD_SOUTH)) { int x = cb.x; int x2 = cb.x + cs; int y = cb.y; int len = x - rp.left + 1; renderLine(x, y, -len, 0); renderLine(x, y, 0, len); renderLine(x2, y, len, 0); renderLine(x2, y, 0, len); skip_south_line = true; } else { int x = cb.x + cs / 2; int y = cb.y; renderLine(x, y, 0, 3); renderLine(x + 1, y, 0, 3); } } if (!skip_south_line) { renderLine(rp.left, rp.bottom, w, 0); } bool skip_west_line = false; if (r->dirs[RD_WEST].exist) { if (anotherZone(r, RD_WEST)) { int x = cl.x; int y = cl.y - 1; int len = cs + 4; renderLine(x, y, 0, len); renderLine(x-1, y, 0, len); renderLine(x-2, y, 0, len); } else if (neighbor(r, RD_WEST)) { int x = cl.x; int y = cl.y; int y2 = cl.y + cs; int len = y - rp.top + 1; renderLine(x, y, 0, -len); renderLine(x, y, -len, 0); renderLine(x, y2, 0, len); renderLine(x, y2, -len, 0); skip_west_line = true; } else { int x = cl.x; int y = cl.y + cs / 2; renderLine(x, y, -3, 0); renderLine(x, y+1, -3, 0); } } if (!skip_west_line) { renderLine(rp.left,rp.top,0,h); } bool skip_east_line = false; if (r->dirs[RD_EAST].exist) { if (anotherZone(r, RD_EAST)) { int x = cr.x; int y = cr.y - 1; int len = cs + 4; renderLine(x, y, 0, len); renderLine(x + 1, y, 0, len); renderLine(x + 2, y, 0, len); } else if (neighbor(r, RD_EAST)) { int x = cr.x; int y = cr.y; int y2 = cr.y + cs; int len = y - rp.top + 1; renderLine(x, y, 0, -len); renderLine(x, y, len, 0); renderLine(x, y2, 0, len); renderLine(x, y2, len, 0); skip_east_line = true; } else { int x = cr.x; int y = cr.y + cs / 2; renderLine(x, y, 3, 0); renderLine(x, y + 1, 3, 0); } } if (!skip_east_line) { renderLine(rp.right, rp.top, 0, h); } int de = cs + 1; if (r->dirs[RD_UP].exist) { int x = rp.left + 3; int y = rp.top + 3; renderLine(x,y,0,de); renderLine(x,y,de,0); } if (r->dirs[RD_DOWN].exist) { int x = rp.right - 4; int y = rp.bottom - 4; renderLine(x,y,0,-de); renderLine(x,y,-de,0); } m_hdc.SelectPen(old); }
void MapperRoomRender::renderRoom(int x, int y, const Room *r) { CRect rp( x, y, x+m_size, y+m_size ); //CRect base(rp); int cs = m_csize; // corridor size to draw (included) int ds = 2; // doors offset to draw (included) - x= lefx - ds, len = cs + ds + ds int rs = (cs- m_roomsizeDeflate) * 2; rp.DeflateRect(cs, cs, rs, rs); CRect bk(rp); bk.DeflateRect(2,2,0,0); HPEN old1 = m_hdc.SelectPen(m_black); rp.OffsetRect(1, 1); renderRect(rp.left,rp.top,rp.right-rp.left,rp.bottom-rp.top); rp.OffsetRect(-1, -1); m_hdc.SelectPen(m_white); renderRect(rp.left,rp.top,rp.right-rp.left,rp.bottom-rp.top); int offset = (rp.right - rp.left - cs) / 2; // start points for corridors - top, bottom, left, right int leftx = rp.left + offset; int topy = rp.top + offset; POINT ct = { leftx, rp.top }; POINT cb = { leftx, rp.bottom }; POINT cl = { rp.left, topy }; POINT cr = { rp.right, topy }; if (r->dirs[RD_NORTH].exist) { if (anotherZone(r, RD_NORTH)) { int x0 = ct.x; int x = ct.x - ds; int y = ct.y - 1; int len = cs + ds + ds; m_hdc.SelectPen(m_exit); renderLine(x,y,len,0); renderLine(x,y+1,len,0); renderLine(x,y+2,len,0); m_hdc.SelectPen(m_exitL); renderLine(x0,y+1,cs,0); } else if (neighbor(r, RD_NORTH)) { int x = ct.x; int x2 = x + cs; int y = ct.y; int len = -(cs+2); m_hdc.SelectPen(m_black); renderLine(x+1, y, 0, len); renderLine(x2, y, 0, len); m_hdc.SelectPen(m_white); renderLine(x, y, 0, len); renderLine(x2-1, y, 0, len); renderLine(x2, y, 1, 1); m_hdc.SelectPen(m_bkg); renderLine(x2-1, y+1, 1, 1); len = -(cs + 3); fillBkg(x + 2, y + 2, cs - 3, len); // затираем стенку } else { m_hdc.SelectPen(m_white); int x = ct.x + cs / 2; int y = ct.y; int dx = 0; int dy = 0; if (!calcDestOffset(dx, dy, r, RD_NORTH)) { renderLine(x, y, 0, -3); renderLine(x+1, y, 0, -3); } else { dy = dy + rp.bottom-rp.top; renderArrow(x+dx, y+dy, -5, 5, 5, 4, 1, 0); renderLine(x, y, dx, dy); renderLine(x+1, y, dx, dy); } } if (r->dirs[RD_NORTH].door) { int x = ct.x - ds; int y = ct.y; int len = cs + ds + ds; m_hdc.SelectPen(m_door); renderLine(x, y, len, 0); m_hdc.SelectPen(m_black); renderLine(x,y+1,len,0); } } if (r->dirs[RD_SOUTH].exist) { if (anotherZone(r, RD_SOUTH)) { int x0 = cb.x; int x = cb.x - ds; int y = cb.y + 1; int len = cs + ds + ds; m_hdc.SelectPen(m_exit); renderLine(x, y, len, 0); renderLine(x, y - 1, len, 0); renderLine(x, y - 2, len, 0); m_hdc.SelectPen(m_exitL); renderLine(x0, y - 1, cs, 0); } else if (neighbor(r, RD_SOUTH)) { int x = cb.x; int x2 = x + cs; int y = cb.y; int len = cs + 2; m_hdc.SelectPen(m_black); renderLine(x + 1, y, 0, len); renderLine(x2, y, 0, len); m_hdc.SelectPen(m_white); renderLine(x, y, 0, len); renderLine(x2 - 1, y, 0, len); m_hdc.SelectPen(m_bkg); renderLine(x+1, y-1, 1, 1); len = cs + 3; fillBkg(x + 2, y - 2, cs-3, len); // затираем стенку } else { m_hdc.SelectPen(m_white); int x = cb.x + cs / 2; int y = cb.y; int dx = 0; int dy = 0; if (!calcDestOffset(dx, dy, r, RD_SOUTH)) { renderLine(x, y, 0, 3); renderLine(x+1, y, 0, 3); } else { dy = dy - (rp.bottom-rp.top); renderArrow(x+dx, y+dy, -5, -5, 5, -4, 1, 0); renderLine(x, y, dx, dy); renderLine(x+1, y, dx, dy); } } if (r->dirs[RD_SOUTH].door) { int x = cb.x - ds; int y = cb.y ; int len = cs + ds + ds; m_hdc.SelectPen(m_door); renderLine(x, y, len, 0); m_hdc.SelectPen(m_black); renderLine(x, y-1, len, 0); } } if (r->dirs[RD_WEST].exist) { if (anotherZone(r, RD_WEST)) { int y0 = cl.y; int y = cl.y - ds; int x = cl.x + 1; int len = cs + ds + ds; m_hdc.SelectPen(m_exit); renderLine(x, y, 0, len); renderLine(x-1 , y, 0, len); renderLine(x-2, y, 0, len); m_hdc.SelectPen(m_exitL); renderLine(x-1, y0, 0, cs); } else if (neighbor(r, RD_WEST)) { int x = cl.x; int y = cl.y; int y2 = cl.y + cs; int len = -(cs + 2); m_hdc.SelectPen(m_black); renderLine(x, y+1, len, 0); renderLine(x, y2, len, 0 ); m_hdc.SelectPen(m_white); renderLine(x, y, len, 0); renderLine(x, y2-1, len, 0); renderLine(x, y2, 1, 1); m_hdc.SelectPen(m_bkg); renderLine(x + 1, y2 - 1, 1, 1); len = -(cs + 3); fillBkg(x+2, y + 2, len, cs - 3); // затираем стенку } else { m_hdc.SelectPen(m_white); int x = cl.x; int y = cl.y + cs / 2; int dx = 0; int dy = 0; if (!calcDestOffset(dx, dy, r, RD_WEST)) { renderLine(x, y, -3, 0); renderLine(x, y+1, -3, 0); } else { dx = dx + rp.right-rp.left; renderArrow(x+dx, y+dy, 5, -5, 4, 5, -1, 0); renderLine(x, y, dx, dy); renderLine(x, y+1, dx, dy); } } if (r->dirs[RD_WEST].door) { int x = cl.x; int y = cl.y - ds; int len = cs + ds + ds; m_hdc.SelectPen(m_door); renderLine(x, y, 0, len); m_hdc.SelectPen(m_black); renderLine(x+1, y, 0, len); } } if (r->dirs[RD_EAST].exist) { if (anotherZone(r, RD_EAST)) { int y0 = cr.y; int y = cr.y - ds; int x = cr.x - 1; int len = cs + ds + ds; m_hdc.SelectPen(m_exit); renderLine(x, y, 0, len); renderLine(x + 1, y, 0, len); renderLine(x + 2, y, 0, len); m_hdc.SelectPen(m_exitL); renderLine(x + 1, y0, 0, cs); } else if (neighbor(r, RD_EAST)) { int x = cr.x; int y = cr.y; int y2 = cr.y + cs; int len = cs + 2; m_hdc.SelectPen(m_black); renderLine(x, y + 1, len, 0); renderLine(x, y2, len, 0); m_hdc.SelectPen(m_white); renderLine(x, y, len, 0); renderLine(x, y2 - 1, len, 0); m_hdc.SelectPen(m_bkg); renderLine(x-1 , y+1, 1, 1); len = cs + 3; fillBkg(x - 2, y + 2, len, cs - 3); // затираем стенку } else { m_hdc.SelectPen(m_white); int x = cr.x; int y = cr.y + cs / 2; int dx = 0; int dy = 0; if (!calcDestOffset(dx, dy, r, RD_EAST)) { renderLine(x, y, 3, 0); renderLine(x, y+1, 3, 0); } else { dx = dx - (rp.right-rp.left); renderArrow(x+dx, y+dy, -5, -5, -4, 5, 0, 1); renderLine(x, y, dx, dy); renderLine(x, y+1, dx, dy); } } if (r->dirs[RD_EAST].door) { int x = cr.x; int y = cr.y - ds; int len = cs + ds + ds; m_hdc.SelectPen(m_door); renderLine(x, y, 0, len); m_hdc.SelectPen(m_black); renderLine(x - 1, y, 0, len); } } int bkw = bk.Width()-1; int bkh = bk.Height()-1; if (!r->selected) { if (!r->use_color) fillBkg(bk.left, bk.top, bkw, bkh ); else fillColor(bk.left, bk.top, bkw, bkh, r->color); } else { fillColor(bk.left, bk.top, bkw, bkh, RGB(255, 255, 255)); } if (r->icon > 0) { int icons_count = m_plist->GetImageCount(); int icon_size = m_icons_size; int x = bk.left + (bk.Width() - icon_size) / 2 - 1; int y = bk.top + (bk.Height() - icon_size) / 2 - 1; if (r->icon <= icons_count) { HICON icon = m_plist->GetIcon(r->icon - 1); ::DrawIconEx(m_hdc, x, y, icon, icon_size, icon_size, 1, NULL, DI_NORMAL); } } int de = cs + 1; // size up/down corridor if (r->dirs[RD_UP].exist) { int x = rp.left + 3; int y = rp.top + 3; int x2 = x + de; int y2 = y + de; m_hdc.SelectPen(m_black); renderLine(x2, y, 0, de); renderLine(x2, y2, -de, 0); m_hdc.SelectPen(m_white); renderLine(x,y2,0,-de); renderLine(x,y,de+1,0); if (r->dirs[RD_UP].door) { fillWhite(x+1,y+1,de-1,de-1); } else if (!r->dirs[RD_UP].next_room) // unknown room { fillBlack(x+1,y+1,de-1,de-1); } if (anotherZone(r, RD_UP)) { fillExit(x+1,y+1,de-1,de-1); m_hdc.SelectPen(m_exitL); renderLine(x2, y, 0, de); renderLine(x2, y2, -de, 0); renderLine(x,y2,0,-de); renderLine(x,y,de+1,0); } } if (r->dirs[RD_DOWN].exist) { int x = rp.right - 3; int y = rp.bottom - 3; int x2 = x - de; int y2 = y - de; m_hdc.SelectPen(m_black); renderLine(x2, y, 0, -de); renderLine(x2, y2, de, 0); m_hdc.SelectPen(m_white); renderLine(x,y2,0,de); renderLine(x,y,-de-1,0); if (r->dirs[RD_DOWN].door) { fillWhite(x,y,-de+1,-de+1); } else if (!r->dirs[RD_DOWN].next_room) // unknown room { fillBlack(x,y,-de+1,-de+1); } if (anotherZone(r, RD_DOWN)) { fillExit(x,y,-de+1,-de+1); m_hdc.SelectPen(m_exitL); renderLine(x2, y, 0, -de); renderLine(x2, y2, de, 0); renderLine(x,y2,0,de); renderLine(x,y,-de-1,0); } } m_hdc.SelectPen(old1); }
void AbstractByteArrayColumnTextRenderer::renderFirstLine( QTextStream *stream, int lineIndex ) const { mRenderLine = lineIndex; renderLine( stream, false ); }
void AbstractByteArrayColumnTextRenderer::renderNextLine( QTextStream* stream, bool isSubline ) const { renderLine( stream, isSubline ); }
void cBatchRenderManager::render3D() { renderLine(); }
void WorldBoxRenderData::renderWorldBox(RenderArgs* args, gpu::Batch& batch) { auto geometryCache = DependencyManager::get<GeometryCache>(); // Show center of world static const glm::vec3 RED(1.0f, 0.0f, 0.0f); static const glm::vec3 GREEN(0.0f, 1.0f, 0.0f); static const glm::vec3 BLUE(0.0f, 0.0f, 1.0f); static const glm::vec3 GREY(0.5f, 0.5f, 0.5f); static const glm::vec4 GREY4(0.5f, 0.5f, 0.5f, 1.0f); static const glm::vec4 DASHED_RED(1.0f, 0.0f, 0.0f, 1.0f); static const glm::vec4 DASHED_GREEN(0.0f, 1.0f, 0.0f, 1.0f); static const glm::vec4 DASHED_BLUE(0.0f, 0.0f, 1.0f, 1.0f); static const float DASH_LENGTH = 1.0f; static const float GAP_LENGTH = 1.0f; auto transform = Transform{}; static std::array<int, 18> geometryIds; static std::once_flag initGeometryIds; std::call_once(initGeometryIds, [&] { for (size_t i = 0; i < geometryIds.size(); ++i) { geometryIds[i] = geometryCache->allocateID(); } }); batch.setModelTransform(transform); geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(HALF_TREE_SCALE, 0.0f, 0.0f), RED, geometryIds[0]); geometryCache->renderDashedLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(-HALF_TREE_SCALE, 0.0f, 0.0f), DASHED_RED, DASH_LENGTH, GAP_LENGTH, geometryIds[1]); geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, HALF_TREE_SCALE, 0.0f), GREEN, geometryIds[2]); geometryCache->renderDashedLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, -HALF_TREE_SCALE, 0.0f), DASHED_GREEN, DASH_LENGTH, GAP_LENGTH, geometryIds[3]); geometryCache->renderLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, HALF_TREE_SCALE), BLUE, geometryIds[4]); geometryCache->renderDashedLine(batch, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -HALF_TREE_SCALE), DASHED_BLUE, DASH_LENGTH, GAP_LENGTH, geometryIds[5]); // X center boundaries geometryCache->renderLine(batch, glm::vec3(-HALF_TREE_SCALE, -HALF_TREE_SCALE, 0.0f), glm::vec3(HALF_TREE_SCALE, -HALF_TREE_SCALE, 0.0f), GREY, geometryIds[6]); geometryCache->renderLine(batch, glm::vec3(-HALF_TREE_SCALE, -HALF_TREE_SCALE, 0.0f), glm::vec3(-HALF_TREE_SCALE, HALF_TREE_SCALE, 0.0f), GREY, geometryIds[7]); geometryCache->renderLine(batch, glm::vec3(-HALF_TREE_SCALE, HALF_TREE_SCALE, 0.0f), glm::vec3(HALF_TREE_SCALE, HALF_TREE_SCALE, 0.0f), GREY, geometryIds[8]); geometryCache->renderLine(batch, glm::vec3(HALF_TREE_SCALE, -HALF_TREE_SCALE, 0.0f), glm::vec3(HALF_TREE_SCALE, HALF_TREE_SCALE, 0.0f), GREY, geometryIds[9]); // Z center boundaries geometryCache->renderLine(batch, glm::vec3(0.0f, -HALF_TREE_SCALE, -HALF_TREE_SCALE), glm::vec3(0.0f, -HALF_TREE_SCALE, HALF_TREE_SCALE), GREY, geometryIds[10]); geometryCache->renderLine(batch, glm::vec3(0.0f, -HALF_TREE_SCALE, -HALF_TREE_SCALE), glm::vec3(0.0f, HALF_TREE_SCALE, -HALF_TREE_SCALE), GREY, geometryIds[11]); geometryCache->renderLine(batch, glm::vec3(0.0f, HALF_TREE_SCALE, -HALF_TREE_SCALE), glm::vec3(0.0f, HALF_TREE_SCALE, HALF_TREE_SCALE), GREY, geometryIds[12]); geometryCache->renderLine(batch, glm::vec3(0.0f, -HALF_TREE_SCALE, HALF_TREE_SCALE), glm::vec3(0.0f, HALF_TREE_SCALE, HALF_TREE_SCALE), GREY, geometryIds[13]); // Center boundaries geometryCache->renderLine(batch, glm::vec3(-HALF_TREE_SCALE, 0.0f, -HALF_TREE_SCALE), glm::vec3(-HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), GREY, geometryIds[14]); geometryCache->renderLine(batch, glm::vec3(-HALF_TREE_SCALE, 0.0f, -HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, -HALF_TREE_SCALE), GREY, geometryIds[15]); geometryCache->renderLine(batch, glm::vec3(HALF_TREE_SCALE, 0.0f, -HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), GREY, geometryIds[16]); geometryCache->renderLine(batch, glm::vec3(-HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), GREY, geometryIds[17]); geometryCache->renderWireCubeInstance(args, batch, GREY4); // Draw meter markers along the 3 axis to help with measuring things const float MARKER_DISTANCE = 1.0f; const float MARKER_RADIUS = 0.05f; transform = Transform().setScale(MARKER_RADIUS); batch.setModelTransform(transform); geometryCache->renderSolidSphereInstance(args, batch, RED); transform = Transform().setTranslation(glm::vec3(MARKER_DISTANCE, 0.0f, 0.0f)).setScale(MARKER_RADIUS); batch.setModelTransform(transform); geometryCache->renderSolidSphereInstance(args, batch, RED); transform = Transform().setTranslation(glm::vec3(0.0f, MARKER_DISTANCE, 0.0f)).setScale(MARKER_RADIUS); batch.setModelTransform(transform); geometryCache->renderSolidSphereInstance(args, batch, GREEN); transform = Transform().setTranslation(glm::vec3(0.0f, 0.0f, MARKER_DISTANCE)).setScale(MARKER_RADIUS); batch.setModelTransform(transform); geometryCache->renderSolidSphereInstance(args, batch, BLUE); transform = Transform().setTranslation(glm::vec3(MARKER_DISTANCE, 0.0f, MARKER_DISTANCE)).setScale(MARKER_RADIUS); batch.setModelTransform(transform); geometryCache->renderSolidSphereInstance(args, batch, GREY); }
int Application::execute(std::string filename){ init(); this->filename = filename; load(); render(); renderNumbers(); renderControl(); move(0,5); display->mv(0,0); current->set_pos(0); while(running){ int in = getch(); if(in == 258 || in == 259 || in == 339 || in == 338){ if(tempPos == -1) tempPos = current->cursor_position(); } else{ tempPos = -1; } if(in > 0x1F && in < 0x7F){//typable current->insert(in); changed = true; renderLine(); updateMove(); } else if(in == 263/*CWin::key_backspace()*/){ if(current->cursor_position()){ changed = true; current->decrementPos(); current->del(); renderLine(); updateMove(); } else if(!display->xPos() && current->prev()){ changed = true; int temp = current->prev()-> current->prev()->set_pos(current->prev()->string().end());//move the cursor to the joining point current->prev()->append(current->string());//move the strings together //some magic in order to pop the one node current = current->prev(); Line* temp = current->next(); if(temp->next()){ temp->next()->prev(current); current->next(temp->next()); } else current->next(NULL); delete temp; current->set_num(current->number()); (*current->string().begin())->set_pos(); updateMove(-1); render(); renderNumbers(); } } else if(in == 330){//del if(!current->del()){ renderLine(); } else if(current->next()){ current->append(current->next()->string()); Line* temp = current->next(); if(temp->next()){ current->next(temp->next()); current->next()->prev(current); } else current->next(NULL); delete temp; current->set_num(current->number()); (*current->string().begin())->set_pos(); render(); renderNumbers(); } changed = true; } else if(in == 24){//^X if(changed){ int temp = promptBool("Save before exit? [y/n/c] "); if(temp == 1) saveAs(); if(temp > -1) running = false; } else running = false; } else if(in == 258){//dn todo check scrolling things if(current->next()){ current = current->next(); current->set_pos(tempPos); if(current->cursor_position() < xShift){ if((int)current->cursor_position()-(int)display->xMax() < 0) xShift = 0; else xShift = current->cursor_position()-display->xMax(); render(); } if(display->yPos() == display->yMax()-1){ top = top->next(); updateMove(); render(); renderNumbers(); } else updateMove(1); } } else if(in == 259){//up if(current->prev()){ current = current->prev(); current->set_pos(tempPos); if(current->cursor_position() < xShift){ if((int)current->cursor_position()-(int)display->xMax() < 0) xShift = 0; else xShift = current->cursor_position()-display->xMax(); render(); } if(display->yPos() == 0 && top->prev()){ top = top->prev(); updateMove(); render(); renderNumbers(); } else updateMove(-1); } } else if(in == 260){//left current->decrementPos(); if(current->cursor_position() < xShift && xShift){ xShift--; render(); } updateMove(); } else if(in == 261){//right current->incrementPos(); if(current->cursor_position() > xShift+display->xMax()-1){ xShift = current->cursor_position()-display->xMax()+1; render(); } updateMove(); } else if(in == CWin::key_end()){ //current->set_pos(current->string().length()); current->set_pos(-1); if(current->cursor_position() < display->xMax()){ updateMove(); } else{ xShift = current->cursor_position()-display->xMax()+1; updateMove(); render(); } } else if(in == 262){//home String::iterator tempChar = current->string().begin(); while((*tempChar)->ch() < 0x21 || (*tempChar)->ch() > 0x7E) ++tempChar; current->set_pos(tempChar); if(current->cursor_position() < display->xMax()) xShift = 0; else xShift = current->cursor_position()-display->xMax()-1; updateMove(); render(); } else if(in == 443){//ctrl-left page left if(xShift){ xShift--; render(); } } else if(in == 444){//ctrl-right page right xShift++; render(); } else if(in == 265){//F1 help } else if(in == 6){//^F find std::string what = promptString("String to search: "); } else if(in == 15){//^O Mode } else if(in == 19){//^S Save save(); } else if(in == 18){//^R Reload } else if(in == 339){//page up if(top->prev()){ top = top->prev(); render(); renderNumbers(); updateMove(1); if(display->yPos() == display->yMax()){ current->prev()->set_pos(tempPos); current = current->prev(); updateMove(-1); } } } else if(in == 338){//page dn if(top->next()){//should be a check for the bottom? top = top->next(); render(); renderNumbers(); updateMove(-1); if(display->yPos() == (unsigned int)-1){ current->next()->set_pos(tempPos); current = current->next(); updateMove(1); } } } } return 0; }