Giter Club home page Giter Club logo

php-glfw's Introduction

PHP-GLFW

LICENSE PHP Versions Supported GitHub tag issues - php-glfw

PHP-GLFW Tests MacOS Installer Windows Build

WebsiteGetting StartedAPI DocsExamples

A fully-featured OpenGL and GLFW extension for PHP. Batteries included 🔋!

PHP-GLFW allows you to create 2D and 3D real-time applications in PHP. It introduces a whole new set of tools for PHP developers to build graphical applications like games, scientific simulations, user interfaces, and much more.

Currently supports PHP8.x

What is this extension? Features 🚀

PHP-GLFW aims to be a complete solution containing everything you need to start building graphical applications in PHP. It doesn't just provide GLFW library bindings, but also includes OpenGL bindings and a set of essential classes and helpers.

OpenGL

  • Full native support for OpenGL (4.1+ core), bringing GPU-accelerated rendering to PHP.
  • Targets OpenGL 4.1, but can be built for newer versions as well.
  • Support for OpenGL extensions (limited).
  • Mirrors the C API as closely as possible, with adjustments made where required or otherwise nonsensical.
  • Supports ~90% of the full standard; see GLSUPPORT.md for details.

GLFW

This extension includes bindings for the powerful GLFW library, offering a range of amazing features, such as:

  • Multiplatform Window creation and handling (MacOS / Windows / Linux)
  • Support for multiple windows and monitors
  • Real-time user input handling
    • Keyboard and Mouse event handling
    • Joystick input support

PHPGL - Math

PHP-GLFW comes with a built-in mathematics library, written in C and optimized for graphical applications.

  • Supported structs: Vec2, Vec3, Vec4, Mat4, and Quat
  • Includes most common matrix operations, like: lookAt, perspective, inverse, rotate, and more

Integration into the extension offers several advantages:

  • High performance
  • Low memory footprint
  • Overloaded operators for math structs, enabling intuitive operations like:
    use GL\Math\Vec2;
    $v3 = Vec2(15, -5) + Vec2(42, 7); // returns Vec2(57, 2)
  • Some OpenGL functions directly accept math structs as arguments
  1. Read more about math functions

PHPGL - Buffers

This extension also includes a set of buffer objects that internally hold data in native types.

  • Can handle large arrays of data
  • Low memory footprint and very fast
  • Data is stored internally to be directly uploadable to the GPU
  1. Read more about the buffers

PHPGL - Textures

PHP-GLFW supports the loading of images/textures into buffers without requiring an additional extension:

  • Can load common image formats, like jpg, png, tga, bmp, and gif (gd or Imagick is not required)
  • Can write images/textures back to disk
  • Writes data into a BufferInterface object, providing full access to the bitmap
  1. Read more about texture loading

PHPGL - Geometry

PHP-GLFW comes with a .obj wavefront file loader, allowing you to load and parse .obj files. It also provides helpers to generate tangent and bitangent vectors for the loaded geometry. Currently, only triangulated geometry is supported, with no support for quads.

  • Can parse .obj and .mtl files
  • Can generate normal, tangent, and bitangent vectors for the loaded geometry on the fly
  • Allows extraction of separate meshes and groups from the loaded geometry
  • Can group vertices by their material
  • Can reindex extracted meshes to reduce the number of vertices
  1. Read more about geometry loading

How are the bindings achieved?

PHP-GLFW parses the OpenGL specs to generate most of the C extension, instead of porting functions manually. Manual adjustments are made where necessary.

Documentation 📚

  1. Full Documentation
  2. Getting Started Guide
  3. User Guide
  4. API Docs

Examples

glfw-previews

Explore the examples directory to dive into the code.

FlappyPHPant

A very simple Flappy Bird-like game written in PHP.

FlappyPHPant 2D PHP Game

https://github.com/phpgl/flappyphpant

php-chip8

Yet another CHIP-8 emulator, but in PHP!

A CHIP-8 Game Emulator written in PHP

https://github.com/mario-deluna/php-chip8

PHP-Towerdense Game

We are currently developing a 3D game entirely built with PHP, leveraging the power of PHP-GLFW. The game, named PHP-TowerDefense, is open-source and serves as a showcase for the capabilities of PHP-GLFW. Although the game is in active development, it is not yet ready for release.

PHP-TowerDefense Screenshot

Check out the game's repository on GitHub for more information and to follow its progress: https://github.com/phpgl/php-towerdefense

php-pong

Classic Pong game programmed with pure OpenGL wrapped in OOP code.

Classic Pong Game written in PHP

https://github.com/medilies/php-pong

Installation

Please refer to the comprehensive installation guide here: Installation

PHP Version: >= 8.0 While I would love to support older PHP builds, it was just not feasible for this extension.

MacOS

