Jump to content

PHP-SDL


xdracox

Recommended Posts

So I decided to make an SDL module for PHP. I have had to adjust to somethings since PHP is made in C. But that's all taken care of. If any of you know SDL, you know there is a function called SDL_GetVideoSurface(), this is the function I am having trouble with.

I created SDL_SetVideoMode() like this:
[code]/** setup a video mode with the specified width, height, and bpp
*    @param    long width
*    @param    long height
*    @param    long bpp
*    @param    long flags
*    @return    resource (SDL_Surface)
*/
PHP_FUNCTION(sdl_setvideomode)
{
    long width, height, bpp, flags;
    SDL_Surface *surface;
    
    if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &width, &height, &bpp, &flags) == FAILURE )
        return;
    
    surface = SDL_SetVideoMode(width, height, bpp, flags);
    
    if ( !surface )
    {
        php_error(E_WARNING, "%s() failed to set video mode to %dx%dx%d: %s",
            get_active_function_name(TSRMLS_C), width, height, bpp, SDL_GetError());
        RETURN_FALSE;
    }
    
    ZEND_REGISTER_RESOURCE(return_value, surface, le_surface);
}[/code]

And so far, I have this for SDL_GetVideoSurface()
[code]/** returns a handle to the current display surface
*    @return    resource (SDL_Surface)
*/
PHP_FUNCTION(sdl_getvideosurface)
{
    SDL_Surface *screen;
    zval **surface_handle;
    
    screen = SDL_GetVideoSurface();
    if ( !screen )
    {
        php_error(E_WARNING, "%s() failed to get current display surface: %s",
            get_active_function_name(TSRMLS_C), SDL_GetError());
        RETURN_NULL();
    }
    
    // ZEND_FETCH_RESOURCE(screen, SDL_Surface *, surface_handle, -1, le_surface_name, le_surface);
}[/code]

So, my question is, what exactly do the arguments of ZEND_FETCH_RESOURCE() need to be?

EDIT: This seems to be the first real Core PHP Hacking question in a while...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.