dhdd
January 13, 2009, 9:27am
1
hey guys (and girls?).
as seen on this thread http://www.jmonkeyengine.com/jmeforum/index.php?topic=8692.0
nothing was done there so far i guess and since i stumbled upon the same bug, i applied the changes and created a patch.
I will of course ask the original author if he wants to commit
Index: src/com/jme/renderer/lwjgl/LWJGLRenderer.java
===================================================================
--- src/com/jme/renderer/lwjgl/LWJGLRenderer.java (revision 4087)
+++ src/com/jme/renderer/lwjgl/LWJGLRenderer.java (working copy)
@@ -552,7 +552,9 @@
matRecord.switchMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
- GLU.gluOrtho2D(0, width, 0, height);
+ float viewportWidth = width * (camera.getViewPortRight() - camera.getViewPortLeft());
+ float viewportHeight = height * (camera.getViewPortTop() - camera.getViewPortBottom());
+ GLU.gluOrtho2D(0, viewportWidth, 0, viewportHeight);
matRecord.switchMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
Index: src/com/jme/renderer/AbstractCamera.java
===================================================================
--- src/com/jme/renderer/AbstractCamera.java (revision 4087)
+++ src/com/jme/renderer/AbstractCamera.java (working copy)
@@ -1047,8 +1047,8 @@
tmp_quat.set( worldPosition.x, worldPosition.y, worldPosition.z, 1 );
modelViewProjection.mult( tmp_quat, tmp_quat );
tmp_quat.multLocal( 1.0f / tmp_quat.w );
- store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 + viewPortLeft ) * getWidth();
- store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 + viewPortBottom ) * getHeight();
+ store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 ) * getWidth();
+ store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 ) * getHeight();
store.z = ( tmp_quat.z + 1 ) / 2;
return store;
Andy
nymon
January 13, 2009, 6:51pm
2
Has the issue of the changes effect on the stats graph (and maybe other side effects) been addressed?
basixs
January 14, 2009, 12:32am
3
I believe that was one of the 'loose ends' left around by the old guys (XD), maybe its something that's important enough to get on the 2.0 list…
dhdd
January 14, 2009, 9:30am
4
nymon said:
Has the issue of the changes effect on the stats graph (and maybe other side effects) been addressed?
damn, i forgot that, I'll check as soon as i can and get back to you.
dhdd
January 24, 2009, 2:46pm
5
well, i tested the StatGraph with the TestCloth testcase and I cannot see any difference with the applied Patch I posted above.
Can someone confirm that?
basixs
January 24, 2009, 8:13pm
6
I get:
Parsing of patch file failed: Invalid unified diff range: @@ -552,7 +552,9 @@
Maybe you need to recreate the patch w/ the newest source...
dhdd
January 28, 2009, 2:55pm
7
so, heres the newly created patch. The root directory of the diff is the project root directory. I think thats ok?
Index: src/com/jme/renderer/lwjgl/LWJGLRenderer.java
===================================================================
--- src/com/jme/renderer/lwjgl/LWJGLRenderer.java (revision 4093)
+++ src/com/jme/renderer/lwjgl/LWJGLRenderer.java (working copy)
@@ -553,7 +553,9 @@
matRecord.switchMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
- GLU.gluOrtho2D(0, width, 0, height);
+ float viewportWidth = width * (camera.getViewPortRight() - camera.getViewPortLeft());
+ float viewportHeight = height * (camera.getViewPortTop() - camera.getViewPortBottom());
+ GLU.gluOrtho2D(0, viewportWidth, 0, viewportHeight);
matRecord.switchMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
Index: src/com/jme/renderer/AbstractCamera.java
===================================================================
--- src/com/jme/renderer/AbstractCamera.java (revision 4093)
+++ src/com/jme/renderer/AbstractCamera.java (working copy)
@@ -1047,8 +1047,8 @@
tmp_quat.set( worldPosition.x, worldPosition.y, worldPosition.z, 1 );
modelViewProjection.mult( tmp_quat, tmp_quat );
tmp_quat.multLocal( 1.0f / tmp_quat.w );
- store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 + viewPortLeft ) * getWidth();
- store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 + viewPortBottom ) * getHeight();
+ store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 ) * getWidth();
+ store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 ) * getHeight();
store.z = ( tmp_quat.z + 1 ) / 2;
return store;
can someone confirm (see last post)?
basixs
January 28, 2009, 5:35pm
8
Looks good here, although doesn't the JOGL renderer need the same changes?
(never could get patch to apply, same error; had to 'install' by hand…)
dhdd
January 29, 2009, 7:57am
9
i have no clue as to why the patch wouldn't work. In Eclipse there are thress possible patch root directories (Workspace, Project and Selection), whereas Selection should be the same as project when you selected the project
Here a new patch with the changes to the JOGLRenderer:
Index: src/com/jme/renderer/jogl/JOGLRenderer.java
===================================================================
--- src/com/jme/renderer/jogl/JOGLRenderer.java (revision 4093)
+++ src/com/jme/renderer/jogl/JOGLRenderer.java (working copy)
@@ -569,7 +569,9 @@
matRecord.switchMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
- glu.gluOrtho2D(0, width, 0, height);
+ float viewportWidth = width * (camera.getViewPortRight() - camera.getViewPortLeft());
+ float viewportHeight = height * (camera.getViewPortTop() - camera.getViewPortBottom());
+ glu.gluOrtho2D(0, viewportWidth, 0, viewportHeight);
matRecord.switchMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
Index: src/com/jme/renderer/lwjgl/LWJGLRenderer.java
===================================================================
--- src/com/jme/renderer/lwjgl/LWJGLRenderer.java (revision 4093)
+++ src/com/jme/renderer/lwjgl/LWJGLRenderer.java (working copy)
@@ -553,7 +553,9 @@
matRecord.switchMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
- GLU.gluOrtho2D(0, width, 0, height);
+ float viewportWidth = width * (camera.getViewPortRight() - camera.getViewPortLeft());
+ float viewportHeight = height * (camera.getViewPortTop() - camera.getViewPortBottom());
+ GLU.gluOrtho2D(0, viewportWidth, 0, viewportHeight);
matRecord.switchMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
Index: src/com/jme/renderer/AbstractCamera.java
===================================================================
--- src/com/jme/renderer/AbstractCamera.java (revision 4093)
+++ src/com/jme/renderer/AbstractCamera.java (working copy)
@@ -1047,8 +1047,8 @@
tmp_quat.set( worldPosition.x, worldPosition.y, worldPosition.z, 1 );
modelViewProjection.mult( tmp_quat, tmp_quat );
tmp_quat.multLocal( 1.0f / tmp_quat.w );
- store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 + viewPortLeft ) * getWidth();
- store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 + viewPortBottom ) * getHeight();
+ store.x = ( ( tmp_quat.x + 1 ) * ( viewPortRight - viewPortLeft ) / 2 ) * getWidth();
+ store.y = ( ( tmp_quat.y + 1 ) * ( viewPortTop - viewPortBottom ) / 2 ) * getHeight();
store.z = ( tmp_quat.z + 1 ) / 2;
return store;
Tested the JOGLRenderer with TestCloth. works.
basixs
January 29, 2009, 10:00am
10
I guess NB doesn't like Eclipse's patches (can't we all just get along hehe)
Changes look good here though. Tested JOGL and LWJGL with box color (ussed status ofc) as well as TestText…
dhdd
January 29, 2009, 11:04am
11
coolio
well, in case someone is working with two screens and rendering ORTHO stuff to them, he/she must have used workarounds for this bug in the past (doubling width). Commiting this bug will force them to remove their workarounds.
I will wait 2 days from now on and then commit.
so long,
Andy
dhdd said:
well, in case someone is working with two screens and rendering ORTHO stuff to them, he/she must have used workarounds for this bug in the past (doubling width).
Your assumption is correct, thanks for fixing :)
dhdd
February 9, 2009, 11:34am
13
the fix is in on the trunk, however not on the development branch. Shall I commit to the branch too?
basixs
February 9, 2009, 5:34pm
14
Give me just a minute and I will merge the 2 branches…
dhdd
February 10, 2009, 7:49am
15
thx basixs
EDIT: although the minutes is more than up and it seems its not merged yet?
basixs
February 10, 2009, 7:49pm
16
Sorry, I got sidetracked yesterday; merging now…