Example #1
0
Screen::Screen() :
  sdl_init_{make_scoped_call(SDL_Init,
                             SDL_Quit,
                             SDL_INIT_TIMER |
                             SDL_INIT_AUDIO |
                             SDL_INIT_VIDEO |
                             SDL_INIT_EVENTS)},
  ttf_init_{make_scoped_call(TTF_Init, TTF_Quit)},
  img_init_{make_scoped_call(IMG_Init, IMG_Quit, 0 /* no special libraries */)},
  window_{make_resource(SDL_CreateWindow,
                         SDL_DestroyWindow,
                         "EGGS",
                         SDL_WINDOWPOS_UNDEFINED,
                         SDL_WINDOWPOS_UNDEFINED,
                         kStartWidth,
                         kStartHeight,
                         SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE)},
  renderer_{make_resource(SDL_CreateRenderer,
                          SDL_DestroyRenderer,
                          window_.get(),
                          -1 /* first available driver */,
                          SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC)},
  font_{make_resource(TTF_OpenFont, TTF_CloseFont,
                      get_asset_path("DroidSansMono.ttf").c_str(),
                      kFontPtSize)}
{
	empty_.r = 255;
	empty_.g = 255;
	empty_.b = 255;
	empty_.a = 0;
	text_color_.r = 0;
	text_color_.g = 0;
	text_color_.b = 0;
	text_color_.a = 0;
}
 QuadTreeRenderer::QuadTreeRenderer()
     : m_vert_shader(make_resource("color.vert"))
     , m_frag_shader(make_resource("color.frag"))
     , m_material(make_resource("Color.material"))
     , m_vao(nullptr)
     , m_vbuffer(nullptr)
     , m_ibuffer(nullptr)
 {
     build();
 }
Example #3
0
static struct resource *nonstatic_find_io_region(unsigned long base, int num,
		   unsigned long align, struct pcmcia_socket *s)
{
	struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.class_id);
	struct socket_data *s_data = s->resource_data;
	struct pcmcia_align_data data;
	unsigned long min = base;
	int ret;

	if (align == 0)
		align = 0x10000;

	data.mask = align - 1;
	data.offset = base & data.mask;
	data.map = &s_data->io_db;

	down(&rsrc_sem);
#ifdef CONFIG_PCI
	if (s->cb_dev) {
		ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
					     min, 0, pcmcia_align, &data);
	} else
#endif
		ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
					1, pcmcia_align, &data);
	up(&rsrc_sem);

	if (ret != 0) {
		kfree(res);
		res = NULL;
	}
	return res;
}
static struct resource *iodyn_find_io_region(unsigned long base, int num,
		unsigned long align, struct pcmcia_socket *s)
{
	struct resource *res = make_resource(0, num, IORESOURCE_IO,
					     dev_name(&s->dev));
	struct pcmcia_align_data data;
	unsigned long min = base;
	int ret;

	if (align == 0)
		align = 0x10000;

	data.mask = align - 1;
	data.offset = base & data.mask;

#ifdef CONFIG_PCI
	if (s->cb_dev) {
		ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
					     min, 0, pcmcia_align, &data);
	} else
#endif
		ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
					1, pcmcia_align, &data);

	if (ret != 0) {
		kfree(res);
		res = NULL;
	}
	return res;
}
Example #5
0
    Material::Material()
        : m_vert_shader(InvalidResource)
        , m_frag_shader(InvalidResource)
        , m_depth_vert_shader(InvalidResource)
        , m_depth_frag_shader(InvalidResource)
        , m_tex_albedo(InvalidResource)
        , m_tex_normal(InvalidResource)
        , m_tex_roughness(InvalidResource)
        , m_tex_metallic(InvalidResource)
        , m_tex_env(InvalidResource)
        , m_cull_mode(CullMode::BackFace)
        , m_blending(false)
        , m_casts_shadows(true)
    {
        m_vert_shader = make_resource("pbs.vert");
        m_frag_shader = make_resource("pbs.frag");
        m_depth_vert_shader = make_resource("sm_depth.vert");
        m_depth_frag_shader = make_resource("sm_depth.frag");

        create_env_brdf();
    }
static int request_io_resource(unsigned long b, unsigned long n,
			       char *name, struct pci_dev *dev)
{
	struct resource *res = make_resource(b, n, IORESOURCE_IO, name);
	struct resource *pr = resource_parent(b, n, IORESOURCE_IO, dev);
	int err = -ENOMEM;

	if (res) {
		err = request_resource(pr, res);
		if (err)
			kfree(res);
	}
	return err;
}
Example #7
0
static struct resource * nonstatic_find_mem_region(u_long base, u_long num,
		u_long align, int low, struct pcmcia_socket *s)
{
	struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.class_id);
	struct socket_data *s_data = s->resource_data;
	struct pcmcia_align_data data;
	unsigned long min, max;
	int ret, i;

	low = low || !(s->features & SS_CAP_PAGE_REGS);

	data.mask = align - 1;
	data.offset = base & data.mask;
	data.map = &s_data->mem_db;

	for (i = 0; i < 2; i++) {
		if (low) {
			max = 0x100000UL;
			min = base < max ? base : 0;
		} else {
			max = ~0UL;
			min = 0x100000UL + base;
		}

		down(&rsrc_sem);
#ifdef CONFIG_PCI
		if (s->cb_dev) {
			ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num,
						     1, min, 0,
						     pcmcia_align, &data);
		} else
#endif
			ret = allocate_resource(&iomem_resource, res, num, min,
						max, 1, pcmcia_align, &data);
		up(&rsrc_sem);
		if (ret == 0 || low)
			break;
		low = 1;
	}

	if (ret != 0) {
		kfree(res);
		res = NULL;
	}
	return res;
}
static int request_mem_resource(unsigned long b, unsigned long n,
				char *name, struct pci_dev *dev)
{
	struct resource *res;
	struct resource *pr;
	int err = -ENOMEM;

	b += ISAMEM_PHYS;

	res = make_resource(b, n, IORESOURCE_MEM, name);
	pr = resource_parent(b, n, IORESOURCE_MEM, dev);

	if (res) {
		err = request_resource(pr, res);
		if (err)
			kfree(res);
	}
	return err;
}
Example #9
0
static struct resource *
claim_region(struct pcmcia_socket *s, unsigned long base, unsigned long size,
	     int type, char *name)
{
	struct resource *res, *parent;

	parent = type & IORESOURCE_MEM ? &iomem_resource : &ioport_resource;
	res = make_resource(base, size, type | IORESOURCE_BUSY, name);

	if (res) {
#ifdef CONFIG_PCI
		if (s && s->cb_dev)
			parent = pci_find_parent_resource(s->cb_dev, res);
#endif
		if (!parent || request_resource(parent, res)) {
			kfree(res);
			res = NULL;
		}
	}
	return res;
}