示例#1
0
void Render::drawGrid() {
    glDisable(GL_LINE_SMOOTH);
    glBegin(GL_LINES);
    for (int y = getBottomBound(); y <= getTopBound(); y++) {
        if (y % 20 == 0)
            glColor3f(1,0,0.5);
        else
            glColor3f(0.8,0.8,0.8);
        glVertex2f(getLeftBound(), y);
        glVertex2f(getRightBound(), y);
     }
    for (int x = getLeftBound(); x <= getRightBound(); x++) {
       if (x % 100 == 0)
            glColor3f(1,0,0.5);
        else
            glColor3f(0.8,0.8,0.8);
        glVertex2f(x, getBottomBound());
        glVertex2f(x, getTopBound());
     }
    glEnd();
    glEnable(GL_LINE_SMOOTH);
}
示例#2
0
void Render::resizeGL(const int nWidth, const int nHeight) {
    int width = nWidth;
    int height = nHeight? nHeight: 1;
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    float aspectRatio = (float)width/height;
    if (width <= height) {
        setBounds(-viewRadius, viewRadius, -viewRadius/aspectRatio,
                  viewRadius/aspectRatio);
     } else {
        setBounds(-viewRadius*aspectRatio, viewRadius*aspectRatio,
                  -viewRadius, viewRadius);
    }
    glOrtho(getLeftBound(), getRightBound(), getBottomBound(), getTopBound(),
            1.0, -1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    updateGraph();
}
示例#3
0
bool BoundingBox::overlaps(BoundingBox *other) {
  return ( !(getUpperBound() > other->getLowerBound()) &&
	   !(getLowerBound() < other-> getUpperBound()) &&
	   !(getLeftBound() > other->getRightBound()) &&
	   !(getRightBound() < other->getLeftBound()) );
}