Exemplo n.º 1
0
static Bool 
parse_keysym(const char *line, int n, char **name, KeySym *keysym)
{
    *name = copy_to_scratch (line, n);
    if (!strcmp(*name, "NoSymbol")) {
	*keysym = NoSymbol;
	return (True);
    }
    *keysym = XStringToKeysym (*name);
    if (*keysym == NoSymbol && '0' <= **name && **name <= '9')
	return parse_number(*name, keysym);
    return (*keysym != NoSymbol);
}
Exemplo n.º 2
0
void 
HaloRefImage::draw_objects(CGELlist& drawn)
{
   assert(_view);

   GELlist objects;
   for (int i=0; i < drawn.num(); i++ ) {
      if (drawn[i]->is_3D()) 
         if (drawn[i]->name()!="Skybox") // XXX - hack!!
            objects+=drawn[i];
   }

   objects.sort(GL_VIEW::depth_compare);

   // setup projection matrix
   glMatrixMode(GL_PROJECTION); // GL_TRANSFORM_BIT
   glPushMatrix();
   glLoadMatrixd(_view->cam()->projection_xform().transpose().matrix());

   // setup modelview matrix
   glMatrixMode(GL_MODELVIEW);  // GL_TRANSFORM_BIT
   glPushMatrix();
   Wtransf mat = _view->cam()->xform().transpose();
   glLoadMatrixd(mat.matrix());
         
   glEnable(GL_BLEND);                                // GL_ENABLE_BIT
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_COLOR_BUFFER_BIT

   //clear the aux0 buffer 
   if (use_fbos)
      glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);
   else
      glDrawBuffer(GL_AUX0);
   glClearColor(1.0,1.0,1.0,0.0);     
   glClear(GL_COLOR_BUFFER_BIT);
   if (use_fbos)
      glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);

   if (get_kernel_size()>0) { //no need to do this if kernel size is zero
      glReadBuffer(GL_BACK);

      for(int i=0; i<objects.num(); i++) {  
         
         glDrawBuffer(GL_BACK);
           
         //clear back buffer
         glClearColor(1.0,1.0,1.0,0.0);
         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
         if (objects[i]->can_do_halo()) {
            _pass_color = Color::black;
            objects[i]->draw_halo_ref();


            //perform the blur in GLSL
              
            copy_to_scratch();
            _blur_filter->draw(_view);

            //render the white version on top

            //clear Z-buffer
            glClear(GL_DEPTH_BUFFER_BIT);
         }
         glDisable(GL_BLEND);
          
         _pass_color = Color::white;  //white
         objects[i]->draw_halo_ref();

         //accumulate    
         copy_to_scratch();       
         glEnable(GL_BLEND);

         if (use_fbos)
            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);
         else
            glDrawBuffer(GL_AUX0);
         draw_scratch(); //composite into AUX0 buffer
         if (use_fbos)
            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
      }  
   }

   //at this point the combined image exists in GL_AUX0 buffer
   //it is copied to texture from there instead of being copied to back buffer
  
   // restore projection matrix
   glMatrixMode(GL_PROJECTION);
   glPopMatrix();

   // restore modelview matrix
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();
}
Exemplo n.º 3
0
static void 
do_pointer(char *line, int len)
{
    int n;
    int i;
    unsigned long val;
    union op *uop;
    struct op_pointer *opp;
    unsigned char buttons[MAXBUTTONCODES];
    int nbuttons;
    char *strval;
    Bool ok;

    if (len < 2 || !line || *line == '\0') {  /* =1 minimum */
	badmsg0 ("buttons input line");
	return;
    }

    nbuttons = XGetPointerMapping (dpy, buttons, MAXBUTTONCODES);

    n = skip_space (line, len);
    line += n, len -= n;

    if (line[0] != '=') {
	badmsg0 ("buttons pointer code list, missing equal sign");
	return;
    }

    line++, len--;			/* skip = */
    n = skip_space (line, len);
    line += n, len -= n;

    i = 0;
    if (len < 7 || strncasecmp (line, "default", 7) != 0) {
	while (len > 0) {
	    n = skip_space (line, len);
	    line += n, len -= n;
	    if (line[0] == '\0') break;
	    n = skip_word (line, len);
	    if (n < 1) {
		badmsg ("skip of word in buttons line:  %s", line);
		return;
	    }
	    strval = copy_to_scratch(line, n);
	    ok = parse_number (strval, &val);
	    if (!ok || val >= MAXBUTTONCODES) {
		badmsg ("value %s given for buttons list", strval);
		return;
	    }
	    buttons[i++] = (unsigned char) val;
	    line += n, len -= n;
	}
    }
    
    if (i > 0 && i != nbuttons) {
	fprintf (stderr, "Warning: Only changing the first %d of %d buttons.\n",
		 i, nbuttons);
	i = nbuttons;
    }

    uop = AllocStruct (union op);
    if (!uop) {
	badmsg ("attempt to allocate a %ld byte pointer opcode",
		(long) sizeof (struct op_pointer));
	return;
    }
    opp = &uop->pointer;

    opp->type = doPointer;
    opp->count = i;
    for (i = 0; i < opp->count; i++) {
	opp->button_codes[i] = buttons[i];
    }

    add_to_work_queue (uop);
}