World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 04-23-2008, 09:19 PM   #1
Akhesa
Member
 
Join Date: Feb 2008
Posts: 32
Akhesa is on a distinguished road
Default Same code, not the same render on a different card (ATI vs NVidia)

Hi guys,

I'm using several computers with Intel, ATI and nVidia video cards, and my code does not render the same on the nVidia machines as it does on the other machines.

I'm writing a class that can render a cylinder at a given latitude / longitude / elevation, in order to draw cylinder stacks.

What I'm actually doing is computing the bissector vector between two axis:

1- The one between the center of the globe and the bottom of my cylinder
2- (0,0,1) (whatever it is with the current transformation matrix.)

Then I'm applying a 180° rotation around the new axis, so that (0,0,1) is the direction of the normal on the globe at my bottom point.

It works perfectly on both ATI and Intel video cards, but fails miserably on nVidia ones. I'm not saying that it's a nVidia bug, but it certainly doesn't help understand what's happening...

Here are two screenshots to understand the issue.

Here is the code of my render() method:

Code:
public void render(DrawContext dc)
       {
    		
           if (dc == null)
           {
               String msg = Logging.getMessage("nullValue.DrawContextIsNull");
               Logging.logger().severe(msg);
               throw new IllegalArgumentException(msg);
           }

           //Vec4 center = this.getCenter();
           //PolarPoint p = PolarPoint from

           javax.media.opengl.GL gl = dc.getGL();
           
           
           
           //TODO not each time
           //System.out.println("Light actived");
           gl.glEnable(GL.GL_LIGHTING);
           gl.glEnable(GL.GL_LIGHT0);
           gl.glEnable(GL.GL_COLOR_MATERIAL); 

          
//           gl.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_TRANSFORM_BIT);
           gl.glPushMatrix();
//            gl.glLoadIdentity();


           Vec4 point = new Vec4(this.bottomCenter.x, this.bottomCenter.y, this.bottomCenter.z);
           PolarPoint polarPoint = PolarPoint.fromCartesian(point);
//           System.out.println("X: " + this.bottomCenter.x + " Y: " + this.bottomCenter.y + " Z: " + this.bottomCenter.z);
           

//            Vec4 pointNormalized = point.normalize3();

           //Vec4 normal =
           dc.getGlobe().computeSurfaceNormalAtPoint(dc.getGlobe().computePointFromPosition(polarPoint.getLatitude(),polarPoint.getLongitude(), polarPoint.getRadius())).normalize3();
          
           
           Vec4 z = new Vec4(0,0,1000);
//           Vec4 axe = this.axisUnitDirection.add3(z);
           Vec4 axis = this.bottomCenter.add3(z).normalize3();
//
           
           gl.glRotated(180 ,axis.x, axis.y, axis.z);
           gl.glTranslated(0, 0, point.distanceTo3(new Vec4(0, 0, 0)));

           
           
           //Change the color
           gl.glColor3d(this.color[0],this.color[1],this.color[2]);
           
           
           glu.gluCylinder(quadratic, this.cylinderRadius , this.cylinderRadius, this.cylinderHeight, 32, 32);
           gl.glTranslated(0, 0, this.cylinderHeight);
           glu.gluDisk(quadratic, this.cylinderRadius, 0, 45, 5);

           //Change the color to White
           gl.glColor3d(255f, 255f, 255f);

           gl.glPopMatrix();
//           gl.glPopAttrib();
       }
Thanks in advance !
Attached Images
File Type: png NVidia-Card.PNG (525.2 KB, 116 views)
File Type: png ATI-Card.png (406.8 KB, 146 views)
Akhesa is offline   Reply With Quote
Old 04-23-2008, 09:24 PM   #2
remleduff
Senior Member
 
Join Date: Jun 2007
Posts: 218
remleduff is on a distinguished road
Default

You have glPushAttrib and glPopAttrib commented out, but you clearly need to save your enable state. (where you have pushAttrib commented out is too late by the way, it needs to be before all your calls to glEnable)

Until you get your state saving correct I think your results are going to be unpredictable (though I don't necessarily know if this is your bug or not).
remleduff is offline   Reply With Quote
Old 04-23-2008, 09:32 PM   #3
remleduff
Senior Member
 
Join Date: Jun 2007
Posts: 218
remleduff is on a distinguished road
Default

I think one bug is your call to glColor3d.

That call is expecting values between 0 to 1, not 0 to 255. So the result of that will be unpredictable on different video cards (though theoretically it should get clamped, I've seen weirdness there before).
remleduff is offline   Reply With Quote
Old 04-23-2008, 09:34 PM   #4
remleduff
Senior Member
 
Join Date: Jun 2007
Posts: 218
remleduff is on a distinguished road
Default

Ha, I should have looked at your screenshots before posting, I doubt the color has anything to do with your cylinders being offset from the globe.
remleduff is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# code to convert DD to UTM .. here it is !! Hactic Add-on & Script Development 31 08-15-2011 11:13 AM
Dependency injection instead of static singleton WorldWind stolsvik Feature Discussion 19 08-06-2007 02:57 PM
NVIDIA CARD Riva TNT2 (model 64) Unregistered Technical Support 2 05-05-2007 01:47 PM
Graphics card suitable? AlbrechtMehl Install Support 11 07-04-2006 03:02 PM


All times are GMT +1. The time now is 11:37 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.