Skip to main content

Problem with Open GL Java 3D(Graphs are very slow) , How can i solve?

19 replies [Last post]
miguelmu123
Offline
Joined: 2010-05-11

Hi, I have a problem with my application, my aplication uses Java 3D to show 3D Graphs.

When I use OpenGL renderer the graphs are very slow and when I use Direct3D renderer the graphs run Ok.

I Investigated the problem with the application Dependency Walker, and I saw that Java3d with opengl as renderer is continually loading the library openGL32.dll for each call to JNI method:

LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED55E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED55E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED55E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglSwapBuffers") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED5E21.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED55E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED55E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED55E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x6AE90000.
GetProcAddress(0x6AE90000 [OPENGL32.DLL], "wglSwapBuffers") called from "GDI32.DLL" at address 0x75075876 and returned 0x6AED5E21.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.

And I saw that Java3d with direct3d as renderer only load the library D3D9.DLL once time and then call to multiples JNI methods:
LoadLibraryA("C:\Windows\system32\d3d9.dll") called from "D3D9.DLL" at address 0x70EF8761.

"_Java_javax_media_j3d_NativePipeline_updateSeparateSpecularColorEnable@20") called from "HPI.DLL" at address 0x6D29116A and returned NULL. Error: No se encontr el proceso especificado (127).
GetProcAddress(0x060F0000 [J3DCORE-D3D.DLL], "_Java_javax_media_j3d_NativePipeline_updateSeparateSpecularColorEnable@20") called from "HPI.DLL" at address 0x6D29116A and returned 0x060F4C10.
GetProcAddress(0x6D360000 [JAWT.DLL], "_Java_javax_media_j3d_NativePipeline_setSceneAmbient@28") called from "HPI.DLL" at address 0x6D29116A and returned NULL. Error: No se encontr el proceso especificado (127).
GetProcAddress(0x060F0000 [J3DCORE-D3D.DLL], "_Java_javax_media_j3d_NativePipeline_setSceneAmbient@28") called from "HPI.DLL" at address 0x6D29116A and returned 0x060F1720.
GetProcAddress(0x6D360000 [JAWT.DLL], "_Java_javax_media_j3d_NativePipeline_disableFog@16") called from "HPI.DLL" at address 0x6D29116A and returned NULL. Error: No se encontr el proceso especificado (127).

I think the problem is the load Library iteration in OpenGL.

How I can solve this problem to use openGL renderer in my application?

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miguelmu123
Offline
Joined: 2010-05-11

Sorry but my english isn´t very good and I didn't undestand you before.

My application show a lot of points in a 3D graphs(A cube with 3 axis), I support zoom & rotations with mouse.

But i proved a demo code of Java3D of java3D and it also runs slow:

The demo code is:
public class Demo{

private SimpleUniverse universe;
private Appearance cubeAppearance;
private BranchGroup rootGroup;
private BoundingSphere bounds;

public void init() {
createUniverse();
createAppearance();
createCubeOfCubes();
createLights();
createBehaviourInteractors();
universe.getViewingPlatform().setNominalViewingTransform();

// add the cube group of objects to SimpleUnvirse object
universe.addBranchGraph(rootGroup);
}

private void createUniverse() {
universe = new SimpleUniverse();
rootGroup = new BranchGroup();
bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

}

private void createAppearance() {
cubeAppearance = new Appearance();
Color3f ambientColour = new Color3f();
ambientColour.set(Color.GRAY);
Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);
Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);
Color3f diffuseColour = new Color3f();
diffuseColour.set(Color.GRAY);

float shininess = 20.0f;
cubeAppearance.setMaterial(new Material(ambientColour, emissiveColour,
diffuseColour, specularColour, shininess));
}

private void createCubeOfCubes() {
// build up a cube of 10 cube for each axis (x, y, z)
for (float x = -.5f; x <= .5f; x = x + .1f) {
for (float y = -.5f; y <= .5f; y += .1f) {
for (float z = -.5f; z <= .5f; z += .1f) {
Box box = new Box(0.02f, 0.02f, 0.02f, cubeAppearance);
TransformGroup tg = new TransformGroup();
Transform3D transform = new Transform3D();
Vector3f vector = new Vector3f(x, y, z);
transform.setTranslation(vector);
tg.setTransform(transform);
tg.addChild(box);
rootGroup.addChild(tg);
}
}

}
}

private void createLights() {
Color3f ambientLightColour = new Color3f(0.9f, 0.9f, 0.9f);
AmbientLight ambientLight = new AmbientLight(ambientLightColour);
ambientLight.setInfluencingBounds(bounds);
Color3f directionLightColour = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f directionLightDir = new Vector3f(-1.0f, -1.0f, -1.0f);
DirectionalLight directionLight = new DirectionalLight(directionLightColour, directionLightDir);
directionLight.setInfluencingBounds(bounds);
rootGroup.addChild(ambientLight);
rootGroup.addChild(directionLight);
}

