Re: Problem with code which works in compiled mode and fails in hosted mode

2010-07-07 Thread CarToro
Hi Alan,

I think I misled you with my answer. It turns out that the GWT-G3D had
a very similar problem, but not quite the same.

I started using the GWT-GL wrapper, and now I'm having the same
problem as you are!

For some reason, the method
glContext.getUniformLocation(shaderProgram, perspectiveMatrix);

expects an fails because, as you pointed it out, the OOPHM object
expects an int.

Sorry for the mess.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Problem with code which works in compiled mode and fails in hosted mode

2010-07-06 Thread CarToro
Hi Alan,

It looks like you haven't received many replies yet. I ran into the
same problem, but I managed to find a solution. Albeit not the most
elegant, it did allow me to carry on working.

OK, your problem is around here

 The actual lines of code are:
         float [] perspectiveMatrix = createPerspectiveMatrix(45, 1,
 0.1f, 1000);
         WebGLUniformLocation uniformLocation =
 glContext.getUniformLocation(shaderProgram, perspectiveMatrix);
         checkError();

         glContext.uniformMatrix4fv(uniformLocation, false,
 perspectiveMatrix);


Right?
There seem to be a problem with the binding and how it parses certain
arguments. So, for instance, in the case of the FlatShader or the
BasicShader3D, the issue with the matrices was solved here:

http://code.google.com/p/gwt-g3d/issues/detail?id=2can=1q=TBasicShader3D%20setModelViewMatrix%20causes%20JavaScript%20error

Basically, it needed to replace the following code:

public void setProjectionMatrix(Matrix4f value) {
gl.uniformMatrix(getUniformLocation(uProjectionMatrix), 
value);
}

with:
public void setProjectionMatrix(Matrix4f value) {
// gl.uniformMatrix(getUniformLocation(uProjectionMatrix), 
value);

float[] matrixValue = MatrixUtils.toFloatArray(value);
WebGLUniformLocation mvMatrixLoc =
getUniformLocation(uProjectionMatrix);
gl.uniformMatrix4fv(mvMatrixLoc, false,
WebGLFloatArray.createArray(matrixValue));
}

And similarly with the ModelView. As you can see, in your case the
perspectiveMatrix needs to be passed in as
WebGLFloatArray.createArray(perspectiveMatrix).

Hope this helps you, and let's hope the guys manage to get this fix
into their next release. I've been trying other WebGL wrappers for
GWT, but it does seem like these guys have gone further than anybody.
Funny thing though is that their examples do not work with Google's
chromium, but with Mozilla's minefield. Go figure.

Regards.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Problem with code which works in compiled mode and fails in hosted mode

2010-05-24 Thread Alan Chaney

Hi

I'm using the gwtgl library. There's one method invocation in it which 
throws an exception in hosted mode but seems to work OK in compiled 
mode. I suspect that the answer is obvious... Any suggestions would be 
greatly appreciated...




The actual lines of code are:
   float [] perspectiveMatrix = createPerspectiveMatrix(45, 1, 
0.1f, 1000);
   WebGLUniformLocation uniformLocation = 
glContext.getUniformLocation(shaderProgram, perspectiveMatrix);

   checkError();

   glContext.uniformMatrix4fv(uniformLocation, false, 
perspectiveMatrix);


and as I said, it works fine compiled and fails in hosted mode. If I 
stop the debugger at glContext.uniformMatrix4fv(  it gets there OK, 
but as soon as I step into it the debugger it fails at:


protected JsValue doInvoke(String name, Object jthis, Class?[] types,
 Object[] args) throws Throwable {
   TreeLogger branch = host.getLogger().branch(TreeLogger.SPAM,
   Invoke native method  + name, null);
   CompilingClassLoader isolatedClassLoader = getIsolatedClassLoader();
   JsValueOOPHM jsthis = new JsValueOOPHM();
   Class? jthisType = (jthis == null) ? Object.class : jthis.getClass();
   JsValueGlue.set(jsthis, isolatedClassLoader, jthisType, jthis);
   branch.log(TreeLogger.SPAM,   this= + jsthis);

   int argc = args.length;
   JsValueOOPHM argv[] = new JsValueOOPHM[argc];
   for (int i = 0; i  argc; ++i) {
 argv[i] = new JsValueOOPHM();
 JsValueGlue.set(argv[i], isolatedClassLoader, types[i], args[i]);
 branch.log(TreeLogger.SPAM,   arg[ + i + ]= + argv[i]);
   }
   JsValueOOPHM returnVal = new JsValueOOPHM();
   try {
 channel.invokeJavascript(isolatedClassLoader, jsthis, name, argv,
 returnVal);   --- EXCEPTION THROWN HERE
 branch.log(TreeLogger.SPAM,   returned  + returnVal);
   } catch (Throwable t) {
 branch.log(TreeLogger.SPAM, exception thrown, t);   --- 
Exception is invoke of 
@com.googlecode.gwtgl.binding.impl.WebGLMethodsBinding::uniformMatrix4fv(Lcom/googlecode/gwtgl/binding/WebGLUniformLocation;Z[F) 
failed

 throw t;
   }

Thanks

Alan

(exception trace is below)


17:11:06.785 [ERROR] [webgltest] Failed to create an instance of 
'com.google.gwt.core.client.impl.SchedulerImpl' via deferred binding
com.google.gwt.core.client.JavaScriptException: (String): invoke of 
@com.google.gwt.core.client.JavaScriptObject::createArray() failed
at 
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
at 
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at 
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at 
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at 
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at 
com.google.gwt.core.client.JavaScriptObject$.createArray(JavaScriptObject.java)
at 
com.google.gwt.core.client.impl.SchedulerImpl.init(SchedulerImpl.java:251)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown 
Source)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)
at 
com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:422)
at 
com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:39)

at com.google.gwt.core.client.GWT.create(GWT.java:98)
at 
com.google.gwt.core.client.impl.SchedulerImpl.clinit(SchedulerImpl.java:76)

at com.google.gwt.core.client.impl.Impl.exit(Impl.java:207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:374)
at 
com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at 
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at 
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)

at java.lang.Thread.run(Unknown Source)


--
You received this message because you are subscribed to the Google Groups Google 
Web Toolkit group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.