Beispiel #1
0
void spawn_about(widget *x)
{
	widget *w = widget_window_new(100, 100, "ABOUT");
	widget *item = widget_text_new(20, 110, "\u00a9 2013 Daniel Burke");
	widget_child_add(w, item);
	item = widget_text_new(20, 80, "VOXEL TEST");
	item->fontsize = 40.0f;
	item->fontface = 1;
	widget_child_add(w, item);
	item = widget_url_new(20, 120, "WWW",
			"http://danpburke.blogspot.com.au");
	item->size.x = 90;
	widget_child_add(w, item);
	item = widget_url_new(120, 120, "GitHub",
			"https://github.com/burito/voxel");
	item->size.x = 90;
	widget_child_add(w, item);
	item = widget_url_new(220, 120, "YouTube",
			"http://www.youtube.com/user/bur1t0/videos");
	item->size.x = 90;
	widget_child_add(w, item);
	w->size.x = 330;
	w->size.y = 170;
	w->noResize = 1;
	widget_add(w);
}
Beispiel #2
0
void spawn_http_pend(widget *x)
{
	widget *item, *w = widget_window_new(100, 100, "Pending Devices");
	item = widget_text_new(10, 65, "OpenGL");
	item->fontsize = 30.0f;
	item->fontface = 1;
	widget_child_add(w, item);
	item = widget_text_new(20, 90, hcopy(
		(const char*)glGetString(GL_VENDOR) ));
	widget_child_add(w, item);
	item = widget_text_new(20, 110, hcopy(
		(const char*)glGetString(GL_RENDERER) ));
	widget_child_add(w, item);
	item = widget_text_new(20, 130, hcopy(
		(const char*)glGetString(GL_VERSION) ));
	widget_child_add(w, item);
	item = widget_text_new(20, 150, hcopy(
		(const char*)glGetString(GL_SHADING_LANGUAGE_VERSION) ));
	widget_child_add(w, item);

	w->size.x = 330;
	w->size.y = 155;
	w->noResize = 1;
	widget_add(w);
}
Beispiel #3
0
int gui_init(int argc, char *argv[])
{
	memset(frame_time, 0, sizeof(long)*MAX_FRAMES);
	stash = sth_create(512,512);
	if (!stash)
	{
		printf("Could not create stash.\n");
		return -1;
	}
	font_load(0,"data/gui/SourceCodePro-Regular.ttf");
	font_load(1,"data/gui/SourceCodePro-Bold.ttf");
	font_load(2,"data/gui/SourceSansPro-Regular.ttf");
	font_load(3,"data/gui/SourceSansPro-Bold.ttf");

	widget *w;
	widget *menu = widget_menu_new();
	widget *item = widget_menu_add(menu, "File");
	widget_menu_item_add(item, "Open", spawn_open);
	widget_menu_item_add(item, "Voxel Open", spawn_voxopen);
	widget_menu_separator_add(item);
	widget_menu_item_add(item, "Exit", menu_killme);

	item = widget_menu_add(menu, "Display");
	w = widget_menu_item_add(item, "	 Fullscreen - F11", menu_fullscreen);
	w->draw = widget_menu_bool_draw;
	w->data2 = &fullscreen;
	w = widget_menu_item_add(item, "	 Draw 3D Texture", menu_texdraw);
	w->draw = widget_menu_bool_draw;
	extern int texdraw;
	w->data2 = &texdraw;
	widget_menu_item_add(item, "GPU Information", spawn_gpuinfo);
	widget_menu_separator_add(item);
	widget_menu_item_add(item, "Rebuild Shaders", voxel_rebuildshader);

	item = widget_menu_add(menu, "Input");
	w = widget_menu_item_add(item, "	 Accepting Tablets",
		menu_http_toggle);
	w->draw = widget_menu_bool_draw;
	w->data2 = &http_accepting_new_clients;
	w = widget_menu_item_add(item, "Authorised Devices", spawn_http_auth );
	w = widget_menu_item_add(item, "Pending Authorisation", spawn_http_pend);

	item = widget_menu_add(menu, "Help");
	widget_menu_item_add(item, "Overview \u2560", 0);
	widget_menu_item_add(item, "Wiki \u26a0", 0);
	widget_menu_separator_add(item);
	widget_menu_item_add(item, "Credits \u2623", spawn_credits);
	widget_menu_item_add(item, "License", spawn_license);
	widget_menu_separator_add(item);
	widget_menu_item_add(item, "About", spawn_about);

	widget_add(menu);

	last_time = sys_time();
	return 0;
}
Beispiel #4
0
void spawn_gpuinfo(widget *x)
{
	widget *item, *w = widget_window_new(100, 100, "GPU Information");
	item = widget_text_new(10, 65, "OpenGL");
	item->fontsize = 30.0f;
	item->fontface = 1;
	widget_child_add(w, item);
	item = widget_text_new(20, 90, hcopy(
		(const char*)glGetString(GL_VENDOR) ));
	widget_child_add(w, item);
	item = widget_text_new(20, 110, hcopy(
		(const char*)glGetString(GL_RENDERER) ));
	widget_child_add(w, item);
	item = widget_text_new(20, 130, hcopy(
		(const char*)glGetString(GL_VERSION) ));
	widget_child_add(w, item);
	item = widget_text_new(20, 150, hcopy(
		(const char*)glGetString(GL_SHADING_LANGUAGE_VERSION) ));
	widget_child_add(w, item);

	item = widget_text_new(10, 175, "OpenCL");
	item->fontsize = 30.0f;
	item->fontface = 1;
	widget_child_add(w, item);

	int count = 0;
	size_t bs=1000;
	char buf[bs];
	OCLCONTEXT *c = OpenCL;
		for(int i=0; i<c->num_pid; i++)
	{
		bs = 1000;
		clGetPlatformInfo( c->pid[i], CL_PLATFORM_NAME, bs, buf, &bs);
		item = widget_text_new(10, 200+count*20, hcopy(buf));
		widget_child_add(w, item);
		count ++;

		for(int j=0; j<c->num_did[i]; j++)
		{
			bs = 1000;
			clGetDeviceInfo(c->did[i][j], CL_DEVICE_NAME, bs, buf, &bs);
			item = widget_text_new(20, 200+count*20, hcopy(buf));
			widget_child_add(w, item);
			count ++;
		}
	}

	w->size.x = 330;
	w->size.y = 190 + count * 20;
	w->noResize = 1;
	widget_add(w);
}
Beispiel #5
0
widget* spawn_ocl(char* filename)
{
	widget *w = widget_window_new(100, 100, filename);
	w->draw = widget_window_ocl_draw;
	w->release = widget_window_ocl_release;
	w->onclick = widget_window_ocl_onclick;
	w->free = widget_window_ocl_free;
	OCLPROGRAM *p = ocl_build(filename);
	w->data2 = p;
	p->window = w;
	widget_add(w);
	return w;
}
Beispiel #6
0
void spawn_credits(widget *x)
{
	widget *item, *w = widget_window_new(100, 100, "CREDITS");
	item = widget_text_new(20, 80, "3RD PARTY");
	item->fontsize = 40.0f;
	item->fontface = 1;
	widget_child_add(w, item);
	item = widget_text_new(30, 120, "LIBRARIES");
	item->fontface = 1;
	widget_child_add(w, item);
	item = widget_text_new(190, 120, "FONTS");
	item->fontface = 1;
	widget_child_add(w, item);
	item = widget_url_new(20, 120, "GLEW",
			"http://glew.sourceforge.net");
	item->size.x = 140;
	widget_child_add(w, item);
	item = widget_url_new(20, 160, "Font Stash",
			"https://github.com/akrinke/Font-Stash");
	item->size.x = 140;
	widget_child_add(w, item);
	item = widget_url_new(20, 200, "stb_truetype.h",
			"http://nothings.org/");
	item->size.x = 140;
	widget_child_add(w, item);
	item = widget_url_new(20, 240, "stb_image.c",
			"http://nothings.org/");
	item->size.x = 140;
	widget_child_add(w, item);
	item = widget_url_new(20, 280, "zlib",
			"http://zlib.net/");
	item->size.x = 140;
	widget_child_add(w, item);
	item = widget_url_new(180, 120, "SourceSansPro",
			"https://github.com/adobe-fonts/source-sans-pro");
	item->size.x = 140;
	widget_child_add(w, item);
	item = widget_url_new(180, 160, "SourceCodePro",
			"https://github.com/adobe-fonts/source-code-pro");
	item->fontface = 1;
	item->size.x = 140;
	widget_child_add(w, item);
//	item = widget_url_new(180, 200, "",
//			"");
//	item->size.x = 140;
//	widget_child_add(w, item);
	w->size.x = 340;
	w->size.y = 330;
	w->noResize = 1;
	widget_add(w);
}
Beispiel #7
0
widget* spawn_obj(char* filename)
{
	widget *w = widget_window_new(100, 100, filename);
	WF_OBJ *m = wf_load(filename);
	w->data2 = m;
	w->draw = widget_window_obj_draw;
	w->free = widget_window_obj_free;
	w->onclick = widget_window_obj_onclick;
	float3 *p = malloc(sizeof(float3));
	p->x = p->y = p->z = 0;
	w->data3 = p;
	widget_add(w);
	return w;
}
Beispiel #8
0
void spawn_license(widget *x)
{
	widget *w = widget_window_new(100, 100, "LICENSE");
	widget *item;
	item = widget_text_new(20, 70, "Copyright (c) 2012 Daniel Burke");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 95, "This software is provided 'as-is', without any express or implied");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 110, "warranty. In no event will the authors be held liable for any damages");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 125, "arising from the use of this software.");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 155, "Permission is granted to anyone to use this software for any purpose,");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 170, "including commercial applications, and to alter it and redistribute it");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 185, "freely, subject to the following restrictions:");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 210, "	1. The origin of this software must not be misrepresented; you must not");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 225, "	claim that you wrote the original software. If you use this software");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 240, "	in a product, an acknowledgment in the product documentation would be");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 255, "	appreciated but is not required.");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 280, "	2. Altered source versions must be plainly marked as such, and must not be");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 295, "	misrepresented as being the original software.");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 320, "	3. This notice may not be removed or altered from any source");
	item->fontface = 1;	item->fontsize = 14.0f; widget_child_add(w, item);
	item = widget_text_new(20, 335, "	distribution.");
	item->fontface = 0;	item->fontsize = 14.0f; widget_child_add(w, item);
	w->size.x = 570;
	w->size.y = 360;
	w->pos.x = 20;
	w->pos.y = 80;
	w->noResize = 1;
	widget_add(w);
}
Beispiel #9
0
void widget_window_onclick(widget *w)
{
	widget_remove(w);
	widget_add(w);		// send to foreground
	w->delta.x = mouse_x - w->pos.x;
	w->delta.y = mouse_y - w->pos.y;

	if(w->delta.y > 5)
	if(w->delta.y < 30)
	{
		if( w->delta.x > (w->size.x - 50) )
				w->clicked=3;	// end
		else
			w->clicked=2;		// dragging
		return;
	}

	if(w->noResize)return;

	if(w->delta.y > w->size.y - 10)	// dragging down
	{
		w->clicked = 4;		// resize bottom
		if(w->delta.x < 10)w->clicked = 5;	// resize bottom left
		if(w->delta.x > (w->size.x-10))w->clicked = 6;	// resize bottom right
		return;
	}

	if(w->delta.x < 10)
	{
		w->clicked = 7;		// resize left
	}
	if(w->delta.x > (w->size.x - 10))
	{
		w->clicked = 8;		// resize right
	}

}
Beispiel #10
0
void widget_menu_onclick(widget *w)
{
	widget_add((widget*)w->data2);
}
Beispiel #11
0
void spawn_open(widget *x)
{
	widget *w = widget_window_new(100, 100, "OPEN...");
	w->onclick = widget_open_onclick;
	w->click = widget_open_click;
	widget *b = widget_button_new(10, 40, "Open");
	b->action = x ? open_test : open_voxel;

	widget_child_add(w, b);


	int dmax = 100, fmax = 100;
	int dcnt = 0, fcnt = 0;
	char **dirs;
	char **files;

	dirs = malloc(sizeof(char*)*dmax);
	files = malloc(sizeof(char*)*fmax);

	char *path = "./data";
	w->data2 = path;
	DIR *dir = opendir(path);
	char tmp[1000];
	struct dirent *ent;
	while((ent = readdir(dir)))
	{
		if(ent->d_name[0] == '.')continue;

		struct stat s;
		memset(&s, 0, sizeof(struct stat));
		memset(tmp, 0, 1000);
		sprintf(tmp, "%s/%s", path, ent->d_name);
		stat(tmp, &s);
		if( S_ISDIR(s.st_mode) )
		{
			if(dcnt == dmax)
			{
				printf("dont forget to malloc some more\n");
				return;
			}
			dirs[dcnt++] = hcopy(ent->d_name);
		} else
		if( S_ISREG(s.st_mode) )
		{
			if(fcnt == fmax)
			{
				printf("dont forget to malloc some more\n");
				return;
			}
			if(x)
			{
				if(strstr(ent->d_name, ".obj"))
					files[fcnt++] = hcopy(ent->d_name);
				else if(strstr(ent->d_name, ".OpenCL"))
					files[fcnt++] = hcopy(ent->d_name);
			}
			else
			{
				if(strstr(ent->d_name, ".obj"))
					files[fcnt++] = hcopy(ent->d_name);
			}
		}
		else printf("Unexpected Filetype= %d \"%s\"\n", s.st_mode, ent->d_name);


	}
	closedir(dir);

	qsort(dirs, dcnt, sizeof(char*), cmp_str);
	qsort(files, fcnt, sizeof(char*), cmp_str);

	widget *item = widget_list_new(10, 80, dirs, dcnt);
	item->size.x = w->size.x / 3 - 15;
	item->size.y = w->size.y - 100;
	widget_child_add(w, item);
	item = widget_list_new(w->size.x/3 + 5, 80, files, fcnt);
	item->size.x = w->size.x / 3 * 2 - 15;
	item->size.y = w->size.y - 100;
	widget_child_add(w, item);
	item->action = open_test;
	widget_add(w);
}