phpMedia 2.0

Apr 20 2009

![](/i/logos/phpmedia.png) At some moment 5 years ago, I did a PHP extension that allowed to make 2D multimedia applications. By then I used PHP4 and Allegro. All the graphic stuff was done via software and it didn't allow to achieve great performance. The API was not Object-Oriented and PHP4 was much more limited than nowadays. The project was hosted at sourceforge [aquí](http://phpmedia.sourceforge.net/). A couple of weeks ago, I decided to revive the project, but make it much better: with an object-oriented interface for PHP5.3 and using OpenGL with full hardware acceleration. I created a project at googlecode, and started to define the API that it would have. The objective was to get an easy and useful API. Not fully versatile, but that allows to create enough things. I made a prototype of the interface in PHP, and a documentation generator for googlecode. * [http://phpmedia.googlecode.com/svn/trunk/api.php](http://phpmedia.googlecode.com/svn/trunk/api.php) * [http://code.google.com/p/phpmedia/wiki/API](http://code.google.com/p/phpmedia/wiki/API) I didn't write anything, but at least I designed most of te API. This afternoon I started to code, with promising results. I haven't have too much problems, and everything have gone as expected or even better. As result, I have released the furst usable version for PHP5.3. You can download it from the project's page. What I have done: * Basic keyboard support. Only the most common keys. It allows to detect presses and releases. * Graphical initialization (window and fullscreen) * Clase Bitmap (pretty advanced). It allows to create new bitmaps, load them from files or strings. It allows to make slices, and to clone images. What's left: * Improve keyboard support * Mouse support * Gamepad support. * Audio. * Shaders. Ejemplo de prueba + archivos necesarios: * [http://phpelegante.googlepages.com/test_phpmedia_20.7z](http://phpelegante.googlepages.com/test_phpmedia_20.7z) * [http://phpmedia.googlecode.com/files/php_media2.0-alpha%2Bphp53_min.7z](http://phpmedia.googlecode.com/files/php_media2.0-alpha%2Bphp53_min.7z) [http://phpmedia.googlecode.com/files/phpmedia_dependences.7z](http://phpmedia.googlecode.com/files/phpmedia_dependences.7z) In order to test the example, you have to download all the files, and execute the `test.bat` file. You can use t he cursor keys to move the image. W/S to zoom in and our the image. A/D to rotate it. ESC to exit the sample. Project's website: [http://code.google.com/p/phpmedia/](http://code.google.com/p/phpmedia/)
![](/i/logos/phpmedia.png) Hace unos 5 años, hice una extensión para php que permitía hacer aplicaciones multimedia 2D. Por aquel entonces usaba PHP4 y Allegro. Todo el tema gráfico se hacía por software y no permitía conseguir un buen rendimiento. El API no era orientado a objetos y PHP4 estaba mucho más limitado que en la actualidad. El proyecto se alojaba en sourceforge [aquí](http://phpmedia.sourceforge.net/). Hace un par de semanas, decidí que estaría bien revivir aquello, pero hacerlo mucho mejor: con una interfaz orientada a objetos para PHP5.3 y usando OpenGL con aceleración completa por hardware. Establecí un proyecto en googlecode. Y me puse a idear el API que tendría. El objetivo es conseguir un API sencillo y útil. Que no sea totalmente versatil, pero que deje hacer bastantes cosas. Hice un prototipo de interfaz en PHP, y un generador de documentación para googlecode. * [http://phpmedia.googlecode.com/svn/trunk/api.php](http://phpmedia.googlecode.com/svn/trunk/api.php) * [http://code.google.com/p/phpmedia/wiki/API](http://code.google.com/p/phpmedia/wiki/API) Aunque no hice nada, ya tenía mas o menos pensada parte del API. Esta tarde/noche, me he puesto con ello. Con unos resultados muy prometedores. He tenido muy pocos problemas y ha ido todo como esperaba o incluso mejor. Como resultado he sacado una primera versión usable, para PHP5.3\. En la página del proyecto está. Lo que he hecho: * Soporte básico de teclado. Las teclas principales. Detectar pulsaciones o detectar si está pulsada o levantada la tecla. * Inicialización gráfica (ventana o pantalla completa) * Clase Bitmap (bastante avanzada). Permite crear nuevos bitmaps, cargar desde archivos o desde cadenas. Permite hacer recortes, clonar réplicas. Lo que falta: * Mejorar el soporte de teclado. * Soporte para ratón. * Soporte para gamepad. * Todo el tema del audio. * Shaders. Ejemplo de prueba + archivos necesarios: * [http://phpelegante.googlepages.com/test_phpmedia_20.7z](http://phpelegante.googlepages.com/test_phpmedia_20.7z) * [http://phpmedia.googlecode.com/files/php_media2.0-alpha%2Bphp53_min.7z](http://phpmedia.googlecode.com/files/php_media2.0-alpha%2Bphp53_min.7z) [http://phpmedia.googlecode.com/files/phpmedia_dependences.7z](http://phpmedia.googlecode.com/files/phpmedia_dependences.7z) Para probar el ejemplo, bajar todos los archivos. Y ejecutar el archivo test.bat. Teclas del cursor para desplazar la imagen. W/S para acercar/alejar la imagen. A/D para rotar la imagen. ESC para salir del ejemplo. Página del proyecto: [http://code.google.com/p/phpmedia/](http://code.google.com/p/phpmedia/)