3D Rendering on a Server

BlitzMax Forums/BlitzMax Programming/3D Rendering on a Server

Banshee(Posted 2011) [#1]
Hi

Has anyone had any luck using BlitzMax to render 3D images on a web server?

I've managed to get BlitzMax 1.30 compiling on Centos 5 (outdated I know - but I cant change the server so i'm stuck with an old version of glibc which in turn limits me to Max 1.30).

Of course what the server doesnt have is a desktop environment (no KDE or Gnome) as that's a security risk, so all i've got is PuTTY which is console driven and so doesnt have access to the graphics ram.

I develop locally and everything is fine but of course when I try to run my app via PuTTY I get a "Segmentation Error", which I believe is where my software calls Graphics3D because it cannot access the graphics RAM and results in a page fault.

I know that there are libraries on Linux for offscreen rendering but i've no idea how to use them, I suspect I would need to rewrite at least some of the OpenGL commands within MiniB3D to restructure the engine for rendering to an image buffer - which sounds like more man hours than I can throw into my current project.

Do any of you resident genius' have any thoughts on the topic, or suggestions of things I might try?

Thanks
Becky


kfprimm(Posted 2011) [#2]
The segmentation fault is caused by the GL graphics driver failing to find an X11 display to initialize a window and GL context on.

Don't have any idea how you would go about doing what you want to do, but I imagine it'll take some heavy modification.


Zethrax(Posted 2011) [#3]
From your post it sounds like you're trying to do 3D rendering without any sort of 3D renderer. You'll presumable need a server with either a 3D graphics card, or some sort of software renderer. MiniB3D isn't a software renderer, it's just a high-level interface to the 3D API. And the 3D API (OpenGL or DirectX) is just a low level interface for the 3D graphics hardware.

I've heard of some dedicated server hosts providing 3D graphics cards as an option on their servers, but I can't recall which ones. I'd suggest Googling for suitable hosts. Using a customized colocated server which you've set up a graphics card on is another option. You'll probably need a host that can host a tower system, though, as a conventional rack server will be lacking the ports, power capacity, etc, required for a graphics card.

I tried a quick Google for server hosts that provide this, but all I seem able to find is people asking about this on web hosting forums and then getting a lot of muppet replies back.


AdamRedwoods(Posted 2011) [#4]
The other way is to write your own Opengl software renderer, or use Mesa, which I believe has an Opengl software renderer.


Banshee(Posted 2011) [#5]
In terms of server I could get the hardware changed easily enough, but the software is more rigid - it's running CentOS 5 without a desktop environment and I cannot change that.

So I could get a 3D card put in but I have a suspicion that still wont be enough, will the "Graphics3D" command still need some kind of desktop environment to open a window?

The security experts have suggested to me in no uncertain terms that running KDE or Gnome could open up the potential for exploits and is a route that I cannot go down.

Alternatively is there a 3D engine in BMax that supports software rendering? I'd be happy to change engine, but I lack the skill and time constraints to write my own.

Thanks
Becky


BlitzSupport(Posted 2011) [#6]
I don't believe BlitzMax executables for Linux need a desktop environment, at least going by this post I made YEARS ago!

My understanding is that Linux OpenGL defaults to Mesa (generally, software rendering) by default, which is at least what used to happen in virtual machines before they supported hardware 3D, ie. things would run but very slowly.

So, if the web server had an X server installed (and the dependencies the executable needs), it *might* at least run. I know I couldn't *build* stuff requiring Graphics calls on my Linux server, but BlitzMax executables use static libs as far as I'm aware, so I think you could possibly build them on a standard PC and then copy the exe to the server. Haven't tried it...

However, I've *no* idea how you would get at the rendered image if it did run.... :/

What kind of thing are you planning to do anyway?

Last edited 2011


Banshee(Posted 2011) [#7]
I've successfully run a hello world so indeed it is the Graphics3D call which is failing.

The goal is to deliver 3D rendered images into web pages. The project at hand is quite small, just allows a user to upload an image and see their customised product visualised in 3D.

But if I can get the technology working the possibilities are endless. I'm not looking for real time, just fast delivery of a single image.

Also, I just kinda want to do it, there's a few times over the years I've seen opportunities to do some 3D renders from data just because it'd be cool - and foremost I am utterly a geek! :)

I'll go read your other post now, I might try and setup a test rig without a desktop but with a 3D card and see what happens.

Thanks
Becky


Banshee(Posted 2011) [#8]
Also may I just add, thank you everyone for the abundance of intelligent and considered replies. x

Becky


xlsior(Posted 2011) [#9]
However, I've *no* idea how you would get at the rendered image if it did run.... :/


I don't know how to get around the lack of an actual 3D surface, but if you manage to get past that (big) hurdle you can probably do all your actual rending to pixmaps, which are stored in normal RAM... Then save those to disk.


BlitzSupport(Posted 2011) [#10]
Doh, yes, you could probably just GrabPixmap/SavePixmap after a Flip, then save, so that part's easy.


I'll go read your other post now, I might try and setup a test rig without a desktop but with a 3D card and see what happens.


I'll be interested to hear if you get it working! Now I think about it, I think graphics programs did build but failed on trying to run, so maybe you will have some luck with a graphics card, though I'm reasonably sure hardware 3D isn't necessary for OpenGL/Linux, as long as X/Mesa are installed. (Could be wrong.)

Last edited 2011


BlitzSupport(Posted 2011) [#11]
Just doing a little light reading and found this, Xvfb, which is a virtual X server for machines with no display device attached. Might be useful, as rendering would go to this 'device' (just a block of memory), and the first example shows how you'd grab the output...

... and this page gives an example of real-world use.


Banshee(Posted 2011) [#12]
Thanks BlitzSupport that is a really interesting library you've found, I cant wait to try it.

I'm being all ill and sorry for myself today so i'm working from home far far away from my linux box.

xlsior, I tried rendering to texture and grabbing that but I found that the texture was not easily accessible when using this technique. It wasnt available in texture.pixmap. I considered copying it in there but aired on the side of not modifying MiniB3d to ease updating. However the problem of running on a server ocurrs long before actually rendering anything.

The more I get to understand why it doesnt work the more xvfb looks like a viable solution, so i'm very keen to try it.

Thanks
Becky


Banshee(Posted 2011) [#13]
I went in to the office in the end, and:

tried "-screen 1" and "-screen 0" and "800x600" and "640x480" with the same result:


I *think* i'm running Xvfb correctly ( I am a long way from being an expert ) but it seems to me that the application is still generating a Segmentation fault.

I am using the command:
Graphics3D 800,600,0

I am going to do some more testing, probably not today as I dont think I will get time, but with the goal of testing different graphics3D commands.


Brucey(Posted 2011) [#14]
gdb can tell you where it's crashing...


Banshee(Posted 2011) [#15]
Ooo this is feeling close now, I properly escalated to root and created some folders and had a play, and now i'm at



It feels close... Just not quite got the fat lady singing yet.


Banshee(Posted 2011) [#16]


I've got a bit closer!
No error messages with Xvfb anymore just the segmentation fault.

I need to compile a new test binary with just "Graphics3D" command and check the pixel depth of it, unfortunately some work experience kid is using the spare mouse & keyboard so I can't get near my machine without annoying the manager of the Ops department today but it feels so near now.

It bothers me that the error "Segmentation fault" is written to my PuTTY window though, I would expect it to appear on the Xvfb window, am I using it correctly?


Brucey(Posted 2011) [#17]
You may also find this of interest too, if xvfb doesn't work out for you...


Brucey(Posted 2011) [#18]
I've got OpenGL-based Max2D drawing directly into Pixmaps on a linux instance without X11 running, using OSMesa...

Happy coding :o)


BlitzSupport(Posted 2011) [#19]
As I've posted in your other thread, Brucey, you are a veritable god among men, and @Banshee, drop the xvfb thing and try this out!

Hopefully I'll get to try it tomorrow.


Banshee(Posted 2011) [#20]
The existing OSMesa implementation looks great for 2D but if i'm working in 2D on this particular project then I may aswell use gdLibrary - although I can see ideas i've had in the past which would have benefited from that approach.

The real goal of this project is to do it in 3D. Whilst i'm sure it is possible to hack MiniB3D around I don't have the time - and I suspect I probably don't have the skills to achieve it, I can see where it's got to go but I've little experience with the technicalities in question.

Anyway, I got to get on my boss is loitering over my shoulder at the moment, i'll catch up with you later :)


Brucey(Posted 2011) [#21]
Well, the example is for Max2D, but it's just using OpenGL calls... so, there's no reason it shouldn't work with MiniB3D.
Since I've about 4 hours experience with MiniB3D in total... I can't say for sure. But, I'll have a look at it later anyway... just for fun.