Is it possible to compile Unity's WebGL per processor and download the right binaries? - unity-webgl

If you create a scene using Unity WebGL, is it possible to compile ahead-of-time binary packages that can be downloaded depending on the client's processor and browser?

Related

Can I integrate a native app in a web browser?

I need to display a native app (in my case, a video game built on unity) in a web browser page.
Local video and input streaming would be a solution, but video encoding is consuming too much computer resources.
Is there a way to display a native app in a web browser page?
Sure, you need to compile your application for WebAssembly. Or, to be more precise, cross-compile it, since WebAssembly binary code runs on a virtual stack machine.
You take your native code, compile it into a .wasm module, and then load that .wasm module with WebAssembly.instantiateStreaming().
There are many toolchains that can have WebAssembly as the compilation target. I think the 2 most popular ones are Emscripten and wasm-pack.
There is also wabt, but that is rather a set of lower level tools, not quite a toolchain.
And since you mentioned Unity, I have no experience with it, but there is some official documentation on WebAssembly.
Here is a game that was developed in C# and cross-compiled to WebAssembly.

Developing qt application for a remote device

I am not sure if this is a Programming or Linux question so please forgive me! Here is my situation:
I have my own PC (running Lubuntu 64 19.04) which I use as my work desktop. I have installed qt creator and qt 5.13 and everything works fine.
Now I have a mini-pc (intel nuc) which is luckily the same CPU architecture (intel x86-64). So the program will be binary compatible for both machines and allows me to develope and compile on my main machine and then remotely deploy or debug on the mini-pc using something like ssh and scp.
I want to develope some sort of "kiosk" application for this mini-pc. The problem is that it has very little storage (32GB). This kiosk application will save some data so it needs a lot of free space.
Now back to the question: For the mini-pc, I can go with qt-installer and install qt just like how I did it on my desktop. But I want to avoid this and I want only to copy the libraries that my application needs to have as small as footprint possible. So:
Is there a qt 5.13 libraries only package that I can install using
apt-get?
Can I get away with only copying (.so or .a) files to my remote pc
in the application binary folder?
What would be the must professional way?
You can copy only the relevant dependencies. There is a existing project for this purpose, called linuxdeployqt.
According to the official docs:
This Linux Deployment Tool, linuxdeployqt, takes an application as input and makes it self-contained by copying in the resources that the application uses (like libraries, graphics, and plugins) into a bundle.
And more specific:
When used on Qt-based applications, it can bundle a specific minimal subset of Qt required to run the application.
The project is based in the official tool macdeployqt.

node-webkit and WebGL on Linux

Can someone confirm that WebGL works with node-webkit on Linux distros?
I can make WebGL run on Google Chrome after enabling the flag Override software rendering list on chrome://flags/, but I'm getting errors regarding Three.js when trying to execute the same application on node-webkit.
To answer my own question:
It just depends if the system has a video driver installed that supports:
hardware acceleration and
OpenGL ES2.0
(the requirements for WebGL)
Node-WebKit or not, WebGL is gonna run smoothly, if the above requirements are met.

MonoGame throws MonoGameGLException (InvalidEnum) Error When Creating Texture

Running any of the "Sample" projects that come with MonoGame will result in "MonoGameGLException". This occurs in the Texture2D constructor at the following code..
GL.CompressedTexImage2D(TextureTarget.Texture2D, 0, glInternalFormat,
this.width, this.height, 0,
imageSize, IntPtr.Zero);
GraphicsExtensions.CheckGLError(); <-- Error here
The value for "glInternalFormat" is:
OpenTK.Graphics.OpenGL.PixelInternalFormat.CompressedRgbaS3tcDxt3Ext
This occurs on Ubuntu Linux running on an Intel integrated graphics card.
TL;DR
This is an error that is caused because the OpenGL implementation (Mesa) does not contain support for the internal texture format (S3TC). Install the libtxc_dxtn library to add this functionality to Mesa.
The Problem
OpenGL is the graphics API that MonoGame uses to render graphics. Since OpenGL is just an API, you need some implementation of that API in order to have it work on your system. If you had an NVIDIA or ATI card, you could download their proprietary drivers (which include closed-source implementations of the OpenGL API). If you are not using their proprietary drivers (or are using a card like Intel graphics card that has open source drivers), then you are probably running Mesa, which is an open-source implementation of the OpenGL API standard.
OpenGL has a base standard, but it also has many extensions. One of these extensions is EXT_texture_compression_s3tc. This is an extension that allows the user to specify that the textures we are loading into the graphics card should be compressed using a specific algorithm of the S3TC family of algorithms. That is what the "GL.CompressedTexImage2D" line actually does: it requests that we make room for a texture that will be compressed using the DXT3 algorithm.
Mesa does not implement ALL of the OpenGL API and list of extensions. Specifically, they do not implement the S3TC extension (due to legal reasons).
"Invalid Enum" is the error that Mesa is throwing because you are trying to tell Mesa to use an extension (as specified by the enumerated value PixelInternalFormat.CompressedRgbaS3tcDxt3Ext) that Mesa does not support. This is the standard way an OpenGL implementation tells you that you are referring to an unsupported value.
The Solution
So, there are two options to fix this:
First, workaround MonoGame so that it stops using S3TC. This might require changing MonoGame code, or perhaps there is a better way using the ContentPipeline to specify what texture compression algorithm to use.
Second, install the S3TC algorithm. While Mesa does not include S3TC by default, you can include an external library for Mesa. More details on the Mesa Wiki S3TC page. Mesa needed to be built with a specific compiler flag, and then the library needs to be installed. In my Ubuntu install (12.04), I'm assuming that the Mesa package did have this flag enabled when compiling, since installing the library worked well. In Ubuntu, I installed the libtxc-dxtn-s2tc0 package.
sudo apt-get install libtxc-dxtn-s2tc0
After that, all the MonoGame samples were working.

Monotouch bindings to Obj-c library

I'm trying to bind to an objective-c library with the btouch tool. Should I be binding to a library (lib.a file) built for the iPhone or for the iOS simulator? And what is the difference if any?
Also, does it make a difference if I bind to a debug build vs. release?
Using the iPhone or the Sim version of the .a file really matters when you actually build and run. The sim version of the library is built for the intel x86 architecture and the iOS device version is built for armv6/arvm7 so it is important to link against the version of the static lib that matches what your are targeting. You can make one big library that has both the sim and iOS device .a linked together. If you lookup on Google there will be some walk throughs on how to link the two together.

Resources