Esempio n. 1
0
void draw_projectile()
{
	list_node *c;
	projectile *p;
	for (c = PROJECTILES->next; c->next != NULL; c = c->next) {
		if (((projectile *) c->data) != NULL) {
			p = (projectile *) c->data;
			draw_texture_scale(p->t, p->x, p->y, p->w, p->h);
		}
	}
}
gboolean browser_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer data)
{
	int width = w->allocation.width / browser_columns;
	rows = (tex_names.size() / browser_columns) + 1;
	int top = gtk_range_get_value(GTK_RANGE(browse_vscroll));

	// Set sizes for row and page steps (for the scrollbar)
	int rows_page = w->allocation.height / width;
	gtk_range_set_increments(GTK_RANGE(browse_vscroll), width, rows_page * width);

	GdkGLContext *context = gtk_widget_get_gl_context(w);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(w);

	if (!gdk_gl_drawable_gl_begin(gldrawable, context))
		return false;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	int sel_index = -1;
	int a = 0;
	for (int row = 0; row < rows; row++)
	{
		for (int col = 0; col < browser_columns; col++)
		{
			if (a >= tex_names.size())
				continue;

			rect_t rect(col * width, (row * width) - top, width, width, 0);

			glLineWidth(2.0f);
			if (selected_tex == tex_names[a])
			{
				draw_rect(rect, rgba_t(0, 180, 255, 150, 0), true);
				draw_rect(rect, rgba_t(100, 220, 255, 255, 0), false);
				sel_index = a;
			}

			glLineWidth(1.0f);
			rect.resize(-8, -8);

			if (((row + 1) * width) > top && (row * width) < (top + w->allocation.height))
			{
				if (!browse_sprites)
				{
					if (tex_names[a] != "-")
						draw_texture_scale(rect, tex_names[a], 0);

					draw_text(rect.x1() + (width/2) - 8, rect.y2() - 4, rgba_t(255, 255, 255, 255, 0), 1, tex_names[a].c_str());
				}
				else
					draw_texture_scale(rect, browsesprites[a], 3);
			}

			a++;
		}
	}

	if (browse_sprites && sel_index != -1)
		draw_text(0, 0, rgba_t(255, 255, 255, 255, 0), 0, tex_names[sel_index].c_str());

	if (gdk_gl_drawable_is_double_buffered(gldrawable))
		gdk_gl_drawable_swap_buffers(gldrawable);
	else
		glFlush();

	gdk_gl_drawable_gl_end(gldrawable);

	return false;
}