void Object::draw() { if (isActive()) { auto& gfxMgr = GraphicsManager::getInstance(); int index = getSpriteIndex(); int count = getSpriteSlowdownCount(); gfxMgr.drawFrame(pos, p_sprite->getFrame(index), isCentered(), getTransparency(), p_sprite->getColor()); if (sprite_slowdown == 0) { return; } else { count++; if (count >= sprite_slowdown) { count = 0; ++index %= (p_sprite->getFrameCount()); } } setSpriteSlowdownCount(count); setSpriteIndex(index); } }
//------------------------------------------------------------------------------ // draw() //------------------------------------------------------------------------------ void BearingPointer::draw() { bool c = isCentered(); LCreal dis = getDisplacement(); lcSaveMatrix(); if (!c) lcTranslate(0, dis); lcRotate(myRotation); BasicGL::Graphic::draw(); lcRestoreMatrix(); }
//------------------------------------------------------------------------------ // drawFunc() -- draws the object(s) using openGL //------------------------------------------------------------------------------ void BearingPointer::drawFunc() { GLfloat ocolor[4]; GLfloat lw; glGetFloatv(GL_CURRENT_COLOR, ocolor); glGetFloatv(GL_LINE_WIDTH, &lw); // draw a default head and tail graphic, unless one is given to us, then draw it myRadius = 0; bool amICentered = isCentered(); if (amICentered) myRadius = getCenteredRadius(); else myRadius = getDeCenteredRadius(); // now draw the head graphic glPushMatrix(); // translate to the top of our radius glTranslated(0, GLdouble(myRadius), 0); if (head != 0) { head->container(this); head->draw(); } else { glBegin(GL_POLYGON); glVertex2f(-0.5, 0); glVertex2f(0.5, 0); glVertex2f(0, 0.5); glEnd(); } glPopMatrix(); // now draw the tail graphic glPushMatrix(); // translate to the bottom of our radius glTranslated(0, GLdouble(-myRadius), 0); if (tail != 0) { tail->container(this); tail->draw(); } else { glLineWidth(3); glBegin(GL_LINES); glVertex2f(0, 0); glVertex2f(0, -0.5); glEnd(); } glPopMatrix(); glColor4fv(ocolor); glLineWidth(lw); }