xdracox Posted January 21, 2006 Share Posted January 21, 2006 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 https://forums.phpfreaks.com/topic/3237-php-sdl/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.