Jump to content


Photo

PHP-SDL


  • Please log in to reply
No replies to this topic

#1 xdracox

xdracox
  • Members
  • PipPip
  • Member
  • 11 posts
  • LocationTexas, USA

Posted 21 January 2006 - 04:22 AM

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:
/** 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);
}

And so far, I have this for SDL_GetVideoSurface()
/** 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);
}

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...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users