This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Any obvious reason my first CNI function (xlib.GC.fillPolygon) doesn't work?


In order to get fillPolygon working on xlib, I had to implement a function
in natGC.cc.  Since this is my first CNI function I'm hoping the reason it
doesn't work (compiles fine, but nothing paints on the screen) is that I've
done something wrong which will be obvious to someone who's done lots of
CNI.

Is there an obvious gaffe in the following code?

In GC.java:
  public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);

In natGC.cc (the fourth arg to XFillPolygon is type "XPoint *"):
void gnu::gcj::xlib::GC::fillPolygon(jintArray xPoints, jintArray yPoints,
jint nPoints)
{
  Display* display = target->getDisplay();
  ::Display* dpy = (::Display*) (display->display);
  ::Drawable drawableXID = target->getXID();
  ::GC gc = (::GC) structure;
  typedef ::XPoint xpoint;
  std::vector<xpoint> points(nPoints+1);
  for( int i=0; i<nPoints; i++ )
  {
    points[i].x = elements(xPoints)[i];
    points[i].y = elements(yPoints)[i];
  }
  points[nPoints] = points[0];    // in case the ends don't meet
  XFillPolygon(dpy, drawableXID, gc, &(points.front()), nPoints, Complex,
CoordModeOrigin );
  // no fast fail
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]