Esempio n. 1
0
void eglSubWindow::RenderGLScene(void)
{
	eglWindow::RenderGLScene();

	glTranslatef(0.0f, 0.0f, -10.0f);
	glColor3f(1.0f, 0.0f, 0.0f);
	glPointSize(10.0f);
	glBegin(GL_POINTS);
		for(piter i=mPointList.begin(); i!=mPointList.end(); ++i)
		{
			glVertex3f((*i).x, (*i).y, (*i).z); 			
		}
	glEnd();
}
Esempio n. 2
0
void eglSubWindow::OnLButtonDown(WPARAM wParam, LPARAM lParam)
{
	GLfloat xPos = (GLfloat)(LOWORD(lParam));
	GLfloat yPos = (GLfloat)(HIWORD(lParam));

	GLfloat glX = ((xPos * (2*Range)) / ClientWidth)  - Range;
	GLfloat glY = ((yPos * (2*Range)) / ClientHeight) - Range;
	
	mPointList.push_back(Point3D(glX, -glY, 0.0f));
	TRACE("glVertex3f[ %f , %f , %f ]\n", glX, -glY, 0.0f);
}
Esempio n. 3
0
void build_shapes(point_list& points, shape_map& shapes, unique_shapes& uniques) {
  points.sort();
  int x,y;

  for (point_list::iterator it(points.begin()), end(points.end()); it != end; ++it) {
    x = it->first;
    y = it->second;
#ifdef DEBUG_BS
    cerr << it->first << " " << it->second << endl;
#endif
    int above = 0, left = 0;

    // check top
    if (y) // y-1 >= 0
      above = field[x][y-1];
    if (above) {
#ifdef DEBUG_BS
      cerr << "shape above!" << endl;
#endif
      // include this point into shape found above
      field[x][y] = above;
      shapes[above]->add(x, y);
    }

    // check left
    if (x) //(x-1 >= 0)
      left = field[x-1][y];
    if (left) {
#ifdef DEBUG_BS
      cerr << "shape on the left!" << endl;
#endif
      if (above) {
        if (shapes[above] != shapes[left]) {
        //if (above != left) {
#ifdef DEBUG_BS
          cerr << "combining!" << endl;
#endif
          // there was a different shape above as well
          // ==> fuse two shapes together
          shapes[above]->combine(*shapes[left]);
          // overwrite
          shape* s = shapes[left];
          uniques.erase(shapes[left]);
          delete s;
          shapes[left] = shapes[above];
        }
      } else {
        // include this point into shape to the left
        field[x][y] = left;
        shapes[left]->add(x, y);
      }
    }

#ifdef DEBUG_BS
    cerr << "above: " << above << " left: " << left << endl;
#endif
    if (!above && !left) { // no adjacent shapes, create new one
      shape* s = new shape(x,y);
      uniques.insert(s);
      field[x][y] = s->id;
      shapes[s->id] = s;
    }
  }
}