OK. May be as the topic is same I should continue here only. There is one more function in that cpp file.
The query is small, but the code I have given displays more lines. Basically, I have a base class Figure; and from that I have derived classes like Line, Triangle, Quad....

Original author has implemented figureSet as vector, I implemented it as python list while converting the code.  In the below code snippet, "in the if-else part", I am not able to make out, how will I convert the code in python?

Guyz please help. I need to get the full working python clone by tomorrow & I am stuck at few places.

Full c code -> http://sprunge.us/OUKM?cpp & header file is here http://sprunge.us/OUKM?cpp

void drawSel() {
  glColor3f(0, 0, 0);
  int size = figureSet.size();
  Figure *f = figureSet[selected];

  /* getPoint() is a virtual method: every figure has at least
      two points (is at least a line) */
  int *pt1 = f->getPoint(1)->getCoords();
  int *pt2 = f->getPoint(2)->getCoords();

  if (Triangle *t = dynamic_cast<Triangle*>(f)) { // triangle: one more point
     int *pt3 = t->getPoint(3)->getCoords();
     //something happens here
  }
  else if (Quad *q = dynamic_cast<Quad*>(f)) { // quad: two more point
     int *pt3 = q->getPoint(3)->getCoords();
     int *pt4 = q->getPoint(4)->getCoords();
     //Something happens here
  }
}


On Sun, Apr 17, 2011 at 10:49 PM, Joshua R. Davis <joshuardavis@q.com> wrote:
Converting C/C++ OpenGL code to PyOpenGL code takes a little practice, due to small alterations in how PyOpenGL function calls use parameters. Rather than directly answering your question, let me point you to completely abstracted PyOpenGL picking and collision-testing functions on my web site:

   http://www.joshuadavis.us/software/selection.py

You can use this code as-is, or you can view it as a tutorial. Also, please be aware that the selection mechanism is deprecated in OpenGL now. It is preferable to pick using the back buffer, for example. Hope this helps.

Josh



--
Regards,
Abhijeet Rastogi (shadyabhi)
http://www.google.com/profiles/abhijeet.1989