OGRE port to NaCl (Google's Native Client)

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

Last updated 2 April 2013.

This thread is going to be about OGRE port to Google's native platform.
The Native Client module executed in this page draws Ogre Sample Browser.
The Native Client module executed in this page draws Ogre Sample Browser.
Open the page in the screenshot
Or the same page as a Chrome Web Store App

Google native platform – NaCl – it a new and exciting way to share software on the web.
The idea is to compile c and c++ and in a special way, a protected way, a cross platform way.
Google released an SDK for NaCl that includes a compiler, "c run time" h files and libraries –in a form that is similar to Linux gcc and its accompanied files, so compiling existing project that already compile for Linux is not that hard.
What makes the NaCl's compiler special is that the resulted "exe" can be run in a "sandbox" on multiple platforms as a browser plug-in. Think about is as an ActiveX but one that is platform independent and safe from hackers.
In simple terms - the idea behind the "sandbox" is a new concept that NaCl introduced – when the compilers compile the c++ code to native code (assembly) – it adds extra assembly instruction before any memory access assembly command to check that the target memory valid – meaning data memory and not the part of the memory that holds the program commands, same goes for goto commands – they will never go to the data memory. Meaning hackers can use buffer overruns.
Regular file access API is disabled and NaCl provides its own class to access files – this stops any possibility for system files hacks.
Assembly commands in c++ (__asm__) are not allowed.
To preserve platform portability and security – you can't access any platform specific API – like windows API and such.

The bottom line – you can compile c and c++ code to run in the browser that have the same system access as javascript code.

The advantages of NaCl over javascript are that native assembly code will always run faster then javascript and you can reuse existing code that you wrote for game in c++ to run safely in the browser.

The biggest disadvantage that NaCl currently has is that it doesn't have a debugger, more over – if you do bad things like using an uninitialized pointer – it exists without any message, call stuck or any way for you to know WHERE the error is.

One other disadvantage is that it wasn't released even in Chrome, and none of the other browsers intend to support it for now, but who cares, the idea of having a safe and cross-platformed browser plug-in written in c++ is a good idea.

Sinbad and I tweeted lots of tweets that from the alternatives (flash, javascript's WebGL, Silverlight and such) – NaCl is the best option.

Last week when Google announced that they want to include NaCl in their next release of Chrome I decided to port OGRE to NaCl.
The main reason was just to check out how good is NaCl, can it run my favorite pet, an ogre.
The secondary reason was that I searched the web for any other 3d open source project that ported its code to NaCl and couldn't find one.
Moreover – I didn't find any webpage, blog post and such that shows off even a simple NaCl OpenGL cube. Later when I was deep in I did found a reference and a "how to compile and run" of a basic OpenGL sample that runs on NaCl – but not even a single webpage you can just open and see some 3d rendering using NaCl.

The first thing I wanted to do is to compile the OGRE dependencies, Google ported most of them in a project called NaClPorts (http://code.google.com/p/naclports/).
My biggest issue here was that Google does provides all the SDK tools like the compile and link program and such as win32 exes that can run without Cygwin, but for the projects they converted for NaCl you have to use Cygwin and a complex system that downloads zip files, patch them then compile using make.

This was very complicated for me. I use visual studio as my main IDE, I love it, used to it, I love windows, I wanted to use visual studio, I hate complex hand written scripts to compile a few files. I like to open files in the IDE, edit them, compile, re-compile until no error. I don't like writing command lines and searching for files in the directory tree. The thing that bugs me must is that I have visual studio projects for OGRE and all of its dependencies, so why not compile the same project to a new platform using visual studio. Well, visual studio doesn't support compiling for NaCl, so you can't, Google worked on a project that should have added NaCl as a new target to visual studio but dropped it in the end of 2010. So I am stuck. But am I? After thinking about it and testing a few tests I decided that is too complicated to change the visual studio projects by hand.

I decided to write a tool that converts an existing visual studio project that compiles for windows to a new project with the same files, includes, defines and such – but one that compiles for NaCl.

I based the tool on an open source project called vspc that converts visual studio projects between versions, in a way is resembles what I wanted to do.
I changed the tool that the result project will contain the same files but for all the source file instead of compiling using Microsoft compiler will be considered a "Custom Build Tool" with a command line to compile using the NaCl compiler.
I had to translate all the defines and includes to be in the command line, find the right parameters and such, but it wasn't that hard, and the result saved me lots of time later on because I could use visual studio and translate existing projects that I already have.

Basically what I needed to do next was to compile and link the visual studio projects until there were no error – then start to debug the OGRE plug-in in Chrome.

Compiling the dependencies was not that hard after I wrote the solution convertor. I learned how to compile using the NaCl SDK tools by seeing the command prompt commands when I compiled the samples that comes with the SDK, there was no samples how to create static libs (.a extension) – but I searched Google and the process is the same as in linux (you use a special program called ar that merge .o file in to .a files). Also there is a naming convention that you need to prefix the static library name with "lib".
To link everything into an exe (.nexe extension) you use gcc, one thing I notices is that when you link an exe – the NaCl nexe function that is like the "main" function in normal programs called "CreateModule" must be linked in an o. file (and not in a static library .a file), easy to sort out because 99% of the time you don't have the main function in a library. In OGRE sample browser this is not an issue.
Getting OGRE to compile wasn't that hard, most of the work was to add the NaCl specific code to OpenGL ES 2 render system and to adapt the init process for NaCl.
I based my init code on the sample from the NaCl SDK.
When I started to debug the plug-in in the browser it was hard, the plug-in failed to load, NaCl plugins can't be debugged – so I needed to add lots of

Code: Select all

return NULL; //ASSAF HACK
lines. 20 hours of work later I got OGRE to render. I noticed that the resizing code doesn't work, both in my code and also in the sample code from the NaCl source control (the cube thing). I was able to work it out myself and the sample browser now resizes correctly when you zoom the page in and out.

With the input I first took a direction of using SDL that is already ported to NaCl and using it to feed the input to OIS (it has SDL support). But SDL crashed when I tried to init it, and also I didn't what to add a new dependency, so I wrote the needed code to add NaCl support to OIS. The hard part here was translating the key codes one by one from the javascript convention (used by NaCl) to the windows convention(used by OIS).

File access was more work then I expected, NaCl file and download API just didn't work correctly and it took me ages to find the right order of commands. I wrote once code that embed a zip file into an exe – but I don't think that this will be an option in real applications – and I wanted to demonstrate a real application – so I worked more and got it to work. I download the files and save them to the browser cache to save time the second time you open the page with the NaCl exe.


Here is the result of all my work – a webpage that shows off the OGRE sample browser.

All the OGRE code I wrote for this is checked in to OGRE's trunk.

Running the sample browser with Google Chrome beta isn't simple; you have to add flags, environment variables and such. Moreover - Google Chrome warns you if you have nexe files that they are risky and recommend you to delete them! Renaming the extension to anything without the substring "exe" solves the issue and the NaCl plug-in still works.

Google people that are reading this long post, if you got to this part you care about NaCl, and if that is true, mark my word - you need to make thing easier!

I have posted the link in twitter and it seems to work on most windows machines. I did found out about some issues:
A 32bit XP computer gets a blue screen every time you start the second sample.
A 32bit win7 computer doesn’t start the nexe with a "bad ELF file" message.
A 32bit OSX mac doesn't load the nexe without any reason or error.
The download sometimes doesn't work without any reason.
The progress callback from the nexe download only return in 0% and 100%, that is not so good when the nexe file size is 20MB. I think I can workaround this by downloading the file in javascript – with progress, then using it and it will be in the cache.
Here are some open issues I still have:
I need to output the resource files download progress.
The mouse wheel doesn't work – seems something easy to fix.
I want to write a new OGRE Archive to download files using the NaCl API, that also check hash codes, basically something that will allow you to only download the used files on the fly – to reduce loading time.
A big issue – unlike OpenGL – NaCl version on OpenGL ES 2 can have "lost device" issues, if the screen saver is up, the computer goes to sleep or you lock the screen – you lose your context and need to recreate the window and all of the resource similar to what happens in DirectX 9 on XP. Seems like hard work, moreover I don’t see how I can support render to texture results and such.

I will be happy for any help with this port. Feel free to contact me and offer it.

I guess that some of you will want to compile OGRE for NaCl.

For nun-linux people – I was able to compile OGRE using cmake with gcc output by changing the cmake parameters releated to gcc to use NaCl tools (they are the same names as in gcc but with "NaCl_" prefix). You will also need to mix in the dependencies compile, but if you are a Linux person - I guess you know what to do. Try to get it working on your own for now, I don't think I will get to it in the near future. I will be happy for any related patches.

For windows people – follow the following steps:
1. Download the NaCl SDK and install it.
2. Set an environment variable called NACL_SDK_ROOT that directs to the NaCl SDK dir. (ex: c:\nacl_sdk\pepper_20)
3. Download this dependencies zip and unzip it.
4. Get OGRE trunk.
5. CMake a solution for VS 2010
Use the dependencies from step 1 as the dependencies folder.
OGRE_BUILD_PLATFORM_NACL = true
OGRE_STATIC = true
OGRE_BUILD_TOOLS = false
OGRE_CONFIG_THREADS = 0
OGRE_BUILD_RENDERSYSTEM_D3D11 = false
OGRE_BUILD_RENDERSYSTEM_D3D9 = false
OGRE_BUILD_RENDERSYSTEM_GL = false
OGRE_BUILD_RENDERSYSTEM_GLES2 = true
OGRE_CONFIG_ALLOCATOR = 1 (check the CMake advanced checkbox to see this option.)
OGRE_USE_BOOST = false

meaning static build, no DX and GL render system, yes GLES2 render system, no boost, thread config 0, no tools.

6. Download my solution convertor tool and use it on the Ogre.sln solution you created in stage 5 and the dependencies sln.
7. Open the OgreDependencies_NaCl.sln (make sure you created it in stage 6) with visual studio (it is in the "src" the folder in the dependencies folder you unzipped in step 3), compile it for both 32 and 64 platforms, Copy the created .a file from the dependencies folder "src\out " to a sub folder named "out" under your new solution folder. If you have issues opening up the visual studio solution - this may be your issue.
8. Open the Ogre_nacl.sln that will be created next to the Ogre.sln.
9. Find the project SampleBrowser, find the item "Link NaCl", right click, properties, custom build tool, select "All platforms" from the "platform" combo box at the top of the window, "command line" line (top one in custom build), select it, click on the combo box button, <edit…>, an edit window opens, go to the end of the line of the last line in the edit window for the command line and paste the following text to be the end of the line instead of the "-lppapi -lppapi_cpp -lnosys" at the end there (BTW: there should be a space before the "-L$(SolutionDir)out"):

Code: Select all

"-L$(SolutionDir)out" -lOgreTerrain_x86_$(PlatformArchitecture)  -lSample_BezierPatch_x86_$(PlatformArchitecture) -lSample_BSP_x86_$(PlatformArchitecture) -lSample_CameraTrack_x86_$(PlatformArchitecture) -lSample_CelShading_x86_$(PlatformArchitecture) -lSample_Character_x86_$(PlatformArchitecture) -lSample_Compositor_x86_$(PlatformArchitecture) -lSample_CubeMapping_x86_$(PlatformArchitecture) -lSample_DeferredShading_x86_$(PlatformArchitecture) -lSample_Dot3Bump_x86_$(PlatformArchitecture) -lSample_DynTex_x86_$(PlatformArchitecture) -lSample_FacialAnimation_x86_$(PlatformArchitecture) -lSample_Fresnel_x86_$(PlatformArchitecture) -lSample_Grass_x86_$(PlatformArchitecture) -lSample_Instancing_x86_$(PlatformArchitecture) -lSample_Isosurf_x86_$(PlatformArchitecture) -lSample_Lighting_x86_$(PlatformArchitecture) -lSample_NewInstancing_x86_$(PlatformArchitecture) -lSample_Ocean_x86_$(PlatformArchitecture) -lSample_ParticleFX_x86_$(PlatformArchitecture) -lSample_ParticleGS_x86_$(PlatformArchitecture) -lSample_ShaderSystem_x86_$(PlatformArchitecture) -lSample_Shadows_x86_$(PlatformArchitecture) -lSample_SkeletalAnimation_x86_$(PlatformArchitecture) -lSample_SkyBox_x86_$(PlatformArchitecture) -lSample_SkyDome_x86_$(PlatformArchitecture) -lSample_SkyPlane_x86_$(PlatformArchitecture) -lSample_Smoke_x86_$(PlatformArchitecture) -lSample_SphereMapping_x86_$(PlatformArchitecture) -lSample_Terrain_x86_$(PlatformArchitecture) -lSample_TextureArray_x86_$(PlatformArchitecture) -lSample_TextureFX_x86_$(PlatformArchitecture) -lSample_Transparency_x86_$(PlatformArchitecture) -lSample_VolumeTex_x86_$(PlatformArchitecture) -lSample_Water_x86_$(PlatformArchitecture) -lSample_EndlessWorld_x86_$(PlatformArchitecture) -lSample_VolumeCSG_x86_$(PlatformArchitecture) -lSample_VolumeCSG_x86_$(PlatformArchitecture) -lOgrePaging_x86_$(PlatformArchitecture)  -lPlugin_BSPSceneManager_x86_$(PlatformArchitecture) -lPlugin_OctreeSceneManager_x86_$(PlatformArchitecture) -lPlugin_OctreeZone_x86_$(PlatformArchitecture) -lPlugin_ParticleFX_x86_$(PlatformArchitecture) -lPlugin_PCZSceneManager_x86_$(PlatformArchitecture) -lOgreRTShaderSystem_x86_$(PlatformArchitecture) -lRenderSystem_GLES2_x86_$(PlatformArchitecture) -lOgreOverlay_x86_$(PlatformArchitecture) -lOgreMain_x86_$(PlatformArchitecture) -lfreetype_NaCl_x86_$(PlatformArchitecture) -lOIS_NaCl_x86_$(PlatformArchitecture)  -lzziplib_NaCl_x86_$(PlatformArchitecture) -lFreeImageLib_x86_$(PlatformArchitecture) -lOpenEXR_x86_$(PlatformArchitecture) -lLibJPEG_x86_$(PlatformArchitecture) -lLibMNG_x86_$(PlatformArchitecture) -lLibOpenJPEG_x86_$(PlatformArchitecture) -lLibPNG_x86_$(PlatformArchitecture) -lLibRawLite_x86_$(PlatformArchitecture) -lLibTIFF_x86_$(PlatformArchitecture) -lZLib-FreeImage_x86_$(PlatformArchitecture)  -lppapi_gles2 -ldl -lppapi -lppapi_cpp -lnosys
10. Remove the following projects from the solution: ALL_BUILD, INSTALL, PACKAGE.
11. Build the solution for both "Win32" and "x64" platforms. (meaning two solution builds…)
12. Copy the nexe files that were created in the "out" directory that is under the folder the solution exist in – into a directory with this template (use SVN to get it). Override the existing files that you see there.
13. You need to create an SampleBrowser.nmf file (Sorry, this is Google's idea and not me...) http://www.chromium.org/nativeclient/de ... -for-glibc
After creating the SampleBrowser.nmf file - override the one in the folder from stage 12.
To create an nmf file first run something like this:

Code: Select all

%NACL_SDK_ROOT%\toolchain\win_x86_glibc\bin\x86_64-nacl-objdump -p SampleBrowser_x86_64.nexe
Then look look for the lines that start with: "NEEDED" and create the nmf file.
For example, I got this output when running x86_64-nacl-objdump:

Code: Select all

  .....
  NEEDED               libppapi_gles2.so
  NEEDED               libdl.so.11652996
  NEEDED               libpthread.so.11652996
  NEEDED               libppapi_cpp.so
  NEEDED               libstdc++.so.6
  NEEDED               libm.so.11652996
  NEEDED               libgcc_s.so.1
  NEEDED               libc.so.11652996
....
And I create from it the following nmf file that worked:

Code: Select all

{ "program": {
   "x86-64": {"url": "lib64/runnable-ld.so"},
   "x86-32": {"url": "lib32/runnable-ld.so"}
 },
 "files": {
   "libpthread.so.11652996" : {
     "x86-64": {"url": "lib64/libpthread.so.11652996"},
     "x86-32": {"url": "lib32/libpthread.so.11652996"}
   },
   "libppapi_gles2.so" : {
     "x86-64": {"url": "lib64/libppapi_gles2.so"},
     "x86-32": {"url": "lib32/libppapi_gles2.so"}
   },
   "libdl.so.11652996" : {
     "x86-64": {"url": "lib64/libdl.so.11652996"},
     "x86-32": {"url": "lib32/libdl.so.11652996"}
   },
   "libpthread.so.11652996" : {
     "x86-64": {"url": "lib64/libpthread.so.11652996"},
     "x86-32": {"url": "lib32/libpthread.so.11652996"}
   },
   "libppapi_cpp.so" : {
     "x86-64": {"url": "lib64/libppapi_cpp.so"},
     "x86-32": {"url": "lib32/libppapi_cpp.so"}
   },
   "libstdc++.so.6" : {
     "x86-64": {"url": "lib64/libstdc++.so.6"},
     "x86-32": {"url": "lib32/libstdc++.so.6"}
   },
   "libm.so.11652996" : {
     "x86-64": {"url": "lib64/libm.so.11652996"},
     "x86-32": {"url": "lib32/libm.so.11652996"}
   },
   "libgcc_s.so.1" : {
     "x86-64": {"url": "lib64/libgcc_s.so.1"},
     "x86-32": {"url": "lib32/libgcc_s.so.1"}
   },
   "libc.so.11652996" : {
     "x86-64": {"url": "lib64/libc.so.11652996"},
     "x86-32": {"url": "lib32/libc.so.11652996"}
   },
   "main.nexe" : {
     "x86-64": {"url": "SampleBrowser_x86_64.nexe"},
     "x86-32": {"url": "SampleBrowser_x86_32.nexe"}
   }
 }
}
Probebly you can use my file - just replace 11652996 with the id you got using objdump.
You will also need to copy later all the content of %NACL_SDK_ROOT%\toolchain\win_x86_glibc\x86_64-nacl\lib to a sub folder named lib64 in the folder from stage 12.
need to copy later all the content of %NACL_SDK_ROOT%\toolchain\win_x86_glibc\x86_64-nacl\lib32 to a sub folder named lib32 in the folder from stage 12.
This is an annoying stage that Google added, sorry about it...
14. Upload to a web server or use the local web server that comes with the NaCl SDK to test the sample out. Note – NaCl doesn't work from a local folder – you have to access a NaCl page with HTTP protocol for it to work – meaning TCP, meaning a web server of some sort.

A few pointers:
1. You can save time by only compiling to the platform you are using (32 or 64).
2. Use the javascript console to view OGRE log.
3. If you re-generate the solution with cmake – make sure to make the changes in the list above – from stage 9.
4. If NaCl doesn't work on a computer – try out the basic OpenGL NaCl that comes with NaCl SDK and see if you see the cube there.
5. If you have issues opening the converted visual studio solution - this may be your issue.

This is about it, lots of work, hopes it will turn into something good. :?

Feel free to comment.
Watch out for my OGRE related tweets here.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by jacmoe »

1 kudos is simply not enough. :D

This is really, really, really awesome. (:hammer_time_icon:)

What a lot of work already... :)

It would probably be easier on Linux - I guess I need to read up on it.

<edit>
20 FPS on my machine - not bad, actually.
</edit>
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by Wolfmanfx »

Nice work! You should try to showcase that on the chrome dev blog. Regarding debugging did you tried wingdb?
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

@Wolfmanfx: I didn't, from what I read here:
Use of a debugger isn't yet supported in Native Client, though you may be able to debug Native Client modules with some alternative approaches. We're actively working on providing integrated debugging support. For further developments, keep an eye on the native-client-announce mailing list.
Watch out for my OGRE related tweets here.
User avatar
typist
Kobold
Posts: 36
Joined: Mon Apr 02, 2007 3:48 am
Location: Toronto, Canada

Re: OGRE port to NaCl (Google's Native Client)

Post by typist »

Awesome work and thanks for the heads up on NaCl, I had not heard about NaCl before, so your tweet intrigued me enough to find out more... and it looks very promising. One thing is for sure, OGRE developers are certainly up-to-date on the latest trends in game development! :)
User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel
x 32

Re: OGRE port to NaCl (Google's Native Client)

Post by Mattan Furst »

I checked it on chrome as you asked. It doesn't seem to work :(

It prints the lines:
progress: Computing... (0 of 0 bytes)
progress: 100% (19986850 of 19986850 bytes)
NaCl exe loading ended
lastError: NaCl module load failed: Insufficient memory to load file
I guess you will have to wait until it's less of a beta
it's turtles all the way down
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by jacmoe »

Don't forget to turn on that native stuff in the special Chrome settings page (can't remember exactly where and what, but you need to enable something and restart the beast) - maybe that's what's preventing you from having fun with it? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

@Mattan - I tested with the Ogre_ubuntu-10.10 virtual box - and got the same issue.
I guess NaCl is not supported on Ubuntu for now - until Google will fix this bug.
Watch out for my OGRE related tweets here.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by jacmoe »

This is Debian Sid, so it works on *nix - just so you know. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5292
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by dark_sylinc »

This is all cool stuff (I'm not really into this, but sounds cool).

I have a few fun comments to make:
Assaf Raman wrote:In simple terms - the idea behind the "sandbox" is a new concept that NaCl introduced – when the compilers compile the c++ code to native code (assembly) – it adds extra assembly instruction before any memory access assembly command to check that the target memory valid – meaning data memory and not the part of the memory that holds the program commands, same goes for goto commands – they will never go to the data memory. Meaning hackers can use buffer overruns.
Regular file access API is disabled and NaCl provides its own class to access files – this stops any possibility for system files hacks.
Assembly commands in c++ (__asm__) are not allowed.

(...)

A 32bit XP computer gets a blue screen every time you start the second sample.
A 32bit win7 computer doesn’t start the nexe with a "bad ELF file" message.
A 32bit OSX mac doesn't load the nexe without any reason or error.
You know how contradictory those sentences look, don't you? :lol: :lol:
(blue screen in XP)
Assaf Raman wrote:...the idea behind the "sandbox" is a new concept that NaCl introduced (...)
To preserve platform portability and security – you can't access any platform specific API – like windows API and such.
Then how is it that you can access OpenGL? :lol:

Just highlighting funny facts. Not doing criticism of any sort. Besides this is brand new stuff.

Good luck
Dark Sylinc
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by jacmoe »

Dark Sylinc is really saying that he loves it. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

Well, NaCl has the same system access as javascript - so if javascript has access to GL - it is the same risk.
Regarding the blue screen, yes OpenGL can blue screen you, the way they are going to solve this is black listing drivers and such. This is an issue also for javascript, flash and the rest - so no disadvantage for NaCl.

Regarding it not starting on so many platforms, well, I didn't expect it, but this is something that can easily get solved by them with some focus on the topic, so I am not worried about it.
Watch out for my OGRE related tweets here.
User avatar
0xC0DEFACE
OGRE Expert User
OGRE Expert User
Posts: 84
Joined: Thu May 21, 2009 4:55 am
x 7

Re: OGRE port to NaCl (Google's Native Client)

Post by 0xC0DEFACE »

Fantastic! Really great work dude! I have been following NaCl for a while and am quite thankful for what you have produced.

Just a few days ago started tinkering with trying to compile an ogre app of mine. I tried to get it all building and working with scons (what the NaCl SDK uses to compile all its examples) but kept having problems.

Firstly I had no idea how to use scons, python or the gcc tool chain, but the NaCl example apps compiled fine using them...how hard could it be?

After looking at Googles NaCl scons scripts, reading scons docs and googling how to do things in python I managed to struggle my way point that I had made a script that would build all the files for free image and then link them into a static lib. This took me a while as scons kept complaining about things, and I also have to add some defines through the free image code, mainly to not include memory.h for NaCl. But then at the linking stage scons politely informed me that the console input was too long. Thanks scons, you dick, mocking me while I waste my weekend cursing you.

Anyway, I was really not looking forward to sorting that out. But then I found this thread, and the joy it summoned was enough for me to give you a hug...If you were here in person.

You have saved me a bunch of work, AND I don't have to use scons! When I get some time ill download ogre 1.8 and your solution converter (wiked!) and see if I can get something working!

Also FYI, I could get the Cube page to load but not the sample browser. It seems to be a problem with the resources. Ogre threw two same exceptions in the java console:

Code: Select all

Creating resource group Popular
OGRE EXCEPTION(7:InternalErrorException): Popular.zip - error whilst opening archive: Unknown error. in ZipArchive::checkZzipError at C:\hg_Code\ogre\ogre_nacl\src\OgreMain\src\OgreZip.cpp (line 297)
OGRE EXCEPTION(7:InternalErrorException): Popular.zip - error whilst opening archive: Unknown error. in ZipArchive::checkZzipError at C:\hg_Code\ogre\ogre_nacl\src\OgreMain\src\OgreZip.cpp (line 297)
NaCl Box also works fine for me, but thats not 3D :P

http://www.naclbox.com/gallery/duke-nukem-ii

HTH, and Thanks again! :D
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

@0xC0DEFACE: You made my day, thanks for your kind words.
Regarding the zip issue - I saw it before, refreshing the page solved it in the past, you can also try to delete the browser cache.
This is a bug in the download code I wrote that uses the NaCl SDK h files, the bug hardly recreates - so I couldn't debug it, what it means that the file was corrupted while downloaded, I don't have a clue why... The code that downloads the files is very raw, I will be happy for any rewrites of it...
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

Try this site template locally and see if it works: http://goo.gl/te4Sv (use a local http server on your computer)
Watch out for my OGRE related tweets here.
User avatar
0xC0DEFACE
OGRE Expert User
OGRE Expert User
Posts: 84
Joined: Thu May 21, 2009 4:55 am
x 7

Re: OGRE port to NaCl (Google's Native Client)

Post by 0xC0DEFACE »

Assaf Raman wrote:@0xC0DEFACE: You made my day, thanks for your kind words.
Credit where credit is due my friend!

I tried clearing my cache and trying again this morning and it all loaded up and worked :). I also tried the local version you posted and it worked too.

Very cool.
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: OGRE port to NaCl (Google's Native Client)

Post by al2950 »

jacmoe wrote:1 kudos is simply not enough. :D
I have to agree! Amazing work Assaf :D

NB. I am getting 180 FPS on bump map demo (knot.mesh, NormalMapping_SinglePass) on a 9800GT.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

The biggest downer for now is that the Google people hinted me that 3d will not be enabled for NaCl by default:
http://groups.google.com/group/native-c ... f15caf10a6
Erik Kay wrote:Thanks for the feedback Assaf. Right now, the 3D API is in a state where
only developers can use it. This should change soon with Chrome 15.
I don't really like this decision - webgl is enabled by default in Chrome, and in theory one can stream out the gl commands to javascript from a NaCl program - with bad performance but the same risks - so why limit NaCl and not webgl? I guess what he means is that they haven't tested the NaCl opengl interface and it is not the same as the webgl one, that seems reasonable.

They release a version once every two months - so we will have to wait about four months for gl support in NaCl, not that bad, I can wait, four months is not long in open source development terms.

I got good reactions from the official NaCl discussion group - so the future looks bright.
Watch out for my OGRE related tweets here.
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: OGRE port to NaCl (Google's Native Client)

Post by Zonder »

That read to me it's currently unsafe as you say but they are macking it safe for v15
There are 10 types of people in the world: Those who understand binary, and those who don't...
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

I opened issues for the NaCl team for most of the issues I had and wrote about on this thread - you can watch my issues on this page: http://goo.gl/S1YdU
Watch out for my OGRE related tweets here.
User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
x 2
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by Nir Hasson »

Great job man !!
Way to go..
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80
Contact:

Re: OGRE port to NaCl (Google's Native Client)

Post by duststorm »

This is really promising!
I'm looking for a solution to distribute my application via web browser in the future, and this seems to be the best option. Previously I was leaning towards distributing my app as a java applet using JNI.

I wasn't even aware of the existence of this feature! :)
Developer @ MakeHuman.org
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: OGRE port to NaCl (Google's Native Client)

Post by mkultra333 »

Hey, this looks excellent! I've been wanting to start developing for more platforms than just PC, this might be the pathway I need.

About chrome and NaCl: I see the Chrome browser exists for Apple computers, PCs and Linux systems. Is there any likelihood of Chrome and NaCl going to mobile devices like the iPad or Android tablets and phones?

Also, what shaders can I use in NaCl? I assume it'd all be OpenGl stuff.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

In the future they are going also to support Android and mobile Linux, I guess I year from now.

Regarding shaders - you can glsl es or Cg (read here.)
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: OGRE port to NaCl (Google's Native Client)

Post by Assaf Raman »

Google changed the way gl is initialized in NaCl, pushed a new Chrome beta to the users, but didn't provide a new SDK, meaning my OGRE NaCl port doesn't work!
I will fix it as soon as the new NaCl SDK is released (v0.6).
Watch out for my OGRE related tweets here.
Post Reply