[Gridflow-cvs] [svn] commit: r3314 - in /trunk/format: opengl.c quartz.m sdl.c x11.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Mar 28 07:35:37 EDT 2008


Author: matju
Date: Fri Mar 28 07:35:36 2008
New Revision: 3314

Log:
switch from Ruby-wrapped Clock to plain t_clock.

Modified:
    trunk/format/opengl.c
    trunk/format/quartz.m
    trunk/format/sdl.c
    trunk/format/x11.c

Modified: trunk/format/opengl.c
==============================================================================
--- trunk/format/opengl.c (original)
+++ trunk/format/opengl.c Fri Mar 28 07:35:36 2008
@@ -47,6 +47,7 @@
 	P<BitPacking> bit_packing;
 	P<Dim> dim;
 	uint8 *buf;
+	t_clock *clock;
 	\decl void call ();
 	\decl void initialize (Symbol mode);
 	\decl 0 close ();
@@ -79,7 +80,7 @@
 	if(!setjmp(hack)) glutMainLoop();
 	//done
 
-	IEVAL(rself,"@clock.delay 100");
+	clock_delay(clock,100);
 }
 
 \def 0 resize_window (int sx, int sy) {
@@ -133,7 +134,7 @@
 } GRID_END
 
 \def 0 close () {
-	IEVAL(rself,"@clock.unset");
+	clock_unset(clock);
 	if (gltex) glDeleteTextures(1, (GLuint*)&gltex);
 	if (buf) delete buf;
 	in_use=false;
@@ -155,11 +156,11 @@
 	
 	gltex = 0;
 	glEnable(GL_TEXTURE_2D);
-	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); 
+	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
 	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
 	glClear(GL_COLOR_BUFFER_BIT);
 	glDisable(GL_ALPHA_TEST);
-	glDisable(GL_CULL_FACE);         
+	glDisable(GL_CULL_FACE);
 	glDisable(GL_DITHER);
 	glDisable(GL_DEPTH_TEST);
 	glDisable(GL_LIGHTING);
@@ -167,8 +168,8 @@
 
 	uint32 mask[3] = {0xff000000,0x00ff0000,0x0000ff00};
 	bit_packing = new BitPacking(4,4,3,mask);
-	IEVAL(rself,"@clock = Clock.new self; @clock.delay 0");
-	gfpost("@clock = Clock.new self");
+	clock = clock_new(this,(t_method)FormatOpenGL_call);
+	clock_delay(clock,0);
 }
 
 \classinfo {install_format("#io.opengl",2,"");}

Modified: trunk/format/quartz.m
==============================================================================
--- trunk/format/quartz.m (original)
+++ trunk/format/quartz.m Fri Mar 28 07:35:36 2008
@@ -119,6 +119,7 @@
 	NSWindowController *wc;
 	GFView *widget; /* GridFlow's Cocoa widget */
 	NSDate *distantFuture;
+	t_clock *clock;
 	\decl void initialize (Symbol mode);
 	\decl 0 delete_m ();
 	\decl 0 close ();
@@ -140,8 +141,9 @@
 	}
 	[NSApp updateWindows];
 	[this->window flushWindowIfNeeded];
-	IEVAL(rself,"@clock.delay 20");
-}
+	clock_delay(clock,20);
+}
+FormatQuartz_call(FormatQuartz *self) {self->call(0,0);}
 
 template <class T, class S>
 static void convert_number_type(int n, T *out, S *in) {
@@ -198,7 +200,7 @@
 	[window orderFrontRegardless];
 	wc = [[NSWindowController alloc]
 		initWithWindow: window];
-	IEVAL(rself,"@clock = Clock.new self");
+	clock = clock_new(this,(t_method)FormatQuartz_call);
 	[window makeFirstResponder: widget];
 	gfpost("mainWindow = %08lx",(long)[NSApp mainWindow]);
 	gfpost(" keyWindow = %08lx",(long)[NSApp keyWindow]);
@@ -210,7 +212,9 @@
 	[window autorelease];
 }
 \def 0 close () {
-	IEVAL(rself,"@clock.unset");
+	clock_unset(clock);
+	clock_free(clock);
+	clock = 0;
 	SUPER;
 	[window autorelease];
 	[window setReleasedWhenClosed: YES];

Modified: trunk/format/sdl.c
==============================================================================
--- trunk/format/sdl.c (original)
+++ trunk/format/sdl.c Fri Mar 28 07:35:36 2008
@@ -36,6 +36,7 @@
 	SDL_Surface *screen;
 	P<BitPacking> bit_packing;
 	P<Dim> dim;
+	t_clock *clock;
 	void resize_window (int sx, int sy);
 	void call ();
 	\decl void initialize (Symbol mode);
@@ -46,8 +47,9 @@
 void FormatSDL::call() {
 	SDL_Event event;
 	while(SDL_PollEvent(&event)) {}
-	IEVAL(rself,"@clock.delay 20");
+	clock_delay(clock,20);
 }
+void FormatSDL_call(FormatSDL *self) {self->call();}
 
 void FormatSDL::resize_window (int sx, int sy) {
 	dim = new Dim(sy,sx,3);
@@ -81,7 +83,9 @@
 } GRID_END
 
 \def 0 close () {
-	IEVAL(rself,"@clock.unset");
+	clock_unset(clock);
+	clock_free(clock);
+	clock = 0;
 	in_use=false;
 }
 
@@ -103,7 +107,7 @@
 		break;
 	default: RAISE("%d bytes/pixel: how do I deal with that?",f->BytesPerPixel); break;
 	}
