Esempio n. 1
0
xdl_int XdevLCudaImpl::readModuleInformation(TiXmlDocument* document) {
	TiXmlHandle docHandle(document);
	TiXmlElement* root = docHandle.FirstChild(XdevLCorePropertiesName.c_str()).FirstChildElement("XdevLOpenGL").ToElement();

	if (!root) {
		XDEVL_MODULE_INFO("<XdevLCuda> section not found, skipping proccess.\n");
		return ERR_OK;
	}

	if(root->Attribute("id")){
		XdevLModuleId id(root->Attribute("id"));
		if(*getId() != id){
			return ERR_OK;
		}		
	}else{
		XDEVL_MODULE_ERROR("No 'id' attribute specified.");
		return ERR_ERROR;
	}

//	if (root->Attribute("framebuffer_depth")){
//		m_ColorDepth = xstd::from_string<xdl_int>(root->Attribute("framebuffer_depth"));
//		XDEVL_MODULE_INFO("Framebuffer depth request: " << m_ColorDepth << std::endl);
//	}

	return ERR_OK;
}
	xdl_int XdevLJoystickServerMac::readJoystickInfo(TiXmlDocument& document) {
		TiXmlHandle docHandle(&document);
		TiXmlElement* root = docHandle.FirstChild(XdevLCorePropertiesName.c_str()).FirstChildElement("XdevLWindow").ToElement();
		if(!root) {
			XDEVL_MODULE_INFO("<XdevLWindow> section not found. Using default values for the device.\n");
			return RET_SUCCESS;
		}

		while(root != nullptr) {

			// Does the user specified the id of the module?
			if(root->Attribute("id")) {
				XdevLID id(root->Attribute("id"));

				// Do only if we have the same ID.
				// TODO Maybe change comparison into string comparison.
				if(getID() == id) {
					TiXmlElement* child = nullptr;
					for(child = root->FirstChildElement(); child; child = child->NextSiblingElement()) {
//						if(root->Attribute("Device"))
//							m_device = XdevLString(root->Attribute("Device"));
					}
				}
			}
			root = root->NextSiblingElement();
		}
		return RET_SUCCESS;
	}
	xdl_int XdevLJoystickServerMac::RunThread(thread::ThreadArgument*) {
		XDEVL_MODULE_INFO("Starting threading mode.\n");
		m_running = xdl_true;
		for(;;) {
			{
				m_mutex.Lock();
				xdl_bool tmp = m_running;
				m_mutex.Unlock();
				if(tmp == xdl_false) {
					break;
				}
			}
			pollEvents();
		}
		XDEVL_MODULE_INFO("Stopping threading mode.\n");
		return 0;
	}
	void XdevLWindowWayland::onSizeChanged(xdl_int width, xdl_int height) {
		XDEVL_MODULE_INFO("Size changed: (width, height): (" << width << ", " << height << ")\n");
		XdevLWindowSize size(width, height);
		setSize(size);

		wl_egl_window_resize(m_egl.m_eglWindow, width, height, 0, 0);

		wl_region *region = wl_compositor_create_region(m_compositor);
		wl_region_add(region, 0, 0, width, height);
		wl_surface_set_opaque_region(m_surface, region);
		wl_region_destroy(region);
	}
Esempio n. 5
0
	int XdevLOpenGLContextGLX::create(XdevLWindow* window, XdevLOpenGLContext* shareContext) {
		XDEVL_ASSERT(m_display == nullptr, "XdevLOpenGLContextGLX already created.");

		if(nullptr != shareContext) {
			m_shareContext = static_cast<XdevLOpenGLContextGLX*>(shareContext);
		}

		window->getDescriptor().registerDependency(this);

		m_display = static_cast<Display*>(window->getInternal(XdevLInternalName("X11_DISPLAY")));
		if(nullptr == m_display) {
			XDEVL_MODULE_ERROR("Could not get native X11 display information.\n");
			return RET_FAILED;
		}

		m_window = (Window)(window->getInternal(XdevLInternalName("X11_WINDOW")));
		if(None == m_window) {
			XDEVL_MODULE_ERROR("Could not get native X11 window information.\n");
			return RET_FAILED;
		}

		if(glXQueryVersion(m_display, &m_glxMajorVersion, &m_glxMinorVersion) == False) {
			XDEVL_MODULE_ERROR("glXQueryVersion failed.\n");
			return RET_FAILED;
		}

		if(initOpenGL(m_display, m_window) == RET_FAILED) {
			XDEVL_MODULE_ERROR("Failed to initialize OpenGL.\n");
			return RET_FAILED;
		}

		if(glXIsDirect(m_display, m_glxContext)) {
			XDEVL_MODULE_INFO("Direct Rendering supported.\n");

		} else {
			XDEVL_MODULE_WARNING("Direct Rendering not supported.\n");
		}

		setVSync(getVSync());

		return RET_SUCCESS;
	}
	xdl_int XdevLJoystickServerMac::addJoystick(const std::string& path) {
		thread::XdevLScopeLock lock(m_mutex);

		auto it = m_joystickDevices.find(path);
		if(it != m_joystickDevices.end()) {
			return RET_SUCCESS;
		}

		xdl_int fd = openUsingPath(path);
		if(fd== -1) {
			XDEVL_MODULE_INFO("Error occured: " << strerror(errno) << std::endl);
			return RET_FAILED;
		}

		XdevLJoystickDeviceInfoMac* joystickInfo = getJoystickInfo(fd, path);
		if(nullptr == joystickInfo) {
			return RET_FAILED;
		}
//		m_joystickDevices[joystickInfo->joystickid] = joystickInfo;

		return RET_SUCCESS;
	}
	XdevLKeyboardImpl::~XdevLKeyboardImpl() {
		XDEVL_MODULE_INFO("~XdevLKeyboardImpl()\n");
	}
	XdevLKeyboardImpl::XdevLKeyboardImpl(XdevLModuleCreateParameter* parameter, const XdevLModuleDescriptor& descriptor) : 
		XdevlKeyboardBase<XdevLKeyboard>(parameter, descriptor) {
			XDEVL_MODULE_INFO("XdevLKeyboardImpl()\n");
	}