private void createBehaviourInteractors() {
TransformGroup viewTransformGroup =
universe.getViewingPlatform().getViewPlatformTransform();

KeyNavigatorBehavior keyInteractor =
new KeyNavigatorBehavior(viewTransformGroup);

BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0, 0.0,
0.0), 100.0);
keyInteractor.setSchedulingBounds(movingBounds);
rootGroup.addChild(keyInteractor);

MouseRotate behavior = new MouseRotate();
behavior.setTransformGroup(viewTransformGroup);
rootGroup.addChild(behavior);
behavior.setSchedulingBounds(bounds);
}

public static void main(String[] args) {
(new Demo()).init();
}
}

Thanks for all.
Best regards

miguelmu123
Offline
Joined: 2010-05-11

private void createCubeOfCubes() {
// build up a cube of 10 cube for each axis (x, y, z)
for (float x = -.5f; x <= .5f; x = x + .1f) {
for (float y = -.5f; y <= .5f; y += .1f) {
for (float z = -.5f; z <= .5f; z += .1f) {
Box box = new Box(0.02f, 0.02f, 0.02f, cubeAppearance);
TransformGroup tg = new TransformGroup();
Transform3D transform = new Transform3D();
Vector3f vector = new Vector3f(x, y, z);
transform.setTranslation(vector);
tg.setTransform(transform);
tg.addChild(box);
rootGroup.addChild(tg);
}
}

}
}

private void createLights() {
Color3f ambientLightColour = new Color3f(0.9f, 0.9f, 0.9f);
AmbientLight ambientLight = new AmbientLight(ambientLightColour);
ambientLight.setInfluencingBounds(bounds);
Color3f directionLightColour = new Color3f(1.0f, 1.0f, 1.0f);
Vector3f directionLightDir = new Vector3f(-1.0f, -1.0f, -1.0f);
DirectionalLight directionLight = new DirectionalLight(directionLightColour, directionLightDir);
directionLight.setInfluencingBounds(bounds);
rootGroup.addChild(ambientLight);
rootGroup.addChild(directionLight);
}

private void createBehaviourInteractors() {
TransformGroup viewTransformGroup =
universe.getViewingPlatform().getViewPlatformTransform();

KeyNavigatorBehavior keyInteractor =
new KeyNavigatorBehavior(viewTransformGroup);

BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0, 0.0,
0.0), 100.0);
keyInteractor.setSchedulingBounds(movingBounds);
rootGroup.addChild(keyInteractor);

MouseRotate behavior = new MouseRotate();
behavior.setTransformGroup(viewTransformGroup);
rootGroup.addChild(behavior);
behavior.setSchedulingBounds(bounds);
}

public static void main(String[] args) {
(new Fcs()).init();
}

miguelmu123
Offline
Joined: 2010-05-11

the link of the example:
http://developers-blog.org/blog/default/2010/02/15/Java3D-Example-1

Becasuse I had problem to write all the code. :D

aces
Offline
Joined: 2003-07-17

An explanation :

Java3D can use OpenGL, D3D and JOGL.

Just use -Dj3d.rend=jogl in cmd line to get Java3D using JOGL, but it requires you put JOGL jars and DLLs on path.

the default OpenGL renderer uses j3dcore-ogl.dll , while the jogl pipeline doesn't use Java3D's original dlls.

miguelmu123
Offline
Joined: 2010-05-11

Ok , thanks for the explanation. :D
I changed java 3D renderer to jogl, and I've had the same problem, :(

I've seen in the application Dependency Walker that java3D using jogl as renderer loads the library opengl32.dll continually as java3D rendered with opengl:

GetProcAddress(0x76100000 [KERNEL32.DLL], "EncodePointer") called from "NVD3DUM.DLL" at address 0x6C8BDF59 and returned 0x772D0E7B.
GetProcAddress(0x76100000 [KERNEL32.DLL], "DecodePointer") called from "NVD3DUM.DLL" at address 0x6C8BDF69 and returned 0x772C9BA5.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x62D10000.
GetProcAddress(0x62D10000 [OPENGL32.DLL], "wglGetPixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x62D555E8.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x62D10000.
GetProcAddress(0x62D10000 [OPENGL32.DLL], "wglChoosePixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x62D5651B.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x62D10000.
GetProcAddress(0x62D10000 [OPENGL32.DLL], "wglDescribePixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x62D55D32.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x62D10000.
GetProcAddress(0x62D10000 [OPENGL32.DLL], "wglDescribePixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x62D55D32.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x62D10000.
GetProcAddress(0x62D10000 [OPENGL32.DLL], "wglDescribePixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x62D55D32.
LoadLibraryA("OPENGL32") called from "GDI32.DLL" at address 0x75075863.
LoadLibraryA("OPENGL32") returned 0x62D10000.
GetProcAddress(0x62D10000 [OPENGL32.DLL], "wglDescribePixelFormat") called from "GDI32.DLL" at address 0x75075876 and returned 0x62D55D32.
...

Why when we uses OpenGL in java3D(java3D rendered with ogl or jogl) java is loading continually the dll, and using Direct3D only loads the dll once time?

I think that is more efficient load the library once time.

Thanks for all.

darwinjob
Offline
Joined: 2004-11-16

>I think that is more efficient load the library once time.

Is this some kind of trolling? :)

miguelmu123
Offline
Joined: 2010-05-11

No, no!! I only think that is very strange that java3d with opengl or jogl is continually loading the library, and I think that my performance problem could be caused by this.

Sorry if you think that I was trolling, but i wasn't trolling.

darwinjob
Offline
Joined: 2004-11-16

IMHO there is something in your code. I barely can imagine a situation when Java3D D3D pipeline works better then OpenGL on NVIDIA card. But since you are ignoring the question about what you are visualizing there we will never know.

aces
Offline
Joined: 2003-07-17

I'd like to suggest the following :

1) Test if the Java3D demos also suffer of low FPS behavior
2) Test if the JOGL demos also suffer of low FPS

3) Use a "OpenGL extension viewer" to check out about OpenGL performance
http://www.realtech-vr.com/glview/download.html

Step 1) and 2) may clear doubts about issues in your code or in Java3D
Step 3) check if OpenGL is OK for standard applications.

