Applet-Mode Working Sporadically

Hello, I’m working on a game that I hope to release over the web. Actually shooting for a facebook launch, so being able to go in a browser is imperative.



We also don’t want to limit the game to just newer computers, and I know JME isn’t targeted towards dinosaur-like computers, but I still thought I’d share the results of my market research and ask for any guidance that can be provided.



Anyway I have been experimenting with and without my GPU installed in my computer. With it, everything works fine, without it many things can still work fine, but strangely enough the same thing that works when run from the SDK or the EXE or JAR wont run in the applet. I also tested to make sure the applet works for other people, so I know that isn’t the issue.



Right now what I am testing is essentially the TestNormalMapping demo, though I was having trouble with the pond material, so I replaced it with a standard white sphere instead.



Here is the applet: http://spacefighter.kicks-ass.org/



My system information, as well as other people I’ve been testing, can be seen at

http://spacefighter.kicks-ass.org/TestResults.txt

My computer’s imbedded chipset doesn’t have GLSL access, but as I said I can run the program in several different ways, just not the applet. Also it seems that opening a window should not be dependent on GLSL, so I am not sure why they are linked in the LWJGL UnsupportedOperationException (see exception from the applet below)



For me it is currently giving a white screen.

Interestingly enough, I don’t need to have opengl1 mode enabled in the app settings to run the program, but the applet won’t work with opengl1 mode or without it.





Using the java console I acquired this information on the exception:

SEVERE: Failed to create display

java.lang.UnsupportedOperationException: GLSL and OpenGL2 is required for the LWJGL renderer!

at com.jme3.renderer.lwjgl.LwjglRenderer.initialize(LwjglRenderer.java:166)

at com.jme3.system.lwjgl.LwjglContext.initContextFirstTime(LwjglContext.java:131)

at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:474)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

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

Mar 31, 2012 2:25:47 PM com.jme3.system.lwjgl.LwjglCanvas runLoop

INFO: OGL: Creating display …

Mar 31, 2012 2:25:47 PM com.jme3.system.lwjgl.LwjglCanvas restoreCanvas

INFO: OGL: Waiting for canvas to become displayable…

Mar 31, 2012 2:25:47 PM com.jme3.system.lwjgl.LwjglCanvas restoreCanvas

INFO: OGL: Creating display context …

Exception in thread “LWJGL Renderer Thread” java.lang.UnsupportedOperationException: GLSL and OpenGL2 is required for the LWJGL renderer!

at com.jme3.renderer.lwjgl.LwjglRenderer.initialize(LwjglRenderer.java:166)

at com.jme3.system.lwjgl.LwjglContext.initContextFirstTime(LwjglContext.java:131)

at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:474)

at com.jme3.system.lwjgl.LwjglCanvas.restoreCanvas(LwjglCanvas.java:265)

at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:194)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

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

My colleague in this work has mentioned to me that I am not actually asking a question in my post.



Can I get this to work, and if so, how?

Yeah, the applet doesn’t use the AppSettings of the main application. @Momoko_Fan: Tell us, how can one enable OpenGL1 mode for applets?

You need to use the “AppSettingsURL” applet property. You specify a url of a config file that will be loaded with the settings. You can export such file by creating an AppSettings and then exporting it into an OutputStream that is a file.

oO well you heard the man @valentiinro

I was running the program without using OpenGl1 mode in the first place, and it worked.

Maybe switching to OpenGl1 mode will make the applet work, but it as I said, it worked without it in the exe and jar modes.



So this AppSettingsUrl… Would this go in the run-applet.html file under attributes or parameters or something?

@valentiinro said:
I was running the program without using OpenGl1 mode in the first place, and it worked.
Maybe switching to OpenGl1 mode will make the applet work, but it as I said, it worked without it in the exe and jar modes.

So this AppSettingsUrl... Would this go in the run-applet.html file under attributes or parameters or something?

Its an applet property
@Momoko_Fan said:
Its an applet property


I don't understand where to access these properties as I did not create the applet, it was made by the SDK via the checkbox.

I'm nosing around in the /dist/applet folder looking for anything relevant, and I don't see anything. Even looking through the code.jar and data.jar and I'm not seeing anything relevant.

Sorry I meant Applet parameter.

If you viewed the generated HTML file you would understand what I meant.



Pretty much you have to make a .cfg file with this content

“Renderer(string)=LWJGL-OpenGL1”

OR

“Renderer(string)=LWJGL-OpenGL-Any”

depending on if you want to always choose OpenGL1 or dynamically choose OpenGL version based on capabilities.



You put this on your server and then you add a parameter to the applet like

[xml]<applet …>

<param name=“AppSettingsURL” value=“http://blahblah.com/applet.cfg”/ >

</applet>[/xml]

@Momoko_Fan said:
Sorry I meant Applet parameter.
If you viewed the generated HTML file you would understand what I meant.

Pretty much you have to make a .cfg file with this content
"Renderer(string)=LWJGL-OpenGL1"
OR
"Renderer(string)=LWJGL-OpenGL-Any"
depending on if you want to always choose OpenGL1 or dynamically choose OpenGL version based on capabilities.

You put this on your server and then you add a parameter to the applet like
[xml]<applet ...>
<param name="AppSettingsURL" value="http://blahblah.com/applet.cfg"/ >
</applet>[/xml]


