Ejemplo n.º 1
0
 /** 
  * Uses sub-function for each bigger group of tags.
  */
 void ConfigReader::readConfig() {
     configXmlDoc = xmlReadFile(m_config->configPath().c_str(), NULL, 0);
     if(configXmlDoc == NULL) {
         _inf(
                 "%sThere is no config file (~/.keyfrog/config).\n"
                 "You must create one. You can use example config included with keyfrog.\n"
                 "It should be placed at `/usr/share/keyfrog/doc/sample-config' or\n"
                 "`/usr/local/share/keyfrog/doc/sample-config'. If it's not there,\n"
                 "download sources and check doc/ directory.%s\n"
                 , ccyan, creset);
     }
     xmlNode *rootElement = xmlDocGetRootElement(configXmlDoc);
     // Walk through nodes and invoke proper processing functions
     for (xmlNode * cur_node = rootElement->children; cur_node; cur_node = cur_node->next) {
         if (cur_node->type != XML_ELEMENT_NODE) {
             continue;
         }
         if(0==xmlStrcmp((const xmlChar *)"application-groups",cur_node->name)) {
             processGroups(cur_node->children);
         }
         if(0==xmlStrcmp((const xmlChar *)"options",cur_node->name)) {
             processOptions(cur_node->children);
         }
     }
     xmlFreeDoc(configXmlDoc);
 }
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
	struct engine *engine = NULL;
	Display *dpy;
	int num;
	XSetWindowAttributes attr;
	unsigned long mask;
	Window root;
	Window win;
	XVisualInfo *info = NULL;
	GLXContext ctx  = NULL;
	int conf[] = { GLX_RGBA,
		GLX_RED_SIZE, 1,
		GLX_GREEN_SIZE, 1,
		GLX_BLUE_SIZE, 1,
		GLX_DOUBLEBUFFER, GL_FALSE,
		GLX_DEPTH_SIZE, 1,
		None,
	};

	dpy = XOpenDisplay(NULL);
	if (!dpy) {
		_err("failed to open X display\n");
		return 1;
	}

	num = DefaultScreen(dpy);
	_inf("use GLX_SGIX_pbuffer on screen %d\n", num);

	root = RootWindow(dpy, num);
	info = glXChooseVisual(dpy, num, conf);
	if (!info) {
		_err("glXChooseVisual() failed\n");
		goto out;
	}

	/* window attributes */
	attr.border_pixel = 0;
	attr.colormap = XCreateColormap(dpy, root, info->visual, AllocNone);
	attr.event_mask = ButtonPressMask | ExposureMask | KeyPressMask;
	mask = CWBorderPixel | CWColormap | CWEventMask;

	win = XCreateWindow(dpy, root, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT,
		0, info->depth, InputOutput, info->visual, mask, &attr);

	ctx = glXCreateContext(dpy, info, NULL, GL_TRUE);
	if (!ctx) {
		_err("glXCreateContext() failed\n");
		goto out;
	}

	XFree(info);
	info = NULL;
	XMapWindow(dpy, win);

	_msg("call glXMakeCurrent()\n");
	glXMakeCurrent(dpy, win, ctx);

	_inf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
	_inf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
	_inf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
	_inf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
	_inf("GL_SHADING_LANGUAGE_VERSION = %s\n",
		(char *) glGetString(GL_SHADING_LANGUAGE_VERSION));

	_msg("clear window\n");
	glClearColor(0, 0, 0, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	glXSwapBuffers(dpy, win);

	_msg("init engine\n");
	if (engine_init(&engine, argc, argv) < 0) {
		_err("engine_init() failed\n");
		goto out;
	}

	_msg("start engine\n");
	engine_start(engine);

	glXSwapBuffers(dpy, win);

	engine_stop(engine);
	event_loop(dpy);

	_msg("exit engine\n");
	engine_exit(&engine);

out:
	glXMakeCurrent(dpy, 0, 0);

	if (info)
		XFree(info);

	if (ctx)
		glXDestroyContext(dpy, ctx);

	XDestroyWindow(dpy, win);
	XCloseDisplay(dpy);

	return 0;
}