PDA

View Full Version : WEBGL with C++ or java



stylequick
01-12-2011, 03:40 PM
Hi everyone,
I like the concept of WebGL and I would like to develop some 3d projects with it.
However, It seems to me that using Javascript for 3d games online is just impossible.
Javascript is very very slow compared with C++.
I can't imagine making matrix calculations with Javascript , this is complety insane. :lol:
So, I'm asking you if there is a way to write everything in C++ or Java and then change it to Javascript with a software or an API.

SteveBaker
01-12-2011, 08:39 PM
Well, there is a project called "enscriptem" - which converts the output of the GNU compiler suite into obfuscated JavaScript. In essence, it treats JS as a "machine code" for the web.

With that program, you can program in C++ (or almost any other high level language that GNU's compiler suite supports!) and run your programs in a browser.

However, that's not going to be much faster (and quite possibly, slower) than running JavaScript. Some would argue that being able to work in C++ is enough of a win over raw JS to make it worthwhile!

However, aside from that, it's not likely we'll be able to run C++ from a website in a browser simply because the security risks are too high.

toompaxy
02-02-2012, 12:39 AM
Java cautions about clearing Java cache but why and can doing so potentially speed up my Java? I use real time streaming information spreadsheets which are Java driven. Lately they take minutes instead of seconds to load. After the program is up and running, information updates slowly. Clearing the cache has been suggested to me but Java warns against inexperienced users doing so. Why? And exactly what advanced knowledge am I lacking?

lthornblad
02-02-2012, 05:34 PM
OP: Since the end result MUST run in JavaScript, your starting point won't make any difference in speed once it is converted.

The only exception that I'm aware of is Google's Native Client, which allows you to run C++ in a browser. However, Chrome is the only browser that will support it and I'm not sure if you can use it in conjunction with WebGL. I would not be surprised if this approach takes off in a year or two.

lfyos
05-23-2012, 07:41 AM
In my opinion, WebGL application should divided in two part: one is implemented in browser(chrome, firefox, opera, .etc), this part just do display(using webgl) and get input from mouse and keyboard; the other is scene management implemented in web server,it can be developed by java. comparing with javascript, java has no performance penalty?

When using webgl, first you should save mesh data into buffer object, image data into texture object, these object is acturally stored in display cards(GPU). when render, you need only set some openGL state, set uniform variable value, then issue webgl drawing command. the performance cost by javascript is not so high as you imagine.