OpenGL in PHP
Neophytus writes "Submitted as an entry into the .geek PHP5 tournament a proof of concept openGL implementation in PHP has been released by Peter 'iridium' Waller. The demonstration (download) shows four items being rendered in realtime by PHP at a not unreasonable 59FPS. The author welcomes feedback with practical uses for this technology."
Update: 06/09 01:10 GMT by T : iridiumz0r, author of this entry, adds a link to this informative page responding to a number of comments in the discussion below.
Very impressive -- A while back I heard about PHPOpenGL.
But he didn't even use this at all! Pretty self contained, even to the gzipped uuencoded DLL file embedded in this PHP script whose sole purpose is to create the window that this PHP demo needs for the 3D graphics.
I'm sure others are thinking, like me, "Huh? PHP in a window, not a server-side script?" It took me a couple of moments to figure out how this works, so I figured this could be of some help to others struggling with it.
How to get this download to work in Windows:
1. Unzip the contents of the download to C:\php5
2. Open the C:\php5 directory in Windows Explorer
3. Drag and drop the opengl.php file onto the php-win.exe icon
or
2. Open a Command Prompt
3. C:
4. cd \php5
5. php-win.exe opengl.php
It seemed to me that the DLL paths are hard-coded, so that's why it needs to be in that particular directory.
How soon till we see a port of Unreal?
...Is truly a lost art.
Of course, we already knew this.
Opengl in php.. well, let's see, you could umm.. sell it to a PHB who doesn't know any better, or make bets with people at the local pub that it can be done and then whip it out to win the bet.
59 fps? Sounds like vertical sync at 60 hz. Anybody have any real performance figures?
"[A] high IQ is like a Jeep; you will still get stuck, just farther from help!" --Just d' FAQs, c.g.a
This actually isn't an "OpenGL implementation". It just calls OpenGL func in win32 environment.
cheap implementation. JBoss have a far superior product and this does not even come close to the technical excellence that is JBoss. I do not work for JBoss.
Maybe I'll just start using my kitchen sink as a bathtub just because I can.
I have a 3ghz P4, Radeon 9700 Pro, and 1gb of RAM, and I get about 180FPS constant
While my subject is half-joking, it would be cool to be able to have a running traffic chart generated by a PHP script that you could use to monitor a particular server.
Maybe tie this in with the 3D portscanning/IDS system mentioned a few days ago and make it a remote application?
Overrated / Underrated : Moderation
Unfortunately, it's not a port, it's windows only using the Win32 API. I can see someone didn't RTFA.
Things you think are in the Constitution, but are not.
You are way off. This is pure novelty and has nothing to do with "server side" or "web pages," don't be fooled by the presence of PHP. Also, "port of OpenGL" doesn't make much sense -- OpenGL cannot be ported, just implemented, which this does not do. It's just an OpenGL client.
"[A] high IQ is like a Jeep; you will still get stuck, just farther from help!" --Just d' FAQs, c.g.a
When I ran it on my laptop, I was getting an average of 120 FPS. And while I respect the effort and appreciate the use of OpenGL, I cant see this killing Flash in the near future (or in any other parallel reality). Server-side scripts should stay just that, IMHO.
I've joined a group at LBNL (berkeley lab) that could use this. They have a database of molecular data, and they need a way to visualize it using a web interface.
Quid festinatio swallonis est aetherfuga inonusti?
Africus aut Europaeus?
Actually, being able to render a scene in open GL and send it to a client over the web would be very useful, not for real time animation, but it could certainly be cool for doing custom 3d graphics for a website. Imagine something like a web based Myst rendered in real time on the server. In this case, though, they are using PHP GTK for client side apps written in PHP.
autopr0n is like, down and stuff.
You'd be surpised what get's prototyped in PHP e.g. http://sourceforge.net/projects/phpsdl/ - "PHP SDL module is a wrapper/binding of Simple DirectMedia Layer for PHP. The goal of this project is to allow rapid prototyping of multimedia applications using PHP."
Usually doesn't get beyond the prototype though.
Darn trolls...
Why is it that every Slashdot discussion has to start off with some idiot trying to ruin the fun for everyone else?
There aren't any viruses in these scripts, and I doubt they would make it to the front page on Slashdot without someone actually downloading and running them to see what they are. They work quite nicely (I like the changing spirograph).
My other thought is that this is a convenient port of opengl to any platforms that currently do not support it.
It's not a port, it's just calling opengl functions in php. You'd have to vnc to a windows box or something to view this on a platform that doesn't support openGL. What platform doesn't support opngl and supports php though? Maybe there are some..?
...better pr0n
--
This sig doesn't do windows
Just from reading a few comments, I see people still believe PHP is only server-side. This is all client-side. No server is neccesary. This is just like php-gtk, and the old php_opengl implimentation.
Disconnect and self-destruct, one bullet at a time.
I'm sorry but I have to reject the idea of running openGL with PHP. The concept makes about as much sense as using Flash intros.
However I will add that there is a neato factor to all this, but it only goes so far. It's just silly to allow the unwashed masses access to this kind of technology because it's going to end up like Flash anims, and further plague our internet with CRAP.
The dangers of knowledge trigger emotional distress in human beings.
What does that have to do with anything?
Quality over Quantity.http://www.virusgaming.com/
Here's a couple of ideas:
- GPS terrain mapping: stream a live map in real time with low bandwidth
- Shrek Chat Live!: Have hires avatars render while you speak. Kinda like that Microsoft chat but with good chat buddies.
- Quantum Encryption: Have a whole 3d movie but just use three texture map hidden in the movie are your keys.
You say things that offend me and I can deal with it. Can you?
What's worse than a smug lisp asshole?
One that can't correctly spell 19 words in a row?
The author welcomes feedback with practical uses for this technology.
Because he couldn't think of any.
*ducks*
welcome to the party, PHP.
As I read the discussion, I notice plenty of people missing the point of this. So, to remind you all, it's for a contest. And from the looks of it (His entry making /. and all...), he's about to win the contest too.
Just a cheap party trick, but it gets you free stuff.
The Yasashii Syndicate ||
Well, it's not a port or an implementation; it's a wrapper to a DLL. That's the fun of dynamically loaded libraries: you can call opengl, gtk, qt, COM, CORBA, $WHATEVER_YOU_WANT from $WHATEVER_LANGUAGE_YOU_WANT as long as you take the time and effort to write a wrapper label, which this guy did, and he wasn't the first.
All's true that is mistrusted
....that damn 3D-studio duck will be returning to our screens within days.... Grrrrr! Please no.... it can't be allowed to happen my duck nightmares have been reoccuring ever since I first saw that duck a few times in the mid 90's.... quack quack.... Noooooooooooooo
I suppose if we did some code hacking we could get it to render the OpenGL scene and take a screenshot then save the screenshot as a file. From then on everyone could be sent that screenshot off the page. Sites with Half-Life and Quake2 maps wouldn't have to manually take the screenshots. PHP would be able to do it all for them (if they got a good camera location anyway :P)
Have you metaroderated recently?
So why not have 5 of them?
Here's the slightly altered code. (right click, save)
- Cary
Soon php will be used for all kinds of innapropriate uses!!
For a moment I thought of someone writing a PHP script to dynamically generate Perl scripts for web output... just for no real reason
But then I thought.... Naaaaaa.
;)
P.S. Anything on NeHe about this yet? I did a text search of the front page but nada (I haven't been to the site in months).
Are you local? There's nothing for you here!
porn in php. woot!
-------
FM Clan
"Technical prowess"??! It's just connecting the dots, not even coloring inside the lines with crayons. If they'd written their own OpenGL IMPLEMENTATION instead of just wrapping pre-existing OpenGL libraries somebody else wrote, or if they actually implemented an interesting and original OpenGL game or application in PHP, then there might be a reason to be impressed, but simply connecting the dots that somebody else created is not impressive, certainly not "technical prowess". Hardly impressive.
One word: p0rn
from the they-said-it-couldn't-be-done dept.
No, that was the "from the they-said-it-shouldn't-be-done dept." It's down the hall to the right, and be sure to knock loudly before entering.
501 Not Implemented
On my 1.4ghz Pentium M/Radeon 9000 laptop i'm getting 230-240 fps on the fastest spirograph.
think about it, im surfing the web, and some stupid ad comes up and demands my processor and video card take time away from whatever I purchased them to do... arrgh... unless I want to disable all the latest plugins or something, and that's a hassle to my lazy moonpie pudged ass
This is a very cool thing heh.. but it isn't to be unexpected, as phpopengl was already made, but this new one looks great as well. But who knows what other things will come out... Look at all of these things that php can do here ,there are a bunch of interesting and very useful mods, and more come out all the time. Also, take a look at that link, it gives you a good idea of what php can do (although there is much more than what is on that page).
Duke Nukem Forever online!
huh, sorry but what the hell are you talking?
it(the story) is a program you run locally, it's not a competition to anything web related.
world was created 5 seconds before this post as it is.
If PHP is open source does this make it Open^2GL?
----------
mobile porn
Dude, keep that smack quite... Last think we want is someone implementing PHPActiveX controls/applets... ugh...
I confess: I've been migrating away from bash and Perl script development, toward using PHP CGI scripts, for a while. It's just too convenient to not use as a CLI scripting language.
When one thinks OpenGL they think real time graphics. 59fps sounds impressive until you look at what it's doing in 59fps. Unless he's got his vsync locked that demo should be going several hundred FPS even on a lowly GeForce 2 MX and a barely over 1Ghz processor.
When cross platform is more important than "wow" factor and speed PHP might be appropriate. Otherwise you need to stick to compiled languages. If it can only push a few basic primitives with simple vertex based coloring at 59fps that doesn't leave much time for anything complex.
Neat but very niche. I don't think it'll ever get into the "because it's a good idea" category. It seems to be suited best in the "because I can" category.
Ben
Work Safe Porn
Just so I can be sure not to be mocked in the future, could you - the dear readers of this post - please assign a tick beside which language on the scale it's acceptable for OpenGL to support.
.Net OpenGL/br />
Assembly OpenGL
Basic OpenGL
XSLT OpenGL (heh)
Ecmascript OpenGL
Haskel OpenGL
Scheme OpenG
Python OpenGL
C OpenGL
Ruby OpenGL Java OpenGL
When I try to run it, I get the error message:
PHP Startup: "I.: Unable to initialize module
Modules compiled with module API 20020429, debug=0, thread-safety=1
PHP compiled with module API=20040412, debug=0, thread-safety=1
These options need to match
Any ideas?
I have recently been playing around with Python, PyGame and OpenGL (I love the NeHe tutorial conversions done for PyGame) - I have been pretty pleased with the speed (OpenGL does all the heavy lifting - with a proper culling algorithm and scene graph implementation, speed could go up more with more complex scenes), especially on the machine I am using, which is low-end by many people's definition (P-3/450 w/GeForce 2 - definitely not a gaming machine, but works well enough for me).
Now, I don't know much about OpenGL yet, but is it possible to render to a file instead of the graphics buffer? If it were, then this thing could (in theory) go server-side (provided the server has the proper APIs and DLL, of course) - then render to a file for display by a web server.
Such a system could be useful for online data visualization services or other similar systems (mapping, network visualization, etc)...
Reason is the Path to God - Anon
You sound a little confused there sonny..
This is a _php extention_, so the only way you would see php generated 3d images in your browser would be if they were rendered on the website's server, then converted to gif/jpg, and send to your browser as image.. Thus taking no cpu power from your computer
Alert and knowledgeable readers will note that this isn't an implementation of OpenGL, but a binding of the OpenGL API into the PHP language.
A PHP *implementation* of OpenGL would be very impressive, indeed! That would imply that all of the 3D math, texture mapping, shading, rasterization, etc was written in OpenGL. Unfortunately, such an implementation would probably be extremely slow and therefore fairly useless. And it would of course still require an dynamically linked C library for framebuffer access.
So -- this is a cute trick, to be sure, but nothing to write home about. The author of the software has already said as much in an earlier comment.
Don't blame him for not RTFA, this is slashdot after all.
That would be badass, times two.
I went from C, to PERL, to PHP! w00t! I love PHP!
A while back I was looking at PHP's COM support...
Technically, shouldn't it be possible to use DirectX with PHP as well, using this COM functionality?
i thought php was server side - shouldn't this be a javascript library or something?
whats the point in openGL on the server side? it can animate the data as it parses it?
uh o_O. http://developers.slashdot.org/comments.pl?sid=110 441&cid=9371773
http://randomphp.net/
I love his method for avoiding DLL problems.. the dll file is incoded in the program's source code, and is written out at run time:
D OnguDutY+uMzh80"Z la3IgO7mQ9+733v"H JeYD53pk3UyqKkZ"d 8fKcQwxe2tirBHl"u Jo99qxPlyQ7AFfx"
---
if ( is_file( "SimpleWndProc.dll" ) ? filesize( "SimpleWndProc.dll" ) != 2560 : 1 )
{
$dll = "eNrtVU9IFGEUf7NpTbZue1hCYqlvQT3JslsG0clt/aho1XHN
. "KDrYQTPJS1TUoWMEdSpYrEOEsQl66yD9gT1ILCHhIcqDML35
. "fe9733vffN+blu4p2AEAFQjLAsiBQ03wd3qD8B2c9sHT3fOh
. "TRwgKVFRVIP0SkQzFSIrpLmtgwyoaSlcXV1V68YYevv9/ZFn
. "80fXmUzKqT577k+5CBQgwWEluZm11AvgC+3hKr3gcQu0ye+C
[snip]
. "kdWIJ8pHfdFAdH90uzf+D/QDFVAQCA==";
$dllout = fopen( "SimpleWndProc.dll", "wb" );
if ( !$dllout )
die( "Unable to extract SimpleWndProc.dll" );
fwrite( $dllout, gzuncompress( base64_decode( $dll ) ) );
fclose( $dllout );
---
( He said in the comments that it required a DLL file to work for various reasons, and I guess he wanted to have everything contained in one file... But, it's still pretty funny. )
Oops! I meant to say: That would imply that all of the 3D math, texture mapping, shading, rasterization, etc was written in PHP. This is what happens when we post to Slashdot before having our afternoon triple espresso!
...insensitive clod!
Visit http://ringbreak.dnd.utwente.nl/~mrjb/growingbettersoftware to download your free copy of the book
Nice troll, Troll. There is nothing elitist about what I have said in regards to PHP and openGL. I think the combination is an abomination! I know you may have a problem with my unwashed masses comment, but in regards to the misuse of Flash, anyone with half a clue would completely understand the comment and perhaps applaud it. You are obviously part of the unwashed masses who would disagree and I bet you have a Flash-driven Geocities page to prove it.
The dangers of knowledge trigger emotional distress in human beings.
> Only if you haven't got a clue what you are talking about.
Hahahahahahahah... hahahahaha!!! I've taught PHP & MySQL at college level, and I'm a programmer who uses PHP & MySQL on a regular basis. So I happen to have some grounding in this subject matter. So, it's you who don't know what you're talking about, actually.
> This has nothing to do with the web.
Oh give it time.
> PHP is a general purpose scripting language, like Perl or Python. It has nothing to do with websites.
Hahahahahahahahahahahahahahahahaha!!!!
Of course it's a scripting language. I just have to laugh because you're pretending it was developed for 3d design. That's ridiculous. PHP was designed for the web, unlike Perl. It's a product of the Apache Software Foundation.
From the php.net site: PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
The dangers of knowledge trigger emotional distress in human beings.
> The guy did it for the hell of it. No one is proposing that we start using php for graphics coding. Just proving that we could if we wanted to.
Yes, but we shouldn't use it like that. It's going to be exploitive if it is. It may be useful in some aspects, but I expect it will be misused by marketers, spammers (think 3d pr0n ads) and much more. I think it's going to be hell for many people. It could be invaluable for 3d gaming online, but it could also be totally misused, and because it's built into PHP, the users will have no choice but to go along with it.
The dangers of knowledge trigger emotional distress in human beings.
When the only tool you have is a hammer, every problem looks like a nail.
I am NaN
First I would like to point out that it is still making calls to OpenGL functions which were written in C (and asm most likely). Since PHP is a scripting language and in this case it is calling the OpenGL functions most of the work is being done in the OpenGL calls. Therefore it should run pretty well because most of the delay will be resulting from the C function calls. Scripting languages and all interpreter languages should do well even for simple scenes. They do slow down when you have a lot of logic going on however, such as updating a world model graph.
Reserved Word.
This seems like a crazy idea, but it could seriously be useful. Making an online library of a huge pile of 3D models for example? That could greatly help game development projects.. Rather than opening model after model trying to remember which one is which, you could dump them all into a repository and have a handy-dandy php/opengl script generate little thumbnails for them all.. Awesome.
Oh.
Not to troll, but IMO PHP is a rapidly advancing language and a force to be reconcilied with.
say, you've written your own webserver, but you run it on a consumer-grade line, you think it's secure - but (because you're not an idiot) you don't know for sure, it's just for fun, to see if you could do it, etc...
obviously, you don't post a link from slashdot. And you post anonymously! And you post where only a few will see, at first. But where can I get it checked out for serious use? Do I need 'credentials' b4 I can ask sourceforge to host something like that?
peer review here ain't really up to the job.
base64- and qp-decoding in 'just procmail' (see a.o. bq_demo.rc)
If you want to make a name for yourself... pick a language without an OpenGL binding and write one for it. PHP seems particularily odd tho' ... Ruby gots OpenGL now... so how 'bout OpenGL for the BrainF*ck programming language? How 'bout OpenGL for bash?
[signature]
I find it's especially useful for any application that involves "talking to a service over the network" or dealing with text-like (including html/xml) files and/or relatively simple GD-compatible graphics file manipulation (generating graphs, maps, etc.), whether it's a database server, a webserver, an ftp server, a socket, etc. etc.
My own current personal project involves figuring out the "TIGER/Line" geographic data from the US Census bureau so that I can render the features at will over other existing map graphics and turn them into maps for GPSDrive. I've already got PHP scripts generating "USGS Topographic maps or TIGER/Line [1998 data rendered from the census bureau site] features rendered atop USGS Terraserver aerial photos" for GPSDrive...
I've also considered doing a Kismet client class for PHP. Not real useful for old-fashioned web use, but could be handy for CLI (or PHP-GTK or whatever).
And why not? It's fun.
Hacker Public Radio is our Friend
My JiggleScript project is a similar idea only using JavaScript as a base. I haven't released in awhile, but I've been working on it the past week or so and am nearing a point where I will be making another release--now with sound via OpenAL! :-)
I get many hundreds of frames per second with my system on pretty moderate hardware (such as my 1Ghz G4 Powerbook). There is one script (not on the site, but a friend wrote it) that has about 200 boxes being rendered at a time (so about 2400 polygons) and my Powerbook still touches the 200fps range.
Give it a shot. I'd love to get some people playing with and testing JiggleScript.
Hexy - a strategy game for iPhone/iPod Touch
In mine, the js error only shows up as an icon in the system tray. I'll fix it through.
autopr0n is like, down and stuff.
I just took a look at the opengl demo using wine.
:)
it works very nice.
a simple "wine php.exe -- opengl.php" under Debian unstable.
others may enjoy taking a look
works nice with wine...
There are NO client-oriented socket functions in php.what do you mean by that??.. fsockopen doesnt open a socket to the server from the browser.. !!
fifteen jugglers, five believers
Although a cool hack, this is limited only to the Windows platform:
$w32->RegisterWindowClass( $classname );
so we have a "simple" way to create opengl demos ?
what's the point of an opengl application if it can't have threads nor can it have shared variables between the threads.
how can you wait for a network packet (for example a opengl game that uses the net) and at the same time draw frames ? well ofcourse until some "limit" you can have one thread doing both. But losing network packets because your game can't render on the screen fast enough is a death of a netgame.
php doesn't have threads and never will i think. they'd probably would have to rewrite most of the code to make it work.
it's like you are building a house but are "forgetting" that it should have a roof, electricity and water support. ofcourse the livingroom will be easy to create with 3 lines but missing the rest it has no point.
good luck anyway with it, it looks like a great util for creating opengl demos and movies which would be quite a hell to write in C from the beginning to the end.
I'd tell you the chances of this story being a dupe, but you wouldn't like it.
hmmm i've been sitting here trying to think what it would be usful for, but i realy cant think of anything. PHP hasnt really goten out of the web space much except for PHPGTK. Maybe these two projects could work together and do something? Maybe if there was a client side support for PHP in browsers this would be more usful, but appart from some small idea's people have mentioned, i dont see it being HUGE. But it is interesting.
Giving IE users a taste of their own medicine since 2005 - http://pods.-is-a-geek.net/
in my opinion, php was intended to be, and will always be, "server-side web programming language" and nothing else....if i have to do something outside the web server...then i'll use my old trustworthy buddy, PERL. Or even python. but not php.
i admit that php is very easy to learn and *run*...but lacks some powerful features and other stuffs that general purpose langs other that php offers...
btw, some p'ple believe in something stupid like php is way much faster than other programming langs because it runs faster than cgi. what a stupid, brainless thoughts.
another method to do that: http://www.psikorp.com/php_glut/
ANY tool can be the right too. Can't we all just get along.
> Yet another example of you not having a clue about what PHP is or does.
Inept. Totally inept statement. You missed my whole point, so I'll just skip it because I don't have time for people who don't understand simple logic.
The dangers of knowledge trigger emotional distress in human beings.
Why are you using PHP to do this? Were you bored?
> Is it also hard to control your fingers typing it out?
Sometimes.
> Give me a single example that makes sense. A single example of misuse.
For more information on that, go here.
The dangers of knowledge trigger emotional distress in human beings.
> I guess you completely ignored the bit about Flash and PHP OpenGL being completely different, huh?
What's the point of rehashing this? I've already explained my view on the subject. To me, this PHP/OpenGL project brings the marketing people closer to a solution that will force bandwidth-intensive marketing down our throats. Even if the current state of PHP doesn't make it easy, the push for getting OpenGL to work using PHP brings it one step closer.
PHP is a web scripting language, so it's only a matter of time before someone figures out how to take this project and transform it.
The dangers of knowledge trigger emotional distress in human beings.
Perl fan lecturing that language should promote, or better yet, ENFORCE, good programming practices? And blaming another language for that fault?
If there's language that doesn't do that, it's Perl, if you need to name one language that has most unreadable code in the world written in it, it's Perl.
But, having responded to your
HTH