Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
PHP Programming Graphics Software

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.
This discussion has been archived. No new comments can be posted.

OpenGL in PHP

Comments Filter:
  • by mdrejhon ( 203654 ) * on Tuesday June 08, 2004 @06:21PM (#9371307) Homepage
    Very impressive -- A while back I heard about PHPOpenGL [sourceforge.net].

    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.
  • vsync (Score:5, Interesting)

    by shamilton ( 619422 ) on Tuesday June 08, 2004 @06:26PM (#9371366)
    59 fps? Sounds like vertical sync at 60 hz. Anybody have any real performance figures?
  • Actually faster FPS (Score:3, Interesting)

    by Wallslide ( 544078 ) on Tuesday June 08, 2004 @06:28PM (#9371396)
    I have a 3ghz P4, Radeon 9700 Pro, and 1gb of RAM, and I get about 180FPS constant
  • by mhesseltine ( 541806 ) on Tuesday June 08, 2004 @06:29PM (#9371400) Homepage Journal

    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?

  • Re:vsync (Score:3, Interesting)

    by atrus ( 73476 ) <atrus@@@atrustrivalie...org> on Tuesday June 08, 2004 @06:29PM (#9371403) Homepage
    Many video cards, when operating in OpenGL, VSync by default, so I agree with you here.
  • by haute_sauce ( 745863 ) on Tuesday June 08, 2004 @06:30PM (#9371417)
    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.
  • Perfect application (Score:5, Interesting)

    by Capt'n Hector ( 650760 ) on Tuesday June 08, 2004 @06:32PM (#9371425)
    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.
  • by Anonymous Coward on Tuesday June 08, 2004 @06:33PM (#9371440)
    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.
  • 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.
  • by tolan-b ( 230077 ) on Tuesday June 08, 2004 @06:47PM (#9371568)
    php is fast has a superb set of built in functionality and very flexible, and with php5 has pretty good OO support.

    Sure you're not just prejudiced? :)
  • by killjoe ( 766577 ) on Tuesday June 08, 2004 @06:49PM (#9371581)
    I am curious, why don't you consider php to be the right tool? It's a turing complete language, it's object oriented, it supports inheritance (and mixin type multiple inheritance), it has exception handling, assertions, a large library and a large community.

    So why not php? What makes php a poor choice as opposed to say perl, python, ruby, vb.net or any other scripted language?
  • Very Cool (Score:0, Interesting)

    by Agret ( 752467 ) <alias DOT zero2097 AT gmail DOT com> on Tuesday June 08, 2004 @06:55PM (#9371640) Homepage Journal
    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)
  • Re:Running This (Score:3, Interesting)

    by Fweeky ( 41046 ) on Tuesday June 08, 2004 @07:04PM (#9371718) Homepage
    Some would say that any use is inappropriate for PHP. Not me, but it's certainly one of the less interesting open source languages about.

    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 causing quite a stir; an amazingly easy to set up Wiki server [instiki.org]; a nifty template library [brain-tokyo.jp] gaining fancy bytecode based acceleration and native-C compilation. Every one of these projects alone is probably more interesting to the average developer than yet-another-OpenGL-module for an interpreted language... isn't it?

    Maybe this is why this is News for Nerds, not News for Geeks ;)
  • by soloport ( 312487 ) on Tuesday June 08, 2004 @07:15PM (#9371836) Homepage
    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.
  • by iridiumz0r ( 711388 ) * on Tuesday June 08, 2004 @07:26PM (#9371932)
    I didn't think anyone would submit it. I didn't. But, I suppose I'm not suprised it reached it if someone were to submit it.
  • Interesting... (Score:4, Interesting)

    by cr0sh ( 43134 ) on Tuesday June 08, 2004 @07:33PM (#9372004) Homepage
    Let me first say I know this is client-side and not server-side.

    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)...

  • Avoiding DLL Hell (Score:4, Interesting)

    by tji ( 74570 ) on Tuesday June 08, 2004 @08:07PM (#9372328)
    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:

    ---
    if ( is_file( "SimpleWndProc.dll" ) ? filesize( "SimpleWndProc.dll" ) != 2560 : 1 )
    {
    $dll = "eNrtVU9IFGEUf7NpTbZue1hCYqlvQT3JslsG0clt/aho1XHND OnguDutY+uMzh80"
    . "KDrYQTPJS1TUoWMEdSpYrEOEsQl66yD9gT1ILCHhIcqDML35Z la3IgO7mQ9+733v"
    . "fe9733vffN+blu4p2AEAFQjLAsiBQ03wd3qD8B2c9sHT3fOhH JeYD53pk3UyqKkZ"
    . "TRwgKVFRVIP0SkQzFSIrpLmtgwyoaSlcXV1V68YYevv9/ZFnd 8fKcQwxe2tirBHl"
    . "80fXmUzKqT577k+5CBQgwWEluZm11AvgC+3hKr3gcQu0ye+Cu Jo99qxPlyQ7AFfx"
    [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. )
  • Re:Interesting... (Score:3, Interesting)

    by Tokerat ( 150341 ) on Tuesday June 08, 2004 @08:09PM (#9372353) Journal

    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)...
    My thoughts exactly. PHP already does this with the imaging funcitons, only in 2D. I assume that to create images from scratch, PHP is already using a framebuffer to draw into before converting the image to the proper file format, so hopefully it could become as simple as making 2D images is.

    The really neat thing is that PHP can create SWF (Flash) files with the proper libraries installed, I wonder if one could generate server side Swift3D-style animations with this, although if you think about it, OpenGL wouldn't really be nessisary as the Flash Player would have to do all the rendering client-side anyways...

    Neat stuff.
  • by Anonymous Coward on Tuesday June 08, 2004 @09:45PM (#9373122)
    I'm a C coder, and I don't like VB.

    But personally, I don't think that it forces you to think like a non-coder. It just has a very crippled, rigid, and non-expressive syntax that gets in your way.

    If you took VB.NET and gave it a C-like syntax, it'd start to look a lot like Java, which is a pretty good language, and certainly better than nothing. The clumsiness of VB syntax, however, is what ruins the language IMHO.

    Think about it:
    Dim x as Integer
    int x;

    If...Then..End If
    if( ... ) { ... }

    Function iSomeFunctionName( x as Integer ) as Integer
    iSomeFunctionName = x
    End Function
    int fn( int x ) { return x; }

    These are all examples of equivalent statements. VB's just happen to be more clumsy, less flexible, and more bullshit-heavy. You can still do interesting things in VB. It's just annoying.

    If there's one thing VB is good at, it makes it really easy to create GUI applications, and fast. And now that VB is VB.net, VB can use C# objects, and vice versa. So, honestly? I wouldn't mind coding the core of an application in C# (or better yet, Java), and then using VB.net to create a flimsy/cheap UI connecting the pieces and making it look presentable. In fact, if done right, that could turn out to be a better way to design an application.

    Every tool has a place. Don't let the number of bad VB "programmers" fool you. Believe it or not, it's possible to create a "good" VB app.
  • Awesome! (Score:3, Interesting)

    by Klowner ( 145731 ) on Tuesday June 08, 2004 @09:50PM (#9373163) Homepage
    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.
  • by unixbum ( 720776 ) on Tuesday June 08, 2004 @09:53PM (#9373186)
    Could somebody who knows WTF they are doing tell me if it's possible without using an applet to get this to open a socket back?

    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.
  • by BigZaphod ( 12942 ) on Wednesday June 09, 2004 @01:55AM (#9374458) Homepage
    My JiggleScript [jigglescript.com] 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.

Life is a whim of several billion cells to be you for a while.

Working...