-	IEVAL(rself,"@clock = Clock.new self");
+	clock = clock_new(this,(t_method)FormatSDL_call);
 }
 
 \end class FormatSDL {install_format("#io.sdl",2,"");}

Modified: trunk/format/x11.c
==============================================================================
--- trunk/format/x11.c (original)
+++ trunk/format/x11.c Fri Mar 28 07:35:36 2008
@@ -69,6 +69,7 @@
 	P<Dim> dim;
 	bool lock_size;
 	bool override_redirect;
+	t_clock *clock;
 #ifdef HAVE_X11_SHARED_MEMORY
 	XShmSegmentInfo *shm_info; /* to share memory with X11/Unix */
 #endif
@@ -81,7 +82,7 @@
 #endif
 	FormatX11 () : transfer(0), use_stripes(false), 
 	window(0), ximage(0), image(0), is_owner(true),
-	dim(0), lock_size(false), override_redirect(false)
+	dim(0), lock_size(false), override_redirect(false), clock(0)
 #ifdef HAVE_X11_SHARED_MEMORY
 		, shm_info(0)
 #endif
@@ -99,7 +100,7 @@
 	\decl void initialize (...);
 	\decl 0 bang ();
 	\decl 0 close ();
-	\decl void call ();
+	void call ();
 	\decl 0 out_size (int sy, int sx);
 	\decl 0 setcursor (int shape);
 	\decl 0 hidecursor ();
@@ -168,7 +169,7 @@
 	send_out(COUNT(argv),argv);
 }
 
-\def void call() {
+void FormatX11::call() {
 	XEvent e;
 	for (;;) {
 		int xpending = XEventsQueued(display, QueuedAfterFlush);
@@ -177,9 +178,7 @@
 		switch (e.type) {
 		case Expose:{
 			XExposeEvent *ex = (XExposeEvent *)&e;
-			if (rb_ivar_get(rself,SI(@mode)) == SYM(out)) {
-				show_section(ex->x,ex->y,ex->width,ex->height);
-			}
+			if (mode==2) show_section(ex->x,ex->y,ex->width,ex->height);
 		}break;
 		case ButtonPress:{
 			XButtonEvent *eb = (XButtonEvent *)&e;
@@ -218,8 +217,9 @@
 		case ConfigureNotify:break; // as if we cared
 		}
 	}
-	IEVAL(rself,"@clock.delay 20");
-}
+	clock_delay(clock,20);
+}
+void FormatX11_call(FormatX11 *p) {p->call();}
 
 \def 0 bang () {
 	XGetSubImage(display, window, 0, 0, dim->get(1), dim->get(0), (unsigned)-1, ZPixmap, ximage, 0, 0);
@@ -419,7 +419,7 @@
 \def 0 close () {
 	if (!this) RAISE("stupid error: trying to close display NULL. =)");
 	bit_packing=0;
-	IEVAL(rself,"@clock.unset");
+	clock_unset(clock);
 	if (is_owner) XDestroyWindow(display,window);
 	XSync(display,0);
 	dealloc_image();
@@ -656,7 +656,8 @@
 	} break;
 	default: { RAISE("huh?"); }
 	}
-	IEVAL(rself,"@clock = Clock.new self; @clock.delay 0");
+	clock = clock_new(this,(t_method)FormatX11_call);
+	clock_delay(clock,0);
 	show_section(0,0,sx,sy);
 }
 



More information about the Gridflow-cvs mailing list