Installer

You can use a simple installer script to install PHP-GLFW:

php -r "copy('https://raw.githubusercontent.com/mario-deluna/php-glfw/master/install/macos-installer.php', 'phpglfw-installer.php');" && php phpglfw-installer.php

Once you see "Installation finished!", you're ready to go!

Manual installation

For a manual approach, ensure you have installed the php-dev, git, and cmake packages. They are required!

git clone https://github.com/mario-deluna/php-glfw
cd php-glfw
sudo phpize && ./configure --enable-glfw
sudo make install

Don't forget to add glfw.so in the php.ini file:

extension="glfw.so"

Linux

cmake is required for the installation. You can skip the first step if it's already installed. Also, make sure that you install the php-dev package, for example, php8.1-dev.

sudo apt install -y cmake git 
git clone https://github.com/mario-deluna/php-glfw
cd php-glfw
sudo phpize && ./configure --enable-glfw
sudo make install

Make sure to add glfw.so in the php.ini file:

extension="glfw.so"

Stubs (IDE Support)

As this is a PHP extension, your editor / IDE does not support auto-completion and doc lookups without some help. We created a composer package you can include as a dev dependency to have full support:

composer require --dev phpgl/ide-stubs

Credits

License

Please see License File for more information.

php-glfw's People

Contributors

mario-deluna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-glfw's Issues

maximize window problem

Hi,
edit: I made it work

By the way I some guy made my game into a flatpak package, my php-glfw game now works on most linux distros according to them!

the custom flatpak repo is on my pc, I can send it to you if you want,
building instructions are on my github repository I got it from him.

Element array buffer support

