Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: low performance in drawing primitives

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2010

    low performance in drawing primitives


    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:
    glVertex2i(x1, y1);
    glVertex2i(x2, y2);

    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

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2012
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts