[PD-cvs] externals/pdp/modules/image_io pdp_sdl.c,1.3,1.4

Tom Schouten doelie at users.sourceforge.net
Fri Sep 1 18:46:26 CEST 2006


Update of /cvsroot/pure-data/externals/pdp/modules/image_io
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18389/modules/image_io

Modified Files:
	pdp_sdl.c 
Log Message:
pdp: sdl fixes (delayed open)

Index: pdp_sdl.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pdp/modules/image_io/pdp_sdl.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pdp_sdl.c	16 Dec 2005 01:05:33 -0000	1.3
--- pdp_sdl.c	1 Sep 2006 16:46:24 -0000	1.4
***************
*** 44,49 ****
  /* initial image dimensions */
  
! #define WINWIDTH 640
! #define WINHEIGHT 480
  #define OVERLAYWIDTH 320
  #define OVERLAYHEIGHT 240
--- 44,52 ----
  /* initial image dimensions */
  
! //#define WINWIDTH 640
! //#define WINHEIGHT 480
! #define WINWIDTH 320
! #define WINHEIGHT 240
! 
  #define OVERLAYWIDTH 320
  #define OVERLAYHEIGHT 240
***************
*** 58,73 ****
      int x_surface_flags;
  	
      int x_surface_width;
      int x_surface_height;
- 
      unsigned int x_overlay_width;
      unsigned int x_overlay_height;
!     
  
      t_outlet *x_outlet;
  
  
  } t_pdp_sdl;
  
  static t_pdp_sdl *sdl_singleton; // only one instance allowed
  
--- 61,84 ----
      int x_surface_flags;
  	
+     // current values
      int x_surface_width;
      int x_surface_height;
      unsigned int x_overlay_width;
      unsigned int x_overlay_height;
! 
!     // object creation args (wanted)
!     int x_w;
!     int x_h;
  
      t_outlet *x_outlet;
  
  
+ 
  } t_pdp_sdl;
  
+ 
+ static int pdp_sdl_open(t_pdp_sdl *x);
+ #define IF_NO_OVERLAY(x) if (!pdp_sdl_open(x))
+ 
  static t_pdp_sdl *sdl_singleton; // only one instance allowed
  
***************
*** 146,149 ****
--- 157,161 ----
  
  static void poll_events(t_pdp_sdl *x){
+     IF_NO_OVERLAY(x) { return; }
  
      SDL_Event event;
***************
*** 201,204 ****
--- 213,218 ----
  static void input_0(t_pdp_sdl *x, t_symbol *s, t_floatarg f) {
  
+     IF_NO_OVERLAY(x) { return; }
+ 
      int input_packet = (int)f;
      if (s == gensym("register_ro")){
***************
*** 236,240 ****
  		
  	    else {
! 		pdp_post("SDL: error creating overlay");
  	    }
  		
--- 250,254 ----
  		
  	    else {
! 		PDP_ASSERT(0);
  	    }
  		
***************
*** 259,267 ****
  t_class *pdp_sdl_class;
  
! void *pdp_sdl_new(t_floatarg width, t_floatarg height) {
  
      t_pdp_sdl *x;
-     int w = (int)width;
-     int h = (int)height;
  
      if (sdl_singleton) {
--- 273,307 ----
  t_class *pdp_sdl_class;
  
! 
! static int pdp_sdl_open(t_pdp_sdl *x){
! 
!     if (x->x_overlay) return -1;
! 
!     /* try to create a surface */
!     create_surface(x, x->x_w ? x->x_w : WINWIDTH, x->x_h ? x->x_h : WINHEIGHT, 0);
!     if (!x->x_surface){
! 	pdp_post("Can't create surface");
! 	goto error_cleanup;
!     }
! 
!     /* try to create overlay */
!     check_overlay(x, OVERLAYHEIGHT, OVERLAYWIDTH);
!     if (!x->x_overlay){
! 	pdp_post("Can't create overlay");
! 	goto error_cleanup;
!     }
!     return -1;
! 
! 
!   error_cleanup:
!     pdp_sdl_free(x);
!     return 0;
! 
! }
! 
! 
! static void *pdp_sdl_new(t_floatarg width, t_floatarg height) {
  
      t_pdp_sdl *x;
  
      if (sdl_singleton) {
***************
*** 283,309 ****
      x->x_surface = NULL;
      x->x_overlay = NULL;
  
      x->x_outlet = outlet_new(&x->x_obj, &s_anything);
  
- 
-     /* try to create a surface */
-     create_surface(x, w ? w : WINWIDTH, h ? h : WINHEIGHT, 0);
-     if (!x->x_surface){
- 	pdp_post("Can't create surface");
- 	goto error_cleanup;
-     }
- 
-     /* try to create overlay */
-     check_overlay(x, 320, 240);
-     if (!x->x_overlay){
- 	pdp_post("Can't create overlay");
- 	goto error_cleanup;
-     }
- 
      return (void *)x;
  
-   error_cleanup:
-     pdp_sdl_free(x);
-     return (void *)0;
  }
  
--- 323,333 ----
      x->x_surface = NULL;
      x->x_overlay = NULL;
+     x->x_w = (int)width;
+     x->x_h = (int)height;
  
      x->x_outlet = outlet_new(&x->x_obj, &s_anything);
  
      return (void *)x;
  
  }
  





More information about the Pd-cvs mailing list