Engine - headless

How would I go about running the engine with maybe some dummy pc.GraphicsDevice that would do nothing and would not need WebGL?
I don’t think it’s possible from the browsers perspective (I’m still tinkering with chromium-browser) to run as a WebGL supported target without actually using the GPU.
How feasible is it for me to go about nullifying the renderer’s functionality in the playcanvas engines’ code by myself?

What I’m trying to do is have the same code running on both server and the client of my game.

Good question, I have tried it in the past but various bits (mostly model component if I remember) assume a valid graphics device. We need to update the engine to support this.

I guess there are few options:

1/ Have a null graphics device. Everything needs to check
2/ Change graphics device so that the graphics context this.gl can be null. Everywhere that uses it has to check for a valid context.
3/ Create a dummy context in the case when WebGL isn’t available. This means dummy stubs for all the WebGL methods.

I suspect 2 or 3 would work best. Though 3 might be difficult. Worth bringing @will into the conversation when he’s back next week.

It went better than expected. I’m not yet exactly sure if I’m breaking anything of use but I got it to work on Xvfb with node-webkit.
Here’s the diff with my changes

Doesn’t look too bad. I figured the problems would be when we expect a result from a gl call.

Could you let us know what you’re using to run it headless? What script are you running? How do you start node-webkit? Do you have a package.json handy?

What I’m doing may not be exactly your definition of headless but it gets me where I want to go.

package.json for nw.js

<script type="text/javascript"> var gui = require('nw.gui'); var new_win = gui.Window.open('http://localhost:8080'); </script>

starting script:


ruby -run -e httpd . -p 8080 &
Xvfb :2 -screen 0 1024x768x24 -extension RANDR &
DISPLAY=:2 /nw/nw .[/code]

I hope to run Playcanvas server-side in a Node environment. Has there been recent documentation related to this? How is Tanx server logic currently being accomplished? I found this at GitHub.

tanx logic is simple 2D vector maths. And knows nothing about client rendering and logic engine.

Thanks Max. Do you think I’m barking up the wrong tree? I would like 3D physics and all game state logic running on the server with the clients only providing control input and receiving state updates. The clients would not be running the physics.

You could do it using engine, indeed.
It would require to do some work to make sure it works without gl context.

Btw, engine is open source, and we are keen when developers contribute :wink: