Please create an account to participate in the Slashdot moderation system

 



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:
  • Running This (Score:5, Informative)

    by andyrut ( 300890 ) on Tuesday June 08, 2004 @06:21PM (#9371310) Homepage Journal
    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.
  • by Anonymous Coward on Tuesday June 08, 2004 @06:26PM (#9371372)
    This actually isn't an "OpenGL implementation". It just calls OpenGL func in win32 environment.
  • Re:Practical use (Score:5, Informative)

    by shamilton ( 619422 ) on Tuesday June 08, 2004 @06:30PM (#9371415)
    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.
  • by cbrocious ( 764766 ) on Tuesday June 08, 2004 @06:39PM (#9371489) Homepage
    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.
  • Re:vsync (Score:2, Informative)

    by volvoguy ( 760793 ) <slashdotNO@SPAMvolvoguy.net> on Tuesday June 08, 2004 @06:39PM (#9371490) Homepage
    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).

  • by damiam ( 409504 ) on Tuesday June 08, 2004 @06:53PM (#9371614)
    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.
  • by timothyf ( 615594 ) on Tuesday June 08, 2004 @06:55PM (#9371632) Homepage

    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.

  • by asherman ( 593180 ) on Tuesday June 08, 2004 @07:04PM (#9371723)
    On my 1.4ghz Pentium M/Radeon 9000 laptop i'm getting 230-240 fps on the fastest spirograph.
  • by MagPulse ( 316 ) on Tuesday June 08, 2004 @07:05PM (#9371732)
    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.
  • awesome (Score:4, Informative)

    by vmircea ( 730382 ) <vmircea@t[ ]st.edu ['jhs' in gap]> on Tuesday June 08, 2004 @07:06PM (#9371747) Homepage
    This is a very cool thing heh.. but it isn't to be unexpected, as phpopengl [sourceforge.net] 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 [php.net] ,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).
  • by iridiumz0r ( 711388 ) * on Tuesday June 08, 2004 @07:10PM (#9371773)
    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.
  • This is no big deal (Score:1, Informative)

    by Anonymous Coward on Tuesday June 08, 2004 @07:13PM (#9371809)
    OpenGL is just a library. You can link it in to anything which allows libraries to be linked in. That includes C programs, Java programs (JNI), C++ programs. But it doesn't stop there... PHP has a modules/extension mechanism; it can link in DSO files. But so can Apache and a host of other things. In fact, maybe I'll write an Apache/OpenGL module so that people can make stuff appear on my screen by doing web stuff... that would be really easy to do if you've written some Apache modules before, and I've done plenty of that, but I'm not really sure what I would do with this.

    ----------
    mobile porn [steamymobile.com]

  • 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.
  • Re:Running This (Score:3, Informative)

    by Fletch ( 6903 ) <fletchNO@SPAMpobox.com> on Tuesday June 08, 2004 @07:57PM (#9372212) Homepage
    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
  • Correction (Score:3, Informative)

    by Xeger ( 20906 ) <slashdot@tracAAA ... inus threevowels> on Tuesday June 08, 2004 @08:11PM (#9372388) Homepage
    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!
  • by hey ( 83763 ) on Tuesday June 08, 2004 @09:50PM (#9373162) Journal
    Yeah, for example it uses glEnable() [microsoft.com] from Windows.
  • by TimoT ( 67567 ) on Wednesday June 09, 2004 @03:03AM (#9374709) Homepage
    Blatant plug: OpenGL and SDL bindings for Common Lisp: CL-SDL [sourceforge.net]. 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
  • by 1110110001 ( 569602 ) <(slashdot-0904) (at) (nedt.at)> on Wednesday June 09, 2004 @07:21AM (#9375442)
    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

Kleeneness is next to Godelness.

Working...