Ejemplo n.º 1
0
bool program::

link_feedback() const
{
  GLint link_status(GL_FALSE);

  glGetProgramiv(id_,GL_LINK_STATUS,&link_status);

  if(link_status != GL_TRUE)
  {
    GLint   length(0);
    GLchar* info_buffer(nullptr);

    glGetProgramiv(id_,GL_INFO_LOG_LENGTH,&length);

    if(length != 0)
    {
      info_buffer = new GLchar[length];

      glGetProgramInfoLog(id_,length,&length,info_buffer);

      std::cerr << std::endl
                << "[" << name_ << "]"
                << std::endl << std::endl
                << "line " << info_buffer
                << std::endl;

      delete[] info_buffer;
    }

    return false;
  }

  else
  {
    return true;
  }
}
Ejemplo n.º 2
0
struct video_device* init_video(char*devname,int x,int y)
{
    char* channel = "Composite1";

    const int zero = 0;
    const int one = 1;
    const int two = 2;
    const int three = 3;
    const int four = 4;
    const int five = 5;
    int t;
    struct video_internal* device;
    struct video_device* device_wrapper;

    device_wrapper = (struct video_device*)malloc(sizeof(struct video_device));
    device = (struct video_internal*)malloc(sizeof(struct video_internal));
    device_wrapper->internal = device;

    /* VIDEO */

    printf("Opening %s\n", devname);
    device->dev = open(devname, O_RDWR);

    if(device->dev < 0) {
	char buf[64];
	sprintf(buf, "open %s", devname);
	perror(buf);
	exit(1);
    }

    if(verbose) printf("CAPABILITIES:\n");
    myioctl(device->dev, VIDIOCGCAP, &device->cap);
    if(verbose)
	info_capabilities(&device->cap);

    if(verbose) printf("CHANNELS:\n");
    for(t=0;t<device->cap.channels;t++)
    {
	struct video_channel chan;
	int set = 0;
	chan.channel = t;
	myioctl(device->dev, VIDIOCGCHAN, &chan);

	if(verbose) info_channel(&chan);

	if(t==0)
	    memcpy(&device->chan, &chan, sizeof(chan));

	if(!strcmp(chan.name, channel)) {
	    set = 1;
	    memcpy(&device->chan, &chan, sizeof(chan));
	    if(verbose) {
		printf("^^^^^^^^^^^^^^^^^^^^^^^^ selecting channel %d\n", chan.channel);
	    }
	}

	if(chan.type&VIDEO_VC_TUNER) {
	    unsigned long freq;
	    device->tuner.tuner = 0;
	    myioctl(device->dev, VIDIOCGTUNER, &device->tuner);
	    if(verbose) {
	        info_tuner(&device->tuner);
	    }

	    myioctl(device->dev, VIDIOCGFREQ, &freq);
	    if(verbose) {
		printf("tuner frequency: %d\n", freq);
	    }
	}
    }
    if(verbose) printf("setting channel \"%s\"...\n", device->chan.name);
    myioctl(device->dev, VIDIOCSCHAN, &device->chan);

    if(verbose) printf("device->picture:\n");
    myioctl(device->dev, VIDIOCGPICT, &device->picture);
    if(verbose) info_picture(&device->picture);
    device->picture.brightness = 2;
    device->picture.contrast = 49152;
    myioctl(device->dev, VIDIOCSPICT, &device->picture);

    if(verbose) printf("device->window:\n");
    myioctl(device->dev, VIDIOCGWIN, &device->window);
    if(verbose) info_window(&device->window);
    /* ? framebuffer overlay: 
    myioctl(device->dev, VIDIOCSWIN, &device->window);*/

    if(verbose) printf("device->buffer:\n");
    myioctl(device->dev, VIDIOCGFBUF, &device->buffer);
    if(verbose) info_buffer(&device->buffer);

    if(verbose) printf("device->audio:\n");
    for(t=0;t<device->cap.audios;t++)
    {
	myioctl(device->dev, VIDIOCGAUDIO, &device->audio);
	if(verbose) info_audio(&device->audio);
    }
    
    if(verbose) printf("device->mbuf:\n");
    myioctl(device->dev, VIDIOCGMBUF, &device->mbuf);
    if(verbose) info_mbuf(&device->mbuf);

    device->mem =(unsigned char *)mmap(0,device->mbuf.size,PROT_READ|PROT_WRITE,MAP_SHARED,device->dev,0);
    if((unsigned char*)-1 == device->mem) {
        fprintf(stderr, "Unable to allocate memory!\n");
    }
    if(verbose) printf("Memory: %08x\n", device->mem);

    device->map[0].frame = 0;
    device->map[1].frame = 1;
    device->map[0].width = 
    device->map[1].width = x;
    device->map[0].height = 
    device->map[1].height = y;
    //device->map[0].format = device->map[1].format = VIDEO_PALETTE_GREY;
    device->map[0].format = 
    device->map[1].format = VIDEO_PALETTE_RGB24; //RGB32

    device->picsize = ((3 * x + 3)&~3) * y;

    device_wrapper->frame = 0;
    device->frame = 0;
    return device_wrapper;
}