Beispiel #1
0
static void line_stop(t_line *x)
{
    if (pd_compatibilitylevel >= 48)
    {
        if (clock_getsystime() >= x->x_targettime)
            x->x_setval = x->x_targetval;
        else x->x_setval += x->x_1overtimediff *
            (clock_getsystime() - x->x_prevtime) *
                (x->x_targetval - x->x_setval);
    }
    x->x_targetval = x->x_setval;
    clock_unset(x->x_clock);
}
Beispiel #2
0
/////////////////////////////////////////////////////////
// startRendering
//
/////////////////////////////////////////////////////////
void GemMan :: startRendering()
{
  if (!m_windowState)
    {
      error("GEM: Create window first!");
      return;
    }
    
  if (m_rendering)
    return;
    
  logpost(NULL, 3, "GEM: Start rendering");
    
  // set up all of the gemheads
  renderChain(gensym("__gem_render"), true);
  renderChain(gensym("__gem_render_osd"), true);

  m_rendering = 1;
    
  // if only single buffering then just return
  if (GemMan::m_buffer == 1)
    return;

  m_lastRenderTime = clock_getsystime();
  render(NULL);
}
Beispiel #3
0
static void line_float(t_line *x, t_float f)
{
    double timenow = clock_getsystime();
    if (x->x_gotinlet && x->x_in1val > 0)
    {
        if (timenow > x->x_targettime) x->x_setval = x->x_targetval;
        else x->x_setval = x->x_setval + x->x_1overtimediff *
            (timenow - x->x_prevtime)
            * (x->x_targetval - x->x_setval);
        x->x_prevtime = timenow;
        x->x_targettime = clock_getsystimeafter(x->x_in1val);
        x->x_targetval = f;
        line_tick(x);
        x->x_gotinlet = 0;
        x->x_1overtimediff = 1./ (x->x_targettime - timenow);
        if (x->x_grain <= 0)
            x->x_grain = DEFAULTLINEGRAIN;
        clock_delay(x->x_clock,
            (x->x_grain > x->x_in1val ? x->x_in1val : x->x_grain));

    }
    else
    {
        clock_unset(x->x_clock);
        x->x_targetval = x->x_setval = f;
        outlet_float(x->x_obj.ob_outlet, f);
    }
    x->x_gotinlet = 0;
}
Beispiel #4
0
static void timer_tempo(t_timer *x, t_symbol *unitname, t_floatarg tempo)
{
    x->x_moreelapsed +=  clock_gettimesincewithunits(x->x_settime,
        x->x_unit, x->x_samps);
    x->x_settime = clock_getsystime();
    parsetimeunits(x, tempo, unitname, &x->x_unit, &x->x_samps);
}
Beispiel #5
0
static void tabwrite_tick(t_tabwrite *x)
{
    t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class);
    if (!a) bug("tabwrite_tick");
    else garray_redraw(a);
    x->x_set = 0;
    x->x_updtime = clock_getsystime();
}
Beispiel #6
0
static void *tabwrite_new(t_symbol *s)
{
    t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class);
    x->x_ft1 = 0;
    x->x_arrayname = s;
    x->x_updtime = clock_getsystime();
    x->x_clock = clock_new(x, (t_method)tabwrite_tick);
    floatinlet_new(&x->x_obj, &x->x_ft1);
    return (x);
}
Beispiel #7
0
static void xeqithook_autodelay(t_xeqit *it, int argc, t_atom *argv)
{
    t_xeq *x = (t_xeq *)it->i_owner;
    if (x->x_clock)
    {
	clock_delay(x->x_clock,
		    x->x_clockdelay = it->i_playloc.l_delay * x->x_tempo);
	x->x_whenclockset = clock_getsystime();
    }
}
Beispiel #8
0
void xeq_start(t_xeq *x)
{
    if (x->x_clock)
    {
#if 0
	post ("start delay %f", x->x_autoit.i_playloc.l_delay);
#endif
 	clock_delay(x->x_clock, x->x_clockdelay =
		    x->x_autoit.i_playloc.l_delay * x->x_tempo);
	x->x_whenclockset = clock_getsystime();
    }
}
Beispiel #9
0
static void *line_new(t_floatarg f, t_floatarg grain)
{
    t_line *x = (t_line *)pd_new(line_class);
    x->x_targetval = x->x_setval = f;
    x->x_gotinlet = 0;
    x->x_1overtimediff = 1;
    x->x_clock = clock_new(x, (t_method)line_tick);
    x->x_targettime = x->x_prevtime = clock_getsystime();
    x->x_grain = grain;
    outlet_new(&x->x_obj, gensym("float"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
    floatinlet_new(&x->x_obj, &x->x_grain);
    return (x);
}
Beispiel #10
0
static void *step_new(t_floatarg f, t_floatarg step, t_floatarg grain)
{
    t_step *x = (t_step *)pd_new(step_class);
    x->x_targetval = x->x_setval = f;
    x->x_gotinlet = 0;
    x->x_1overtimediff = 1;
    x->x_clock = clock_new(x, (t_method)step_tick);
    x->x_targettime = x->x_prevtime = clock_getsystime();
    if (grain <= 0) grain = 20;
    x->x_grain = grain;
    if (step <= 0) step = 1;
    x->x_step = step;
    outlet_new(&x->x_obj, gensym("float"));
    inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1"));
	inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2"));
    return (x);
}
Beispiel #11
0
static void line_tick(t_line *x)
{
    double timenow = clock_getsystime();
    double msectogo = - clock_gettimesince(x->x_targettime);
    if (msectogo < 1E-9)
    {
        outlet_float(x->x_obj.ob_outlet, x->x_targetval);
    }
    else
    {
        outlet_float(x->x_obj.ob_outlet,
            x->x_setval + x->x_1overtimediff * (timenow - x->x_prevtime)
                * (x->x_targetval - x->x_setval));
        clock_delay(x->x_clock,
            (x->x_grain > msectogo ? msectogo : x->x_grain));
    }
}
Beispiel #12
0
void xeq_tempo(t_xeq *x, t_floatarg f)
{
    float newtempo;
    if (f == 0) f = 1;  /* tempo message without argument (FIXME) */
    else if (f < 1e-20) f = 1e-20;
    else if (f > 1e20) f = 1e20;
    newtempo = 1./f;
    if (x->x_whenclockset != 0)
    {
    	float elapsed = clock_gettimesince(x->x_whenclockset);
    	float left = x->x_clockdelay - elapsed;
    	if (left < 0) left = 0;
    	else left *= newtempo / x->x_tempo;
    	clock_delay(x->x_clock, x->x_clockdelay = left);
	x->x_whenclockset = clock_getsystime();
    }
    x->x_tempo = newtempo;
}
Beispiel #13
0
static void *loadmess_new(t_symbol *s, int argc, t_atom *argv)
{
    t_loadmess *x = (t_loadmess *)eobj_new(loadmess_class);
    if(x)
    {
        x->l_time = clock_getsystime();
        if(argc && argv)
        {
            x->l_argc = (size_t)argc;
            x->l_argv = (t_atom *)malloc(x->l_argc * sizeof(t_atom));
            if(x->l_argv)
            {
                memcpy(x->l_argv, argv, sizeof(t_atom) * x->l_argc);
                if(x->l_argc == 1)
                {
                    if(atom_gettype(argv) == A_FLOAT)
                        x->l_out = outlet_new((t_object *)x, &s_float);
                    else if (atom_gettype(argv) == A_SYMBOL)
                        x->l_out = outlet_new((t_object *)x, &s_symbol);
                }
                else
                {
                    if(atom_gettype(argv) == A_FLOAT)
                        x->l_out = outlet_new((t_object *)x, &s_list);
                    else if (atom_gettype(argv) == A_SYMBOL)
                        x->l_out = outlet_new((t_object *)x, &s_anything);
                }
            }
            else
            {
                pd_error(x, "can't allocate memory.");
            }
        }
        else
        {
            x->l_argc = 0;
            x->l_argv = NULL;
            x->l_out = outlet_new((t_object *)x, &s_bang);
        }
    }
    
    return (x);
}
Beispiel #14
0
static void *patcherinfos_new(t_symbol *s, int argc, t_atom *argv)
{
    t_patcherinfos *x = (t_patcherinfos *)eobj_new(patcherinfos_class);
    if(x)
    {
        if(canvas_getcurrent())
        {
            x->f_canvas = glist_getcanvas(canvas_getcurrent());
        }
        else
        {
            x->f_canvas = NULL;
        }
        x->f_out_name = outlet_new((t_object *)x, &s_symbol);
        x->f_out_path = outlet_new((t_object *)x, &s_symbol);
        x->f_out_coords = outlet_new((t_object *)x, &s_list);
        x->f_time = clock_getsystime();
    }
    return x;
}
Beispiel #15
0
void *loadmess_new(t_symbol *s, int argc, t_atom *argv)
{
    int i;
	t_loadmess *x =  NULL;
	t_binbuf* d;
    
    if (!(d = binbuf_via_atoms(argc,argv)))
        return NULL;
    
    x = (t_loadmess *)eobj_new(loadmess_class);
    x->l_loaded = 0;
    x->l_time = clock_getsystime();
    x->l_argc = argc;
    x->l_argv = (t_atom *)calloc(x->l_argc, sizeof(t_atom));
    for(i = 0; i < argc; i++)
        x->l_argv[i] = argv[i];
    
    if(!x->l_argc)
    {
        x->l_out = (t_outlet *)bangout(x);
    }
    else if(x->l_argc == 1)
    {
        if(atom_gettype(argv) == A_FLOAT)
            x->l_out = (t_outlet *)floatout(x);
        else if (atom_gettype(argv) == A_SYMBOL)
            x->l_out = (t_outlet *)symbolout(x);
    }
    else
    {
        if(atom_gettype(argv) == A_FLOAT)
            x->l_out = (t_outlet *)listout(x);
        else if (atom_gettype(argv) == A_SYMBOL)
            x->l_out = (t_outlet *)anythingout(x);
    }
    
    return (x);
}
Beispiel #16
0
static void step_float(t_step *x, t_float f)
{
    double timenow = clock_getsystime();
    if (x->x_gotinlet && x->x_in1val > 0 && x->x_step != 0 && f != x->x_setval)
    {
    	if (timenow > x->x_targettime) x->x_setval = x->x_targetval;
    	else x->x_setval = x->x_setval + x->x_1overtimediff *
    	    (timenow - x->x_prevtime)
    	    * (x->x_targetval - x->x_setval);
    	x->x_prevtime = timenow;
    	x->x_targetval = f;		/* where to end */
		x->x_stepcall = 0;
			/* how long does it take ? */
    	x->x_targettime = clock_getsystimeafter(x->x_in1val);
		if(x->x_setval < x->x_targetval)
		{
			x->x_steptime = x->x_in1val / (int)((x->x_targetval - x->x_setval) / x->x_step);
		}
		else
		{
			x->x_steptime = x->x_in1val / (int)((x->x_setval - x->x_targetval) / x->x_step);
		}
		// post("steptime %g", x->x_steptime);
    	step_tick(x);
    	x->x_gotinlet = 0;
    	x->x_1overtimediff = 1./ (x->x_targettime - timenow);
			/* call tick function */
    	clock_delay(x->x_clock, x->x_steptime);
    
    }
    else
    {
    	clock_unset(x->x_clock);
    	x->x_targetval = x->x_setval = f;
    	outlet_float(x->x_obj.ob_outlet, f);
    }
    x->x_gotinlet = 0;
}
Beispiel #17
0
static void step_tick(t_step *x)
{
	t_float outvalue;
    double timenow = clock_getsystime();
    double msectogo = - clock_gettimesince(x->x_targettime);
    if (msectogo < 1E-9)
    {
    	outlet_float(x->x_obj.ob_outlet, x->x_targetval);
    }
    else
    {
		if(x->x_setval < x->x_targetval)
		{		/* count upwards */
			outvalue = x->x_setval + x->x_stepcall * x->x_step;
		}
		else
		{		/* count downwards */
			outvalue = x->x_setval - x->x_stepcall * x->x_step;
		}
    	outlet_float(x->x_obj.ob_outlet, outvalue);
    	clock_delay(x->x_clock, (x->x_steptime > msectogo ? msectogo : x->x_steptime));
    }
	x->x_stepcall++;
}
    /* call this whenever we reset audio */
static void msw_resetmidisync(void)
{
    initsystime = clock_getsystime();
    msw_hibuftime = sys_getrealtime();
}
Beispiel #19
0
static void loadmess_click(t_loadmess *x)
{
    if(clock_gettimesince(x->l_time) < 250.)
        loadmess_output(x);
    x->l_time = clock_getsystime();
}
Beispiel #20
0
static void timer_bang(t_timer *x)
{
    x->x_settime = clock_getsystime();
    x->x_moreelapsed = 0;
}
Beispiel #21
0
void GemMan :: render(void *)
{
  int profiling=m_profile;
  t_symbol*chain1=gensym("__gem_render");
  t_symbol*chain2=gensym("__gem_render_osd");
  if(GemMan::pleaseDestroy)GemMan::destroyWindow();
  if (!m_windowState)return;

  // are we profiling?
  double starttime=sys_getrealtime();
	double stoptime=0;
    
  s_hit = 0;
  resetValues();

  GemState currentState;
  float tickTime;

  // fill in the elapsed time
  if (m_buffer == 1)
    tickTime = 50.f;
  else
    tickTime = static_cast<float>(clock_gettimesince(m_lastRenderTime));

  currentState.set(GemState::_TIMING_TICK, tickTime);

  m_lastRenderTime = clock_getsystime();

  //test to see if stereo is supported
  //XXX maybe there is a better place to do this?
  GLboolean stereoWindowTest;
  glGetBooleanv (GL_STEREO, &stereoWindowTest);
  //if we're trying to do crystal glasses stereo but don't have a stereo window
  //disable stereo and post a warning
  if(m_stereo == 3 && !stereoWindowTest){
    error("GEM: you've selected Crystal Glasses Stereo but your graphics card isn't set up for stereo, setting stereo=0");
    m_stereo = 0;
  } else if(stereoWindowTest) {
    //if we're not doing crystal eyes stereo but our window is enabled to do stereo
    //select the back buffer for drawing
    glDrawBuffer(GL_BACK);
  }

  // if stereoscopic rendering
  switch (m_stereo) {
  case 1: // 2-screen stereo
    {
      int xSize = m_w / 2;
      int ySize = m_h;
      float xDivy = static_cast<float>(xSize) / static_cast<float>(ySize);

      // setup the left viewpoint
      glViewport(0, 0, xSize, ySize);
      // setup the matrices
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(GemMan::m_perspect[0] * xDivy, GemMan::m_perspect[1] * xDivy,	// left, right
                GemMan::m_perspect[2], GemMan::m_perspect[3],			// bottom, top
                GemMan::m_perspect[4], GemMan::m_perspect[5]);			// front, back
 
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
                m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);

      // render left view
      fillGemState(currentState);

      renderChain(chain1, &currentState);

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
      renderChain(chain2, &currentState);

      // setup the right viewpoint
      glViewport(xSize, 0, xSize, ySize);
      // setup the matrices
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(GemMan::m_perspect[0] * xDivy, GemMan::m_perspect[1] * xDivy,	// left, right
                GemMan::m_perspect[2], GemMan::m_perspect[3],			// bottom, top
                GemMan::m_perspect[4], GemMan::m_perspect[5]);			// front, back
 
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
                m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);

      // render right view
      fillGemState(currentState);
      tickTime=0;
      currentState.set(GemState::_TIMING_TICK, tickTime);
      renderChain(chain1, &currentState);

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
      renderChain(chain2, &currentState);


      if (GemMan::m_stereoLine){
        // draw a line between the views
        glDisable(GL_LIGHTING);

        glViewport(0, 0, m_w, m_h);
        xDivy = static_cast<float>(m_w) / static_cast<float>(ySize);
        // setup the matrices
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glFrustum(-1, 1, -1, 1, 1, 20);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);

        glLineWidth(2.f);
        glColor3f(1.f, 1.f, 1.f);
        glBegin(GL_LINES);
        glVertex2f(0.f, -6.f);
        glVertex2f(0.f, 6.f);
        glEnd();
        glLineWidth(1.0f);
      }
    }
    break;
  case 2: // color-stereo
    {
      int xSize = m_w;
      int ySize = m_h;
      float xDivy = static_cast<float>(xSize) / static_cast<float>(ySize);

      int left_color=0;  // RED
      int right_color=1; // GREEN

      glClear(GL_COLOR_BUFFER_BIT & m_clear_mask);
      glClear(GL_DEPTH_BUFFER_BIT & m_clear_mask);
      glClear(GL_STENCIL_BUFFER_BIT & m_clear_mask);
      glClear(GL_ACCUM_BUFFER_BIT & m_clear_mask);

      // setup the left viewpoint
      switch (left_color){
      case 1:
        glColorMask(GL_FALSE,GL_TRUE,GL_FALSE,GL_TRUE);
        break;
      case 2:
        glColorMask(GL_FALSE,GL_FALSE,GL_TRUE,GL_TRUE);
        break;
      case 0:
      default:
        glColorMask(GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE);
      }

      // setup the matrices
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(GemMan::m_perspect[0] * xDivy, GemMan::m_perspect[1] * xDivy,	// left, right
                GemMan::m_perspect[2], GemMan::m_perspect[3],			// bottom, top
                GemMan::m_perspect[4], GemMan::m_perspect[5]);			// front, back
 
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
                m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);

      // render left view
      fillGemState(currentState);
      renderChain(chain1, &currentState);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
      renderChain(chain2, &currentState);

      // setup the right viewpoint
      glClear(GL_DEPTH_BUFFER_BIT & m_clear_mask);
      switch (right_color){
      case 0:
        glColorMask(GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE);
        break;
      case 1:
      default:
        glColorMask(GL_FALSE,GL_TRUE,GL_FALSE, GL_TRUE);
        break;
      case 2:
        glColorMask(GL_FALSE,GL_FALSE,GL_TRUE,GL_TRUE);
      }

      // setup the matrices
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(GemMan::m_perspect[0] * xDivy, GemMan::m_perspect[1] * xDivy,	// left, right
                GemMan::m_perspect[2], GemMan::m_perspect[3],			// bottom, top
                GemMan::m_perspect[4], GemMan::m_perspect[5]);			// front, back
 
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
                m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);

      // render right view
      fillGemState(currentState);
      tickTime=0;
      currentState.set(GemState::_TIMING_TICK, tickTime);
      renderChain(chain1, &currentState);

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
      renderChain(chain2, &currentState);
    
      glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
    } 
    break;
  case 3: // Crystal Eyes Stereo
    {
      int xSize = m_w;
      int ySize = m_h;
      float xDivy = static_cast<float>(xSize) / static_cast<float>(ySize);

      // setup the left viewpoint

      // setup the matrices
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(GemMan::m_perspect[0] * xDivy, GemMan::m_perspect[1] * xDivy, // left, right
                GemMan::m_perspect[2], GemMan::m_perspect[3],     // bottom, top
                GemMan::m_perspect[4], GemMan::m_perspect[5]);      // front, back
         
      glMatrixMode(GL_MODELVIEW);
      glDrawBuffer(GL_BACK_LEFT);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         
      glLoadIdentity();
      gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
                m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
         
      // render left view
      fillGemState(currentState);
      renderChain(chain1, &currentState);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
      renderChain(chain2, &currentState);

      // setup the right viewpoint
      glClear(GL_DEPTH_BUFFER_BIT & m_clear_mask);

      // setup the matrices
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(GemMan::m_perspect[0] * xDivy, GemMan::m_perspect[1] * xDivy, // left, right
                GemMan::m_perspect[2], GemMan::m_perspect[3],     // bottom, top
                GemMan::m_perspect[4], GemMan::m_perspect[5]);      // front, back

      glMatrixMode(GL_MODELVIEW);
      glDrawBuffer(GL_BACK_RIGHT);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      glLoadIdentity();
      gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
                m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);

      // render right view
      fillGemState(currentState);
      tickTime=0;
      currentState.set(GemState::_TIMING_TICK, tickTime);
      renderChain(chain1, &currentState);

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
      renderChain(chain2, &currentState);

      glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
    }
    break;
  default: // normal rendering
    {
      fillGemState(currentState);
      renderChain(chain1, &currentState);

      // setup the matrices
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
      renderChain(chain2, &currentState);
    }
  }
  swapBuffers();

  // are we profiling?
	stoptime=sys_getrealtime();
  if (profiling>0) {
    double seconds =  stoptime-starttime;
    if(seconds>0.f) {
      GemMan::fps = (1 / (seconds * 1000.f)) * 1000.f;
    } else {
      error("GEM: unable to profile");
    }
  }

  // only keep going if no one set the s_hit (could be hit if scheduler gets
  //	    ahold of a stopRendering command)
	double deltime=s_deltime;
	if(profiling<0) {
		float spent=(stoptime-starttime)*1000;
		if(profiling<-1) {
			deltime-=spent;
		} else if(spent<deltime && spent>0.f) {
			deltime-=spent;
		} else {
			post("unable to annihiliate %f ms", spent);
		}
		if(deltime<0.){
			logpost(NULL, 5, "negative delay time: %f", deltime);
			deltime=1.f;
		}
	}

  if (!s_hit && (0.0 != deltime))
    clock_delay(s_clock, deltime);
	
  glReportError();
}
static void timer_bang(t_timer *x)
{
    x->x_settime = clock_getsystime();
}
static void qlist_donext(t_qlist *x, int drop, int automatic)
{
    t_pd *target = 0;
    while (1)
    {
        int argc = binbuf_getnatom(x->x_binbuf),
            count, onset = x->x_onset, onset2, wasreentered;
        t_atom *argv = binbuf_getvec(x->x_binbuf);
        t_atom *ap = argv + onset, *ap2;
        if (onset >= argc) goto end;
        while (ap->a_type == A_SEMI || ap->a_type == A_COMMA)
        {
            if (ap->a_type == A_SEMI) target = 0;
            onset++, ap++;
            if (onset >= argc) goto end;
        }

        if (!target && ap->a_type == A_FLOAT)
        {
            ap2 = ap + 1;
            onset2 = onset + 1;
            while (onset2 < argc && ap2->a_type == A_FLOAT)
                onset2++, ap2++;
            x->x_onset = onset2;
            if (automatic)
            {
                clock_delay(x->x_clock,
                    x->x_clockdelay = ap->a_w.w_float * x->x_tempo);
                x->x_whenclockset = clock_getsystime();
            }
            else outlet_list(x->x_ob.ob_outlet, 0, onset2-onset, ap);
            return;
        }
        ap2 = ap + 1;
        onset2 = onset + 1;
        while (onset2 < argc &&
            (ap2->a_type == A_FLOAT || ap2->a_type == A_SYMBOL))
                onset2++, ap2++;
        x->x_onset = onset2;
        count = onset2 - onset;
        if (!target)
        {
            if (ap->a_type != A_SYMBOL) continue;
            else if (!(target = ap->a_w.w_symbol->s_thing))
            {
                pd_error(x, "qlist: %s: no such object",
                    ap->a_w.w_symbol->s_name);
                continue;
            }
            ap++;
            onset++;
            count--;
            if (!count) 
            {
                x->x_onset = onset2;
                continue;
            }
        }
        wasreentered = x->x_reentered;
        x->x_reentered = 0;
        if (!drop)
        {   
            if (ap->a_type == A_FLOAT)
                typedmess(target, &s_list, count, ap);
            else if (ap->a_type == A_SYMBOL)
                typedmess(target, ap->a_w.w_symbol, count-1, ap+1);
        }
        if (x->x_reentered)
            return;
        x->x_reentered = wasreentered;
    }  /* while (1); never falls through */

end:
    x->x_onset = 0x7fffffff;
    outlet_bang(x->x_bangout);
    x->x_whenclockset = 0;
}