Jump to content


This topic is now archived and is closed to further replies.



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)
    long width, height, bpp, flags;
    SDL_Surface *surface;
    if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &width, &height, &bpp, &flags) == FAILURE )
    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());
    ZEND_REGISTER_RESOURCE(return_value, surface, le_surface);

And so far, I have this for SDL_GetVideoSurface()
[code]/** returns a handle to the current display surface
*    @return    resource (SDL_Surface)
    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());
    // 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...

Share this post

Link to post
Share on other sites


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.