Hi, can I currently use GL_ELEMENT_ARRAY_BUFFER and glDrawElements? because I tried some hours ago and got an error (I do not remember its detail but I'll reproduce it if needed)

If not, are there any plans to add support?

Problem with initializing VGContext with ANTIALIAS in Coca

Hi,

I have an issue with running example number 11, with vector graphics. I had tested it on multiple configurations (described below), and I found out that code is failing on VGContext class instantiating (examples/11_vector_graphics.php:17).

Error output:

php examples/11_vector_graphics.php
3.3.8 Cocoa NSGL EGL OSMesa dynamic
fish: Job 1, 'php examples/11_vector_graphics…' terminated by signal SIGSEGV (Address boundary error)

Environment:

  • Hardware: MacBook Pro Intel arch
  • OS: Sonoma 14.2 (23C64)
  • PHP versions: 8.3.0 / 8.3.1 / 8.2.14 - installed from brew
  • Cocoa: 3.3.8
  • Installation: by building from cloned source / by simple installer script

glfw at Raspberry Desktop version

Hello!
Today i install X11 desktop for Raspberry and try run from it.
pi@raspberrypi:~/php-glfw/examples $ php 01_triangle.php
3.3.8 X11 GLX EGL OSMesa clock_gettime evdev shared
php: /home/pi/php-glfw/vendor/glfw/src/window.c:954: glfwSetWindowUserPointer: Assertion `window != NULL' failed.
Aborted

My 01_triangle.php that i executed from CLI dont work from Desktop

Issue installing on Mac OS 13.4.1

PHP Version: 8.2.7
The automatic installer failed, so I attempted to install via the manual steps.

Automatic installer output
❯ php phpglfw-installer.php
PHP Warning:  PHP Startup: Unable to load dynamic library 'glfw.so' (tried: /usr/local/lib/php/pecl/20220829/glfw.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file)), /usr/local/lib/php/pecl/20220829/glfw.so.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file))) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'glfw.so' (tried: /usr/local/lib/php/pecl/20220829/glfw.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file)), /usr/local/lib/php/pecl/20220829/glfw.so.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file))) in Unknown on line 0

_____ _____ _____     _____ __    _____ _ _ _
|  _  |  |  |  _  |___|   __|  |  |   __| | | |
|   __|     |   __|___|  |  |  |__|   __| | | |
|__|  |__|__|__|      |_____|_____|__|  |_____|

Installler for macOS

checking requirements...
----------------------------------------------------------------------------------------------------------------------------------------------------------------
 ✓ PHP >= 8.0.0                                                                                                                                            php
 ✓ "phpize" is available                                                                                                                                phpize
 ✓ "git" is available                                                                                                                                      git
 ✓ "cmake" is available                                                                                                                                  cmake
 ✓ "homebrew" is available                                                                                                                            homebrew
 ✓ XCode command line tools are available                                                                                                                xcode
----------------------------------------------------------------------------------------------------------------------------------------------------------------

Everything is ready to go! beginning installation...

Cloning PHP-GLFW...
fatal: destination path 'php-glfw' already exists and is not an empty directory.
****************************************************************************************************************************************************************
Building PHP-GLFW...



Configuring for:
PHP Api Version:         20220829
Zend Module Api No:      20220829
Zend Extension Api No:   420220829
configure.ac:161: warning: The macro `AC_LANG_C' is obsolete.
configure.ac:161: You should run autoupdate.
./lib/autoconf/c.m4:72: AC_LANG_C is expanded from...
build/libtool.m4:2739: _LT_AC_LANG_C_CONFIG is expanded from...
build/libtool.m4:2738: AC_LIBTOOL_LANG_C_CONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: The macro `AC_LANG_C' is obsolete.
configure.ac:161: You should run autoupdate.
./lib/autoconf/c.m4:72: AC_LANG_C is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
build/libtool.m4:561: _LT_AC_LOCK is expanded from...
build/libtool.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from...
build/libtool.m4:2739: _LT_AC_LANG_C_CONFIG is expanded from...
build/libtool.m4:2738: AC_LIBTOOL_LANG_C_CONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:161: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
build/libtool.m4:561: _LT_AC_LOCK is expanded from...
build/libtool.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from...
build/libtool.m4:2739: _LT_AC_LANG_C_CONFIG is expanded from...
build/libtool.m4:2738: AC_LIBTOOL_LANG_C_CONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe
build/libtool.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from...
build/libtool.m4:2739: _LT_AC_LANG_C_CONFIG is expanded from...
build/libtool.m4:2738: AC_LIBTOOL_LANG_C_CONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe
build/libtool.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from...
build/libtool.m4:2739: _LT_AC_LANG_C_CONFIG is expanded from...
build/libtool.m4:2738: AC_LIBTOOL_LANG_C_CONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me:${as_lineno-$LINENO}: WARNING: output file \`$ofile' does not exist
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me: WARNING: output file \`$ofile' does not exist
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me:${as_lineno-$LINENO}: WARNING: output file \`$ofile' does not look like a libtool script
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me: WARNING: output file \`$ofile' does not look like a libtool script
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me:${as_lineno-$LINENO}: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: tag name \"$tagname\" already exists
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: The macro `AC_LANG_CPLUSPLUS' is obsolete.
configure.ac:161: You should run autoupdate.
./lib/autoconf/c.m4:262: AC_LANG_CPLUSPLUS is expanded from...
build/libtool.m4:2821: _LT_AC_LANG_CXX_CONFIG is expanded from...
build/libtool.m4:2820: AC_LIBTOOL_LANG_CXX_CONFIG is expanded from...
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe
build/libtool.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from...
build/libtool.m4:2821: _LT_AC_LANG_CXX_CONFIG is expanded from...
build/libtool.m4:2820: AC_LIBTOOL_LANG_CXX_CONFIG is expanded from...
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level
configure.ac:161: warning: back quotes and double quotes must not be escaped in: $as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe
build/libtool.m4:1185: AC_LIBTOOL_SYS_HARD_LINK_LOCKS is expanded from...
build/libtool.m4:2821: _LT_AC_LANG_CXX_CONFIG is expanded from...
build/libtool.m4:2820: AC_LIBTOOL_LANG_CXX_CONFIG is expanded from...
build/libtool.m4:1929: _LT_AC_TAGCONFIG is expanded from...
build/libtool.m4:70: AC_LIBTOOL_SETUP is expanded from...
build/libtool.m4:52: _AC_PROG_LIBTOOL is expanded from...
build/libtool.m4:39: AC_PROG_LIBTOOL is expanded from...
configure.ac:161: the top level



checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin22.5.0
checking host system type... x86_64-apple-darwin22.5.0
checking target system type... x86_64-apple-darwin22.5.0
checking for PHP prefix... /usr/local/Cellar/php/8.2.7_1
checking for PHP includes... -I/usr/local/Cellar/php/8.2.7_1/include/php -I/usr/local/Cellar/php/8.2.7_1/include/php/main -I/usr/local/Cellar/php/8.2.7_1/include/php/TSRM -I/usr/local/Cellar/php/8.2.7_1/include/php/Zend -I/usr/local/Cellar/php/8.2.7_1/include/php/ext -I/usr/local/Cellar/php/8.2.7_1/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/php/8.2.7_1/pecl/20220829
checking for PHP installed headers prefix... /usr/local/Cellar/php/8.2.7_1/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable glfw support... yes, shared
checking for glfw library... yes, shared
checking for os target... building for MacOS
checking for glfw installation... GLFW lib not found, trying to build
-- Using Cocoa for window creation
CMake Error at CMakeLists.txt:353 (add_subdirectory):
  add_subdirectory given source "docs" which is not an existing directory.


-- Configuring incomplete, errors occurred!
configure: error: GLFW lib could not be located or build
****************************************************************************************************************************************************************
Checking if glfw module is already loaded...
PHP Warning:  PHP Startup: Unable to load dynamic library 'glfw.so' (tried: /usr/local/lib/php/pecl/20220829/glfw.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file)), /usr/local/lib/php/pecl/20220829/glfw.so.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file))) in Unknown on line 0
Adding glfw extension to php.ini
PHP Warning:  PHP Startup: Unable to load dynamic library 'glfw.so' (tried: /usr/local/lib/php/pecl/20220829/glfw.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file)), /usr/local/lib/php/pecl/20220829/glfw.so.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file))) in Unknown on line 0
****************************************************************************************************************************************************************
PHP Warning:  PHP Startup: Unable to load dynamic library 'glfw.so' (tried: /usr/local/lib/php/pecl/20220829/glfw.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so' (no such file)), /usr/local/lib/php/pecl/20220829/glfw.so.so (dlopen(/usr/local/lib/php/pecl/20220829/glfw.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file), '/usr/local/lib/php/pecl/20220829/glfw.so.so' (no such file))) in Unknown on line 0

Installation failed!
Manual installation output
✦ ❯ ./configure --enable-glfw
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin22.5.0
checking host system type... x86_64-apple-darwin22.5.0
checking target system type... x86_64-apple-darwin22.5.0
checking for PHP prefix... /usr/local/Cellar/php/8.2.7_1
checking for PHP includes... -I/usr/local/Cellar/php/8.2.7_1/include/php -I/usr/local/Cellar/php/8.2.7_1/include/php/main -I/usr/local/Cellar/php/8.2.7_1/include/php/TSRM -I/usr/local/Cellar/php/8.2.7_1/include/php/Zend -I/usr/local/Cellar/php/8.2.7_1/include/php/ext -I/usr/local/Cellar/php/8.2.7_1/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/php/8.2.7_1/pecl/20220829
checking for PHP installed headers prefix... /usr/local/Cellar/php/8.2.7_1/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable glfw support... yes, shared
checking for glfw library... yes, shared
checking for os target... building for MacOS
checking for glfw installation... GLFW lib not found, trying to build
-- Using Cocoa for window creation
CMake Error at CMakeLists.txt:353 (add_subdirectory):
  add_subdirectory given source "docs" which is not an existing directory.


-- Configuring incomplete, errors occurred!
configure: error: GLFW lib could not be located or build

issue with glValidateProgram

This is my code

    private function linkProgram(int $vertexShader, int $fragShader): void
    {
        glAttachShader($this->program, $vertexShader);
        glAttachShader($this->program, $fragShader);

        glValidateProgram($this->program);
        glGetProgramiv($this->program, GL_VALIDATE_STATUS, $validationSuccess);
        if (GL_TRUE !== $validationSuccess) {
            glGetShaderiv($this->program, GL_INFO_LOG_LENGTH, $length);
            var_dump($length);
            var_dump(glGetShaderInfoLog($this->program, $length));
            throw new Exception('Shader program is not valid.');
        }

        glLinkProgram($this->program);
        glGetProgramiv($this->program, GL_LINK_STATUS, $linkSuccess);
        if (! $linkSuccess) {
            throw new Exception('Shader program could not be linked.');
        }
    }

First of all, the code works fine if I discard the section of glValidateProgram, so I do not know why $validationSuccess is not truthy.

Then we to the part about getting logs. Here I do not understand why the value of $length is negative (see dumps below).

int(-696267152)
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 18446744073013284464 bytes) in C:\Dev\trying-php-glfw\src\ShaderProgram.php on line 69

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 18446744073013284464 bytes) in C:\Dev\trying-php-glfw\src\ShaderProgram.php on line 69

extra support

Hi Mario do you have a buy me coffee link for extra support ?

requirements for the glfwInit() command

I try to execute 01_triangle.php example at Raspberry 3B+, Bookworm version.
I get exception "GLFW could not be initialized!".

Can i init from CLI mode?

my php version:
pi@raspberrypi:/php-glfw/examples $ php -v
PHP 8.3.0 (cli) (built: Nov 25 2023 14:38:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
with Zend OPcache v8.3.0, Copyright (c), by Zend Technologies
GLFW installed:
pi@raspberrypi:
/php-glfw/examples $ php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
glfw
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

My finish task is real image render as i create GD image and transfer it to client.
//image generate
......
header ("Content-type: image/png");
imagepng($image);

Hello again

The examples and instructions are very neat I hope there can be more variety added to them
I havent used opengl before but I know php well, I am sort of bruteforcing solutions and learning at the same time

I still havent figured out how to add objects while in the loop

and without going into shaders and complicated stuff it would be great if I could just add flat surface textures to objects and a simple point lamp in the air

Can this be ported to ipad iphone and android you think?

Where would people that want to talk about this hang out ? thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.