Low performance in drawing primitives

Hi,

I am working on a java application that draws some primitives pixelwise. Then I decided to create a jni library that calls some functions which draw primitives using OpenGL, such that the drawing is now done natively using hardware acceleration.

Thus for example, I am asked by the JAVA to draw a line and so in the JNI function draw_line() I do something similar to this:
glBegin(GL_LINES);
glVertex2i(x1, y1);
glVertex2i(x2, y2);
glEnd();

Other functions are taking this approach too, ie. the immediate mode, for example to draw a texture on a rectangular area, draw a rectangle etc. I’ve read some posts online which discourage you from drawing using this approach and to use VBO instead, but only when you have a large number of vertices. Thus i took the former approach since in every jni drawing function I am asked to draw a simple primitive, like mapping a texture on a rectangular area or drawing a rectangle. Is this approach correct?

When running the application, testing it with drawing primitives continuously, it was found to be very slow when compared to the same application drawing each primitive pixelwise in java without opengl (ie the way it was done before). Do you have any suggestions to why this Opengl JNI approach is much slower than the java drawing when its supposed to be faster using hardware acceleration?

I am using a Mac Pro 1.1 machine, proc name: Dual core Intel Xeon, speed: 3GHz, 2 processors, 4 cores, graphics card: NVIDIA GeForce 7300GT, 256MB

Thanks and regards

You should take into account the amount of overhead that comes with JNI calls. See this post for more information. Also, try the Java-Gaming forum next time you’re asking about Java and JNI. You’ll probably find more help there.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.