/*! * Attempts to resolve the service in order to determine the host and port necessary to establish a connection. * * If forceMulticast is set to true, QxtDiscoverableService will use a multicast request to resolve the service, * even if the host name appears to be a unicast address (that is, outside the local network). * * \sa resolved * \sa resolveError */ void QxtDiscoverableService::resolve(bool forceMulticast) { if(state() != Unknown && state() != Found) { qWarning() << "QxtDiscoverableService: Cannot resolve service while not in Unknown or Found state"; emit resolveError(0); return; } DNSServiceErrorType err; err = DNSServiceResolve(&(qxt_d().service), (forceMulticast ? kDNSServiceFlagsForceMulticast : 0), qxt_d().iface, serviceName().toUtf8().constData(), fullServiceType().constData(), domain().toUtf8().constData(), QxtDiscoverableServicePrivate::resolveServiceCallback, &qxt_d()); if(err != kDNSServiceErr_NoError) { qxt_d().state = Unknown; emit resolveError(err); } else { qxt_d().state = Resolving; qxt_d().notifier = new QSocketNotifier(DNSServiceRefSockFD(qxt_d().service), QSocketNotifier::Read, this); QObject::connect(qxt_d().notifier, SIGNAL(activated(int)), &qxt_d(), SLOT(socketData())); } }
HRESULT DX11SceneManager::createTexture(Texture& textureRef, std::string strName, UVector2 Size, TextureType type) { HRESULT hr; //Fill the data structure. D3D10_TEXTURE2D_DESC textureDesc; ::ZeroMemory(&textureDesc, sizeof(textureDesc)); textureDesc.Width = Size.x; textureDesc.Height = Size.y; textureDesc.MipLevels = 1; textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; textureDesc.SampleDesc.Count = 1; textureDesc.SampleDesc.Quality = 0; textureDesc.Usage = D3D10_USAGE_DYNAMIC; textureDesc.BindFlags = D3D10_BIND_SHADER_RESOURCE; textureDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; textureDesc.MiscFlags = 0; D3D10_SHADER_RESOURCE_VIEW_DESC textureSRDesc; textureSRDesc.Format = textureDesc.Format; textureSRDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; textureSRDesc.Texture2D.MipLevels = 1; textureSRDesc.Texture2D.MostDetailedMip = 0; std::shared_ptr<TextureData> data(new TextureData()); if(type != TEXTURE_NONE) { //Create a directx10 texture and make a shaderresource view of it. if(FAILED(hr = m_pd3dDevice->CreateTexture2D(&textureDesc, NULL, &data->m_pTexture2D))) return EventManager::Instance().postException(resolveError(hr), "ID3D10Device::CreateTexture2D() failed"); if(FAILED(hr = m_pd3dDevice->CreateShaderResourceView(data->m_pTexture2D, &textureSRDesc, &data->m_pShaderResource))) return EventManager::Instance().postException(resolveError(hr), "ID3D10Device::CreateShaderResourceView() failed"); } data->m_strName = strName; data->m_loadState = STATE_LOADED; m_pTextureArray.push_back(data); textureRef = Texture(data); return S_OK; }
HRESULT DX11SceneManager::loadTexture(Texture& textureRef, const char* strFilename) { //Search the texturearray for another copy of the texture by name. for(UINT i = 0;i < m_pTextureArray.size(); i++) { if(m_pTextureArray[i]->m_pShaderResource) { //if names are equal the textures are. if(m_pTextureArray[i]->m_strName.compare(strFilename) == 0) { textureRef = Texture(m_pTextureArray[i]); return S_OK; } } } std::string strPath = ""; strPath.append("..\\data\\textures\\"); strPath.append(strFilename); HRESULT hr = S_OK; //Texture didn't exist so create a new one. std::shared_ptr<TextureData> data(new TextureData()); //TextureInfo dependant on the settings of SceneManager. //D3DX11_IMAGE_LOAD_INFO info; //::ZeroMemory(&info, sizeof(info)); //info.BindFlags = D3D10_BIND_SHADER_RESOURCE; //Try to load the texture and create a shadersource view from a file. if(FAILED(hr = D3DX11CreateShaderResourceViewFromFile(m_pd3dDevice, strPath.c_str(), NULL, NULL, &data->m_pShaderResource, NULL))) { EventManager::Instance().postError(hr, "Loading texture: %s failed", strPath.c_str()); //if there is no first index of the texture array. //Default.png doesn't exist then. if(m_pTextureArray.size() > 0) textureRef = Texture(m_pTextureArray[0]); else return EventManager::Instance().postException(resolveError(hr), "Loading the default texture: %s failed", strPath.c_str()); //Although the loading failed, the texture still exist as a generic //default.png version (PURPLE/WHITE boxes) return hr; } data->m_strName = strFilename; data->m_loadState = STATE_LOADED; m_pTextureArray.push_back(data); textureRef = Texture(data); return S_OK; }