Here's the code for the run-applet.html file generated by the SDK
[xml]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Launcher Page for MyGame Applet</title>
</head>
<body>

<div align="center">
<h2>Launcher Page for MyGame Applet</title>
<br/>

<!-- ***************************************************** -->
<!-- Copy this section into your website to use the applet -->
<!-- ***************************************************** -->
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {code:'org.lwjgl.util.applet.AppletLoader',
archive:'lwjgl_util_applet.jar, lzma.jar',
codebase:'.',
width:640, height:480};
var parameters =
{
AppClass:'mygame.Main',
al_title:'MyGame',
al_main:'com.jme3.app.AppletHarness',
al_logo:'',
al_progressbar:'appletprogress.gif',
al_jars:'code.jar, data.jar, lwjgl.jar.pack.lzma',
al_windows:'windows_natives.jar.lzma',
al_linux:'linux_natives.jar.lzma',
al_mac:'macosx_natives.jar.lzma',
al_solaris:'solaris_natives.jar.lzma',
separate_jvm:'true',
boxborder:'false',
centerimage:'true',
image:'',
java_arguments:'-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false'
};
var version = '1.5' ;
deployJava.runApplet(attributes, parameters, version);
</script>
<!-- ***************************************************** -->
<!-- ***************************************************** -->

</div>

</body>
</html>
[/xml]

Would I put something under parameters to make it looks like so:
var parameters =
{
AppClass:'mygame.Main',
al_title:'MyGame',
al_main:'com.jme3.app.AppletHarness',
al_logo:'',
AppSettingsURL:'location/Applet.cfg'
Other Parameters
}

Would that do the trick? What you were describing doesn't seem to exist in the SDK-produced html file to run the applet, as it runs it with some javascript instead of the standard tag format.

Also, if dynamically selecting OpenGL version based on capabilities, is that a feature that already exists or would I be making a system to do that in my code somewhere?

I'm sorry I keep having questions but it seems the features I keep being interested in are the ones least documented. Go figure :S
Thanks for your help though!

When trying it, I am getting “no protocol: Applet.cfg”

in the java console.

The file’s contents are



Renderer(string)=LWJGL-OpenGL1



The file is located just about everywhere, because I wasn’t exactly sure where to put it.



Here’s the line in the applet parameters int un-applet.html where I call it:

AppSettingsURL:‘Applet.cfg’,

If you use the LWJGL-OpenGL-Any you don’t need to implement anything, its handled automatically.

Sorry that this particular parameter is undocumented, perhaps we need to improve our applet deployment documentation.

Regarding the error you’re getting, you need to specify the full URL, relative URLs won’t work. E.g. http://blahblah.com/place/applet.cfg

Now I’m getting



SEVERE: Failed to create display

java.lang.UnsupportedOperationException: Unsupported renderer: LWJGL-OpenGL1

at com.jme3.system.lwjgl.LwjglContext.initContextFirstTime(LwjglContext.java:126)

at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:474)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

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

Apr 4, 2012 4:16:37 PM com.jme3.system.lwjgl.LwjglCanvas runLoop

INFO: OGL: Creating display …

Apr 4, 2012 4:16:37 PM com.jme3.system.lwjgl.LwjglCanvas restoreCanvas

INFO: OGL: Waiting for canvas to become displayable…

Apr 4, 2012 4:16:37 PM com.jme3.system.lwjgl.LwjglCanvas restoreCanvas

INFO: OGL: Creating display context …

Exception in thread “LWJGL Renderer Thread” java.lang.NullPointerException

at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:464)

at com.jme3.system.lwjgl.LwjglCanvas.restoreCanvas(LwjglCanvas.java:265)

at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:194)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

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



Or, alternatively when I switch to OpenGL-Any



java.lang.UnsupportedOperationException: Unsupported renderer: LWJGL-OpenGL-ANY

at com.jme3.system.lwjgl.LwjglContext.initContextFirstTime(LwjglContext.java:126)

at com.jme3.system.lwjgl.LwjglCanvas.createContext(LwjglCanvas.java:474)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

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

Apparently its case sensitive… You have to use “LWJGL-OPENGL1”

You can find the proper constants in the AppSettings class:

http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/system/AppSettings.java

Oh crap it actually worked! Woo hoo!



Wow these strings are a bit funky.

To use OpenGL1 mode you need “LWJGL-OPENGL1”

To use OpenGL2 mode you need “LWJGL-OpenGL2”

To use OpenGL3 mode you need “LWJGL-OpenGL3”

To use OpenGL-ANY mode you need “LWJGL-OpenGL-Any” With an uppercase A and lower case n and y



What’s the policy on changing things like this for consistency?

I’ve been snooping around and there’s a few other features like this that either don’t work and are badly named.

I guess what one does when changing things like this is make the inconsistent ones deprecated and add the same functionality to some new ones that are all consistent.



Alternatively wherever one uses these strings one could include a compareToIgnoreCase(String str) to the string input.



I know JME is open source, but if I wanted to change the line where they compare strings and use compareToIgnoreCase(String str) instead could I just commit the change or whatever?



Actually I should probably look up faqs on contributing before asking questions like that.



Anyway, thanks a lot for your help, I am now not worried about distribution problems! Pending a retest of some of the people’s computers who couldn’t get it to run of course…