|
Experienced java developer but relatively new to jogl and openGL. I have researched this and could not find a solution. Some of the code for related issues (but not exactly what I wanted) was old and the jogl API has apparently changed so the signatures were not correct so I could not readily adapt it.
What I am trying to do: I have a high energy physics application that displays particle detectors. I draw hits in the detectors as points. But the points in basic jogl/opengl seem to be just squares. So what I would like to do is draw small images (pngs) at the points. So the basic problem is: draw images from png files (resources) at points.
I start by loading the image from a jar file via
_sprite = TextureIO.newTexture(_url, false, ".png");
this seems to work fine. For instance, the sprite reports the correct image size.Then I try to draw the (same sprite) at a set of points using
public static void drawSprites(GLAutoDrawable drawable, float coords[],
Texture sprite, float size) {
GL2 gl = drawable.getGL().getGL2();
gl.glPointSize(size);
sprite.bind(gl);
//how many points?
int np = coords.length / 3;
gl.glBegin(GL.GL_POINTS);
for (int i = 0; i < np; i++) {
int j = i * 3;
gl.glVertex3f(coords[j], coords[j + 1], coords[j + 2]);
}
gl.glEnd();
}
But all I get are the points-- i.e. squares. The squares are at the right xyz location--but they are just squares. No images.
Yes I know this is a noob mistake that will annoy the experts--I'll accept public humiliation as long as I get a solution! Thanks.
|