@@ -202,6 +202,42 @@ PHP_FUNCTION(SDL_RenderCopy)
202202}
203203/* }}} */
204204
205+ PHP_FUNCTION (SDL_RenderCopyEx )
206+ {
207+ zval * z_renderer , * z_texture ;
208+ zval * z_srcrect , * z_dstrect ;
209+ zval * z_center ;
210+ SDL_Renderer * renderer = NULL ;
211+ SDL_Texture * texture = NULL ;
212+ SDL_Rect * srcrect = NULL , * dstrect = NULL ;
213+ double angle ;
214+ SDL_Point * center = NULL ;
215+ long flip ;
216+
217+ if ( zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "zzO!O!dO!l" , & z_renderer , & z_texture , & z_srcrect , get_php_sdl_rect_ce (), & z_dstrect , get_php_sdl_rect_ce (), & angle , & z_center , get_php_sdl_point_ce (), & flip ) == FAILURE ) {
218+ WRONG_PARAM_COUNT ;
219+ }
220+
221+ renderer = (SDL_Renderer * )zend_fetch_resource (Z_RES_P (z_renderer ), SDL_RENDERER_RES_NAME , le_sdl_renderer );
222+ texture = (SDL_Texture * )zend_fetch_resource (Z_RES_P (z_texture ), SDL_TEXTURE_RES_NAME , le_sdl_texture );
223+
224+ if (z_srcrect != NULL && Z_TYPE_P (z_srcrect ) != IS_NULL ) {
225+ srcrect = (SDL_Rect * )emalloc (sizeof (SDL_Rect ));
226+ zval_to_sdl_rect (z_srcrect , srcrect TSRMLS_CC );
227+ }
228+ if (z_dstrect != NULL && Z_TYPE_P (z_dstrect ) != IS_NULL ) {
229+ dstrect = (SDL_Rect * )ecalloc (1 , sizeof (SDL_Rect ));
230+ zval_to_sdl_rect (z_dstrect , dstrect TSRMLS_CC );
231+ }
232+ if (z_center != NULL && Z_TYPE_P (z_center ) != IS_NULL ) {
233+ center = (SDL_Point * )ecalloc (1 , sizeof (SDL_Point ));
234+ zval_to_sdl_point (z_center , center TSRMLS_CC );
235+ }
236+
237+ RETURN_LONG (SDL_RenderCopyEx (renderer , texture , srcrect , dstrect , angle , center , (Uint32 )flip ));
238+ }
239+ /* }}} */
240+
205241/* {{{ MINIT */
206242PHP_MINIT_FUNCTION (sdl_render )
207243{
@@ -210,6 +246,10 @@ PHP_MINIT_FUNCTION(sdl_render)
210246 REGISTER_LONG_CONSTANT ("SDL_RENDERER_PRESENTVSYNC" , SDL_RENDERER_PRESENTVSYNC , CONST_CS | CONST_PERSISTENT );
211247 REGISTER_LONG_CONSTANT ("SDL_RENDERER_TARGETTEXTURE" , SDL_RENDERER_TARGETTEXTURE , CONST_CS | CONST_PERSISTENT );
212248
249+ REGISTER_LONG_CONSTANT ("SDL_FLIP_NONE" , SDL_FLIP_NONE , CONST_CS | CONST_PERSISTENT );
250+ REGISTER_LONG_CONSTANT ("SDL_FLIP_HORIZONTAL" , SDL_FLIP_HORIZONTAL , CONST_CS | CONST_PERSISTENT );
251+ REGISTER_LONG_CONSTANT ("SDL_FLIP_VERTICAL" , SDL_FLIP_VERTICAL , CONST_CS | CONST_PERSISTENT );
252+
213253 le_sdl_renderer = zend_register_list_destructors_ex (NULL , NULL , SDL_RENDERER_RES_NAME , module_number );
214254 le_sdl_texture = zend_register_list_destructors_ex (NULL , NULL , SDL_TEXTURE_RES_NAME , module_number );
215255
0 commit comments