Exemplo n.º 1
0
void
rtb_window_close(struct rtb_window *self)
{
	assert(self);

	glBindVertexArray(0);
	glDeleteVertexArrays(1, &self->vao);

	rtb_font_manager_fini(&self->font_manager);

	ibos_fini(self);
	shaders_fini(self);

	rtb_surface_fini(RTB_SURFACE(self));
	window_impl_close(self);
}
Exemplo n.º 2
0
struct rtb_window *
rtb_window_open_under(struct rutabaga *r, intptr_t parent,
		int w, int h, const char *title)
{
	struct rtb_style_data stdata;
	struct rtb_window *self;

	assert(r);
	assert(h > 0);
	assert(w > 0);
	assert(!r->win);

	self = window_impl_open(r, w, h, title, parent);
	if (!self)
		goto err_window_impl;

	init_gl();

	if (RTB_SUBCLASS(RTB_SURFACE(self), rtb_surface_init, &super))
		goto err_surface_init;

	self->w = w;
	self->h = h;

	self->surface = RTB_SURFACE(self);

	stdata = rtb_style_get_defaults();
	self->style_list = stdata.style;
	self->style_fonts = calloc(stdata.nfonts, sizeof(*self->style_fonts));

	if (shaders_init(self))
		goto err_shaders;

	if (ibos_init(self))
		goto err_ibos;

	if (rtb_font_manager_init(&self->font_manager,
				self->dpi.x, self->dpi.y))
		goto err_font;

	rtb_elem_set_layout(RTB_ELEMENT(self), rtb_layout_vpack_top);

	self->on_event   = win_event;
	self->mark_dirty = mark_dirty;
	self->attached   = attached;

	self->flags = RTB_ELEM_CLICK_FOCUS;

	/* for core profiles */
	glGenVertexArrays(1, &self->vao);
	glBindVertexArray(self->vao);

	self->rtb = r;
	r->win = self;

	self->mouse.current_cursor = RTB_MOUSE_CURSOR_DEFAULT;

	return self;

err_font:
	ibos_fini(self);
err_ibos:
	shaders_fini(self);
err_shaders:
err_surface_init:
	window_impl_close(self);
err_window_impl:
	return NULL;
}