PHP-OpenGL source code
C M4 PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
examples
tests
.gitignore
.travis.yml
CREDITS
LICENSE
README.md
config.m4
opengl.php
package2.xml
php_convert.c
php_convert.h
php_glut.c
php_glut.h Old code removed. Fixed some compilation warnings Jun 21, 2016
php_opengl.c
php_opengl.h

README.md

PHP-OpenGL

PHP bindings of the OpenGL and GLUT libraries.

Not all of the previously mentioned API is available on this extension. In order to keep the code small, maintainable and hopefully less buggy, it was decided to support only these subsets:

  • OpenGL: All but the functions that are part of the compatibility profile. (glRotate, glBegin, glLight, ...). Compatibility profile usage is discouraged in other platforms and this extension only let you use the modern (core) GL profile.
  • GLUT: Only the API related to window management, input handling and main loop are available. Other functions (such as the one to render popup menus) are not available for the same reasons given before.

Requirements

  • PHP7
  • OpenGL and FreeGLUT libraries
  • Linux/MacOS (Windows support coming soon)

Installation

Linux

pecl install phpopengl

Or

git clone git://github.com/phpopengl/extension.git --recursive phpopengl
cd phpopengl
phpize
./configure --enable-opengl
make
sudo make install
echo extension=opengl.so | sudo tee /etc/php5/conf.d/opengl.ini

Examples

<?php
glutInit($argc, $argv);

glutInitWindowSize(800, 600);
glutInitWindowPosition(300, 100);
glutCreateWindow('Basic PHP-OpenGL example');

echo glGetString(GL_VENDOR), PHP_EOL;
echo glGetString(GL_RENDERER), PHP_EOL;

glutDisplayFunc(function() {
    glClearColor(0, 0, .2, 1); 
    glClear(GL_COLOR_BUFFER_BIT);
    glutSwapBuffers();
});
glutMainLoop();

License

GPL-3.0+