Slashdot Mirror


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.

81 of 286 comments (clear)

  1. PHP OpenGL on SourceForge by mdrejhon · · Score: 5, Interesting

    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.

    1. Re:PHP OpenGL on SourceForge by abscondment · · 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.

    2. Re:PHP OpenGL on SourceForge by iridiumz0r · · Score: 5, Informative

      I'm the author of this thing. I read slashdot quite regularly and I'm very suprised this found it's way here. In my opinion it is not slashdot worthy. It relies on lots of experimental stuff, and is just generally not up to production standard. It was my mess-around one afternoon when I should have been studying. I entered it into the competition because I wanted to do something different. I chose intentionally not to use PHP-GTK for various reasons. I wanted to start out from scratch and see if I can do everything myself. It was not my intention to do this all 'properly' as such.

    3. Re:PHP OpenGL on SourceForge by typobox43 · · Score: 4, Funny

      You obviously don't read Slashdot as regularly as you say if you think that a "mess-around" wouldn't make it onto the front page.

    4. Re:PHP OpenGL on SourceForge by iridiumz0r · · Score: 5, Interesting

      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.

    5. Re:PHP OpenGL on SourceForge by The+Ogre · · Score: 5, Funny

      Please, "not slashdot worthy"? I believe the page that details how to make an Enterprise out of a dead floppy disk made it up here, twice. You got that *BEAT*.

    6. Re:PHP OpenGL on SourceForge by Profane+MuthaFucka · · Score: 3, Funny

      I would have been the author of this thing, but I read Slashdot too fucking much.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    7. Re:PHP OpenGL on SourceForge by pcmanjon · · Score: 2, Insightful

      I don't know what submitter of story's problem is with his computer only getting "59FPS." but I seem to get 120. Weird.

  2. Running This by andyrut · · Score: 4, Informative

    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.

    1. Re:Running This by rat7307 · · Score: 4, Funny

      I'm sure others are thinking, like me, "Huh? PHP in a window, not a server-side script?"

      PHP-GTK baby.... GTK apps written in php..

      Soon php will be used for all kinds of innapropriate uses!!

      Viva PHP!

      --
      Burma?
    2. Re:Running This by PCM2 · · Score: 5, Funny
      Soon php will be used for all kinds of innapropriate uses!!
      Like programming, you mean?

      OOooooooh, FACE!!

      --
      Breakfast served all day!
    3. Re:Running This by rffmna · · Score: 2, Insightful
      Thanks for instruction.

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

      --
      -------
      FM Clan
    4. Re:Running This by Fweeky · · Score: 2, Interesting

      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 last seen on LISP; a powerful server framework now integrated with the standard library; an innovative object-relational mapping library which makes interfacing with SQL databases childsplay; an interesting new web application framework which is causing quite a stir; an amazingly easy to set up Wiki server; a nifty template library 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 ;)

    5. Re:Running This by jdray · · Score: 4, Funny

      Let me get this straight...

      1. Read story on Slashdot.
      2. Download .zip file to Windows box.
      3. Unzip file.
      4. Execute unknown code.
      5. ????
      6. Pray.

      Is that about it?

      --
      The Spoon
      Updated 6/28/2011
    6. Re:Running This by no+longer+myself · · Score: 3, Funny

      It couldn't be anymore dangerous than checking your e-mail in Outlook...

    7. Re:Running This by Fletch · · Score: 2, Informative
      It seemed to me that the DLL paths are hard-coded, so that's why it needs to be in that particular directory.
      The PHP binary is looking for the php_ffi.dll extension in it's default extension_dir (C:\php5\ext). Instead of unzipping it there you could simply run it as:
      php.exe -d extension_dir=. opengl.php
    8. Re:Running This by yerfatma · · Score: 2, Funny

      Close one eye.

  3. my favorite game... by AtariMike · · Score: 3, Funny

    How soon till we see a port of Unreal?

    1. Re:my favorite game... by DarkHelmet · · Score: 3, Funny

      Right after the Duke Nukem Forever port.

      --
      /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
  4. Using the right tool for the job by Cardinal · · Score: 5, Insightful

    ...Is truly a lost art.

    Of course, we already knew this.

    1. Re:Using the right tool for the job by chabotc · · Score: 4, Funny

      When you have a hammer, everything looks like a nail!

    2. Re:Using the right tool for the job by tolan-b · · Score: 2, Interesting

      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? :)

    3. Re:Using the right tool for the job by killjoe · · Score: 4, Interesting

      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?

      --
      evil is as evil does
    4. Re:Using the right tool for the job by Saeed+al-Sahaf · · Score: 4, Insightful
      So why not php?

      Because you don't have to be a "guru" a la Perl to right functional programs with it. Same reason people here hate VB.

      --
      "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    5. Re:Using the right tool for the job by damiam · · Score: 2, Informative

      GTK can embed an OpenGL display, so yes, you can use 3D in GTK apps. That wasn't, however, the parent's point. The point was that PHP was designed for server-side scripting and is therefore not the right tool for any GUI job.

      --
      It's hard to be religious when certain people are never incinerated by bolts of lightning.
    6. Re:Using the right tool for the job by pizza_milkshake · · Score: 4, Insightful
      It's a turing complete language

      so is Brainfuck, but i wouldn't consider it the right tool at any time.

    7. Re:Using the right tool for the job by FuzzyBad-Mofo · · Score: 2, 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.

    8. Re:Using the right tool for the job by loginx · · Score: 3, Insightful

      And perl was designed for text processing.

      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.

    9. Re:Using the right tool for the job by GnuVince · · Score: 2, Insightful
      Python is fast has a superb set of built in functionality and very flexible, and has great OO support.
      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 specifically for web pages and turned into a general purpose language because of some mad scientists. On the other hand, Python, Ruby, Common Lisp and Smalltalk are all general purpose languages, and were made that way from scratch.

    10. Re:Using the right tool for the job by Anonymous Coward · · Score: 2, Interesting

      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.

    11. Re:Using the right tool for the job by runderwo · · Score: 4, Insightful
      Nice troll. The problem is more like that with PHP you can "right" programs that work with a minimum of effort. That sounds great, but the issue shows up when that code is handed to someone else. Debugging someone else's code in a language that enforces structured programming pragmas as little as possible is a nightmare. I know this because I do it on a regular basis.

      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.

    12. Re:Using the right tool for the job by Canberra+Bob · · Score: 3, Insightful

      "Debugging someone else's code in a language that enforces structured programming pragmas as little as possible is a nightmare. I know this because I do it on a regular basis."

      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! Having to support quite a number of apps, I want to know the moment something funny happens, not find out a month later when the end user is pulling a report.

      For simple web apps (eg shopping cart) I advise people to use LAMP due to its simplicity. Anything larger and I advise people to stay well clear and go with something like Java (or Perl) and Postgres. This forces the designer / developer to think in large terms to begin with. May seem like a waste of time early on (and it is if you know for certain your app will not grow) but when you start scaling up, it will save a total rewrite.

    13. Re:Using the right tool for the job by DMUTPeregrine · · Score: 2, Funny

      Everything you just said can be applied to INTERCAL. It's turing complete. It's object oriented. Normally the object being a sledgehammer taken to the inventors, but still an object. It supports inheritance. Thousands have inherited headaches from trying to comprehend it. It has exception handling. The language is an exception, and it can handle printing the word INTERCAL rather without all That much difficulty. Assertions. Very easy in intercal. A large library. Well, there are a good number of libraries. Large community: Well, it's a good size, and anyone who has ever obfuscated code is an INTERCAL user at heart. Also anyone sick of the establishment. So why not INTERCAL? What makes INTERCAL a poor choice as opposed to say perl, python, ruby, vb.net, or any other language whatsoever?

      --
      Not a sentence!
    14. Re:Using the right tool for the job by TheRaven64 · · Score: 2, Funny

      When the only tool you have is a chainsaw, every problem looks like fun.

      --
      I am TheRaven on Soylent News
    15. Re:Using the right tool for the job by 1110110001 · · Score: 2, Informative

      Set error_reporting to E_ALL and you see when PHP has to decide something you haven't defined. When you set your stderr to /dev/null you won't see errors in most unix tools and they do "something else". PHP has a recommended configuration. Use it!

      b4n

  5. Practical uses for this technology by vxvxvxvx · · 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.

    1. Re:Practical uses for this technology by Doomrat · · 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.

    2. Re:Practical uses for this technology by Fryboy · · Score: 2, Insightful

      When's your next Slashdot Meetup??

  6. vsync by shamilton · · Score: 4, Interesting

    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
    1. Re:vsync by atrus · · Score: 2, Interesting

      Many video cards, when operating in OpenGL, VSync by default, so I agree with you here.

    2. Re:vsync by volvoguy · · Score: 2, Informative

      If the FPS given in the titlebar of the demo app are accurate, it's doing 160FPS on my modest machine (P4 2.8Ghz, 1Gb RAM, ATI Radeon 7500).

  7. Correct me if I'm wrong, but... by Anonymous Coward · · Score: 5, Informative

    This actually isn't an "OpenGL implementation". It just calls OpenGL func in win32 environment.

    1. Re:Correct me if I'm wrong, but... by DeltaSigma · · Score: 2, Insightful

      At least it let me know about the useful ffi extension. If it wasn't for this cute demo, I'd have never come across this.

    2. Re:Correct me if I'm wrong, but... by hey · · Score: 2, Informative

      Yeah, for example it uses glEnable() from Windows.

  8. Do not be fooled by this by Anonymous Coward · · Score: 4, Funny

    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.

    1. Re:Do not be fooled by this by Anonymous Coward · · Score: 3, Funny
  9. Hrm.. by Anonymous Coward · · Score: 5, Funny

    Maybe I'll just start using my kitchen sink as a bathtub just because I can.

    1. Re:Hrm.. by mrjb · · Score: 2, Funny

      Actually my dad tried this once [using the sink as bathtub] before I was born, according to legend, because the tiny house they bought had no shower-- used the sink as tub and got stuck. If he moved one way he'd turn up the burning hot peel-your-skin-off temperature water, moving the other way he'd turn up the so-cold-it-would-freeze-his-you-know-what-off water. My mom, instead of helping out, ran off to get the photo camera. None of the pictures she took got any good, they were all shaken cause of her laughing....

      --
      Visit http://ringbreak.dnd.utwente.nl/~mrjb/growingbettersoftware to download your free copy of the book
  10. Actually faster FPS by Wallslide · · Score: 3, Interesting

    I have a 3ghz P4, Radeon 9700 Pro, and 1gb of RAM, and I get about 180FPS constant

  11. Rendering 3D graphs of a slashdotting by mhesseltine · · Score: 4, 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 and make it a remote application?

    --
    Overrated / Underrated : Moderation :: Anonymous Coward : Posting
  12. Re:Practical use by shamilton · · Score: 4, Informative

    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
  13. Perfect application by Capt'n+Hector · · Score: 5, Interesting

    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?
    1. Re:Perfect application by timothyf · · 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 with PHP. That will run in your browser.

    2. Re:Perfect application by MagPulse · · Score: 3, Informative

      You probably want a Java3D applet, which can use OpenGL or Direct3D. You can access your database from it using JDBC or just grab a flat file from a URL, and then visualize it however you want.

  14. PHP Simple DirectMedia Layer Extension by Anonymous Coward · · Score: 3, Interesting

    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.

  15. Two words... by tickticker · · Score: 4, Funny

    ...better pr0n

    --
    This sig doesn't do windows

  16. This is NOT Server-side by cbrocious · · Score: 5, Informative

    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.
  17. How about a new set off 'On Demand' products? by randomErr · · Score: 4, Interesting

    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?
  18. Feedback by Anonymous Coward · · Score: 2, Funny

    The author welcomes feedback with practical uses for this technology.

    Because he couldn't think of any.

    *ducks*

  19. And I say, by consumer · · Score: 3, Funny

    welcome to the party, PHP.

  20. Just a wrapper by Theatetus · · Score: 3, 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.

    --
    All's true that is mistrusted
  21. The spirograph is definitely the coolest by caryw · · Score: 2, Insightful

    So why not have 5 of them?

    Here's the slightly altered code. (right click, save)

    - Cary

  22. What about by T-Kir · · Score: 3, 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 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!
  23. Re:Mod parent down. by ultramk · · Score: 4, Funny

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

    Hi, welcome to Slashdot. You must be new here.

    m-

    --
    You catch enchiladas by picking them up behind the head and holding them underwater until they don't kick anymore -VeGas
  24. uh, you read that wrong by theantix · · Score: 4, Funny

    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
  25. Who's getting the most FPS? by asherman · · Score: 2, Informative

    On my 1.4ghz Pentium M/Radeon 9000 laptop i'm getting 230-240 fps on the fastest spirograph.

  26. Cant wait till ads rely on my processor even more! by Moonpie+Madness · · Score: 3, Funny

    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

  27. awesome by vmircea · · Score: 4, Informative

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

  28. Not to 'bash' or anything, but... by soloport · · Score: 2, Interesting

    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.

  29. Interesting... by cr0sh · · Score: 3, Interesting
    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)...

    --
    Reason is the Path to God - Anon
    1. Re:Interesting... by Tokerat · · Score: 2, Interesting

      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.
      --
      CAn'T CompreHend SARcaSm?
  30. Not an implementation, but a binding by Xeger · · Score: 4, Informative

    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.

  31. Avoiding DLL Hell by tji · · Score: 3, Interesting

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

  32. Correction by Xeger · · Score: 2, Informative

    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!

  33. Performance is irrelavant here. by HFXPro · · Score: 2, Insightful

    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.
  34. Awesome! by Klowner · · Score: 2, Interesting

    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.

  35. Re:The animation can't be interactive. by unixbum · · Score: 3, Interesting
    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 since PHP3. More recently, server-orinted socket functions have made it into PHP.

    Not to troll, but IMO PHP is a rapidly advancing language and a force to be reconcilied with.
  36. I've done this in JavaScript. by BigZaphod · · Score: 2, Interesting

    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.

  37. Re:Ha!!! by groomed · · Score: 2, Insightful

    This process is still young, but the eventual direction this will take is 3d apps over PHP and the web.

    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 will adopt it for websites as a result. Why the hell wouldn't they?

    Because PHP is not very well suited to the task, and better solutions exist. This hack is on the order of building a toilet out of LEGO's. Possible, but neither viable nor a harbringer of things to come.

    It's not a totally bad idea, just one that scares me somewhat, if it's used maliciously.

    I don't know that you know what the idea is here.

    There are systemic misuses and outright exploits. I am sure that any new system has both.

    There is nothing new about this "system". It's just another computer program.

  38. Re:Yet another OpenGL binding by TimoT · · Score: 2, Informative

    Blatant plug: OpenGL and SDL bindings for Common Lisp: CL-SDL. And yes, I'm one of the authors. Most Common Lisps are compiled to native code; the performance is fairly good with the added benefit of having a high-level language to program with. There are also bindings to Haskell and OCaml AFAIK.

    TimoT

  39. Re:Yet another OpenGL binding by vidarh · · Score: 2, Funny

    It's mean to suggest something like that... Someone now WILL feel they NEED to write OpenGL bindings for BrainF*ck and Bash just because you suggested it and it's perverted enough.