OpenGL in PHP 286
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.
PHP OpenGL on SourceForge (Score:5, Interesting)
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.
Re:PHP OpenGL on SourceForge (Score:5, Funny)
This just in:
Ken Brown of AdTI reports that there's no way this code could have been written in one year. More investigations are planned to see if code was stolen from MINIX.
Re:PHP OpenGL on SourceForge (Score:5, Informative)
Re:PHP OpenGL on SourceForge (Score:5, Funny)
Re:PHP OpenGL on SourceForge (Score:5, Interesting)
Re:PHP OpenGL on SourceForge (Score:5, Funny)
Re:PHP OpenGL on SourceForge (Score:4, Funny)
Running This (Score:5, Informative)
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.
Re:Running This (Score:4, Funny)
PHP-GTK baby.... GTK apps written in php..
Soon php will be used for all kinds of innapropriate uses!!
Viva PHP!
What about (Score:4, Funny)
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 [gamedev.net] about this yet? I did a text search of the front page but nada (I haven't been to the site in months).
Re:Running This (Score:5, Funny)
OOooooooh, FACE!!
Re:Running This (Score:3, Interesting)
For instance, Ruby's web application support has been rapidly gaining ground for quite a while now; fancy state-keeping systems [beta4.com] last seen on LISP; a powerful server framework [webrick.org] now integrated with the standard library; an innovative object-relational mapping library [rubyonrails.org] which makes interfacing with SQL databases childsplay; an interesting new web application framework [rubyonrails.org] which is
Re:Running This (Score:2)
Not really. All that stuff sounds suspiciously like "dayjob". But PHP spawning a window via an encoded dll for OpenGL? Now that's entertainment.
Re:Running This (Score:2, Insightful)
I get ~113 frames per second...double the "official" number.
I also wonder what the FPS depends more on..CPU, to interpret the PHP, or graphic card, to render textures...hum..
Re:Running This (Score:5, Funny)
1. Read story on Slashdot.
2. Download
3. Unzip file.
4. Execute unknown code.
5. ????
6. Pray.
Is that about it?
Re:Running This (Score:3, Funny)
Re:Running This (Score:3, Informative)
my favorite game... (Score:3, Funny)
Re:my favorite game... (Score:4, Funny)
Using the right tool for the job (Score:5, Insightful)
Of course, we already knew this. [php.net]
Re:Using the right tool for the job (Score:5, Funny)
Re:Using the right tool for the job (Score:2)
Incorrectly quoted (IIRC) (Score:2)
Re:Using the right tool for the job (Score:3, Funny)
Re:Using the right tool for the job (Score:2, Interesting)
Sure you're not just prejudiced?
Re:Using the right tool for the job (Score:3, Insightful)
Ruby is fast has a superb set of built in functionality and very flexible, and great OO support.
Smalltalk is fast has a superb set of built in functionality and very flexible, and great OO support.
Common Lisp is fast has a superb set of built in functionality and very flexible, and great OO support.
Nothing about PHP makes it more suited for this job. Also, PHP is a language that was made specifical
Re:Using the right tool for the job (Score:5, Interesting)
So why not php? What makes php a poor choice as opposed to say perl, python, ruby, vb.net or any other scripted language?
Re:Using the right tool for the job (Score:5, Insightful)
Because you don't have to be a "guru" a la Perl to right functional programs with it. Same reason people here hate VB.
Re:Using the right tool for the job (Score:3, Insightful)
I don't hate VB because non-coders can use it, I hate VB because it forces me to think like a non-coder in order to use it.
Re:Using the right tool for the job (Score:5, Insightful)
PHP is like MySQL, and it appeals to the same group of people. It works, most of the time. When it's not sure what to do, it does _something_ rather than annoy the programmer, which might even be the wrong thing. When it does something that might be the wrong thing, it does it silently whenever possible so there is no "squeaking" on the outside. The result is that PHP programs work most of the time, like MySQL. That sounds great, but they also have a tendency to fail in unexpected murky ways.
BTW, there is no need to be a "guru" to write Perl programs. An understanding of the syntax, as well as basic structured programming/OO principles is all that is necessary to create fast, reusable, and reliable Perl code. The problem is that frequently people lack the latter, so they jump on a language like PHP which lets them get away with not having to know such things. Such people view PHP as superior and Perl programmers as pretentious language snobs because they can do in 5 minutes in PHP what would have taken them an hour to learn how to do in Perl. That in no way invalidates the viewpoint of the Perl snob. PHP is a half-ass hack of a language that happens to be preferred by the majority of half-ass hacks of programmers out there.
Note, this is not a flame at PHP developers. I know some really good ones. I'm flaming people who suggest that PHP is a better language because it doesn't make you learn anything about software design principles. That's precisely the reason I avoid other people's PHP code whenever possible and don't recommend its use in a business environment where software infrastructure quality counts towards the bottom line.
Re:Using the right tool for the job (Score:3, Insightful)
Same here, and I totally agree with you. If something goes wrong, I want to know about it, not have the program / database decide for me what it should do with it. I think your problem was you mentioned something bad about MySQL in a PHP story. The LAMP zealots are amongst the worst. MySQL will accept date types like 2004-15-60!
Re:Using the right tool for the job (Score:2)
This is true. But it also has many proven highly complex uses, has provided the programming framework for many heavy applications. By the way, this whole story is going to turn into a giant PHP troll / flamefest.
Re:Using the right tool for the job (Score:2)
real time (Score:2)
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 le
Re:Using the right tool for the job (Score:5, Insightful)
so is Brainfuck [muppetlabs.com], but i wouldn't consider it the right tool at any time.
Re:Using the right tool for the job (Score:2)
Re:Using the right tool for the job (Score:2)
What makes any scripting language a good choice for 3D graphics?
Re:Using the right tool for the job (Score:2)
Re:Using the right tool for the job (Score:3, Informative)
Re:Using the right tool for the job (Score:4, Insightful)
Languages evolve as more great developers join the core development teams and change the behavior and functionality of the language.
A good language is a language that can evolve beyond what it was designed to do and scale well.
PHP and Python are such languages.
Re:Using the right tool for the job (Score:2)
What? He is creating a tool.
Practical uses for this technology (Score:5, Funny)
Re:Practical uses for this technology (Score:5, Funny)
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.
You'd have to find a pub full of freaks first, though.
vsync (Score:5, Interesting)
Re:vsync (Score:3, Interesting)
Re:vsync (Score:2, Informative)
Correct me if I'm wrong, but... (Score:5, Informative)
Re:Correct me if I'm wrong, but... (Score:2, Insightful)
Re:Correct me if I'm wrong, but... (Score:3, Informative)
Do not be fooled by this (Score:4, Funny)
Re:Do not be fooled by this (Score:3, Funny)
Hrm.. (Score:5, Funny)
Re:Hrm.. (Score:2)
Wait till you have kids.
Re:Hrm.. (Score:3, Funny)
Actually faster FPS (Score:3, Interesting)
some people use over 3 year old computers... (Score:2)
Rendering 3D graphs of a slashdotting (Score:5, Interesting)
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 [slashdot.org] and make it a remote application?
Perfect application (Score:5, Interesting)
Re:Perfect application (Score:2, Informative)
You'll probably want to keep looking. As others have mentioned, this only calls Win32 OpenGL API (using some bundled DLLs?), and requires that PHP be run from the command line. While the code may be more portable for being written in PHP (although, as I said, it relies on external libraries written for Win32), it won't run in your browser.
However, you might take a look at Shockwave Flash Remoting [amfphp.org] with PHP. That will run in your browser.
Re:Perfect application (Score:2)
Re:Perfect application (Score:2)
Python and Perl also have (much more mature) OpenGL support. I doubt they would fit your needs either (OpenGL is for real-time local graphics, not networked visualization), but they'd almost certainly be better than this hack.
Re:Perfect application (Score:4, Informative)
Re:Perfect application (Score:2)
PHP Simple DirectMedia Layer Extension (Score:3, Interesting)
Usually doesn't get beyond the prototype though.
Not to 'bash' or anything, but... (Score:3, Interesting)
Two words... (Score:4, Funny)
--
This sig doesn't do windows
This is NOT Server-side (Score:5, Informative)
How about a new set off 'On Demand' products? (Score:5, Interesting)
- 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.
Feedback (Score:2, Funny)
Because he couldn't think of any.
*ducks*
And I say, (Score:4, Funny)
The spirograph is definitely the coolest (Score:2, Insightful)
Here's the slightly altered code [patriot.net]. (right click, save)
- Cary
uh, you read that wrong (Score:5, Funny)
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.
Who's getting the most FPS? (Score:2, Informative)
Cant wait till ads rely on my processor even more! (Score:3, Funny)
Re:Cant wait till ads rely on my processor even mo (Score:2)
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
awesome (Score:4, Informative)
Interesting... (Score:4, Interesting)
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)...
Re:Interesting... (Score:3, Interesting)
My thoughts exactly. PHP already does this with the imaging funcitons, only in 2D. I ass
Not an implementation, but a binding (Score:5, Informative)
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.
Correction (Score:3, Informative)
Avoiding DLL Hell (Score:4, Interesting)
---
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. )
Performance is irrelavant here. (Score:2, Insightful)
Awesome! (Score:3, Interesting)
I've done this in JavaScript. (Score:3, Interesting)
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.
Re:Practical use (Score:2)
Re:Practical use (Score:5, Informative)
No (Score:2)
Just a wrapper (Score:4, Insightful)
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 [sourceforge.net].
Re:Mod parent down. (Score:5, Funny)
Hi, welcome to Slashdot. You must be new here.
m-
Re:The animation can't be interactive. (Score:2)
it(the story) is a program you run locally, it's not a competition to anything web related.
Re:The animation can't be interactive. (Score:3, Interesting)
PHP has had client-oriented socket functions [php.net] since PHP3. More recently, server-orinted socket functions [php.net] have made it into PHP.
Not to troll, but IMO PHP is a rapidly advancing language and a force to be reconcilied with.
Re:Purpose (Score:2)
This is not useful in any way as far as I can tell.
It's like trying to enter your volkswagon beetle in Formula 1 race. Totally pointless.
Re:Purpose (Score:2)
My mistake. I got this competition mixed up with the official PHP5 competition [zend.com]
Ha! (Score:2)
Re:Ha! (Score:2)
The problem (Score:2)
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 PH
Ha!!! (Score:2)
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.
Hahahaha
Re:Ha!!! (Score:3, Insightful)
No, for the simple fact that this project is not headed in that direction. It does not provide for 3D apps over the web.
It's bound to go that way.
No, because in order for it to go that way, a terrible amount of work would need to be done, and the end result wouldn't provide anything that doesn't already exist.
I think it's extremely viable for a plugin to be designed that will use this, and many wil
Re:Yet another OpenGL binding (Score:3, Informative)
TimoT
Re:Yet another OpenGL binding (Score:3, Funny)