Good Luck ;)

gzdillon
Offline
Joined: 2010-10-18

Hi, could you please tell me how to switch OpenGL and D3D?

miguelmu123
Offline
Joined: 2010-05-11

You must use this arguments
use -Dj3d.rend=jogl (JOGL)
use -Dj3d.rend=ogl (OpenGL)
use -Dj3d.rend=d3d (Direct3D)

darwinjob
Offline
Joined: 2004-11-16

Dependency Walker is cool, but check the driver version, Java3D version and so on. Be sure that you have the latest everything. What kind of card do you have?

miguelmu123
Offline
Joined: 2010-05-11

Well I have a GeForce GT320 with the last drivers, but I have proved my application in others PCs with other graphic cards(Intel on board, ATI Raddeon, ..., with the last drivers), and I have had the same problem on these PCs.

I use the Java3D version 1.5.2.

Thanks for all.

darwinjob
Offline
Joined: 2004-11-16

This is weird. GeForce GT320 should work with OpenGL by default.
Run this:
http://download.java.net/media/java3d/webstart/test/QueryProperties.jnlp

and tell me what you see.

miguelmu123
Offline
Joined: 2010-05-11

Hello, these are the properties than the application returns:

j3d.version = 1.5.2 fcs (build4)
j3d.vendor =
j3d.specification.version = 1.5
j3d.specification.vendor =
j3d.pipeline = NATIVE_OGL
j3d.renderer = OpenGL

native.renderer = GeForce GT 320/PCI/SSE2
native.vendor = NVIDIA Corporation
native.version = 3.3.0
doubleBufferAvailable = true
stereoAvailable = false
sceneAntialiasingAvailable = true
sceneAntialiasingNumPasses = 1
compressedGeometry.majorVersionNumber = 1
compressedGeometry.minorVersionNumber = 0
compressedGeometry.minorMinorVersionNumber = 2
textureUnitStateMax = 4
textureWidthMax = 8192
textureHeightMax = 8192
shadingLanguageCg = false
shadingLanguageGLSL = true
stencilSize = 0
texture3DAvailable = true
texture3DDepthMax = 2048
texture3DHeightMax = 2048
texture3DWidthMax = 2048
textureAnisotropicFilterDegreeMax = 16.0
textureAutoMipMapGenerationAvailable = true
textureBoundaryWidthMax = 1
textureColorTableSize = 0
textureCombineDot3Available = true
textureCombineSubtractAvailable = true
textureCoordSetsMax = 8
textureCubeMapAvailable = true
textureDetailAvailable = false
textureEnvCombineAvailable = true
textureFilter4Available = false
textureImageUnitsCombinedMax = 32
textureImageUnitsMax = 32
textureImageUnitsVertexMax = 32
textureLodOffsetAvailable = false
textureLodRangeAvailable = true
textureNonPowerOfTwoAvailable = true
textureSharpenAvailable = false
vertexAttrsMax = 10

Thanks for all.
:D

aces
Offline
Joined: 2003-07-17

That's very strange.
Try JOGL pipeline. Make sure you have JOGL jars and DLLs on path.

Please report your findings.

miguelmu123
Offline
Joined: 2010-05-11

I read documentation about JOGL, JOGL is new API to create 3D Graphs, I must change my implementation on Java3D to JOGL, but if JOGL uses OpenGL JNI and load the Opengl.dll in the same way as Java3D rendered by openGL this solution posibly doesn't work.
I will try to do an easy example with JOGL to indentify if JOGL solves my problem

darwinjob
Offline
Joined: 2004-11-16

JOGL is not graph-based framework (like Java3D is), it is just a wrapper around OpenGL.

What exactly are you trying to visualize? Post a screenshot maybe?

aces
Offline
Joined: 2003-07-17

An explanation :

Java3D can use OpenGL, D3D and JOGL.

Just use -Dj3d.rend=jogl in cmd line to get Java3D using JOGL, but it requires you put JOGL jars and DLLs on path.

the default OpenGL renderer uses j3dcore-ogl.dll , while the jogl pipeline doesn't use Java3D's original dlls.