Ejemplo n.º 1
0
String  String::Left(UINT iOffset)
{
    if(iOffset > curLength)
    {
        AppWarning(TEXT("Bad call to String::Left.  iOffset is bigger than the current length."));
        return String();
    }

    return String(*this).SetLength(iOffset);
}
Ejemplo n.º 2
0
HANDLE D3D10Texture::GetSharedHandle()
{
    HRESULT err;
    HANDLE handle = NULL;
    IDXGIResource *pDXGIResource;
    if FAILED(err = texture->QueryInterface(__uuidof(IDXGIResource), (void **)&pDXGIResource))
    {
        AppWarning(TEXT("D3D10Texture::GetSharedHandle: QueryInterface failed, result = %08lX"), err);
        return handle;
    }
Ejemplo n.º 3
0
bool DeviceSource::Init(XElement *data)
{
    HRESULT err;
    err = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, (REFIID)IID_IFilterGraph, (void**)&graph);
    if(FAILED(err))
    {
        AppWarning(TEXT("DShowAudioPlugin: Failed to build IGraphBuilder, result = %08lX"), err);
        return false;
    }

    err = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, (REFIID)IID_ICaptureGraphBuilder2, (void**)&capture);
    if(FAILED(err))
    {
        AppWarning(TEXT("DShowAudioPlugin: Failed to build ICaptureGraphBuilder2, result = %08lX"), err);
        return false;
    }

    hSampleMutex = OSCreateMutex();
    if(!hSampleMutex)
    {
        AppWarning(TEXT("DShowAudioPlugin: could not create sample mutex"));
        return false;
    }

    capture->SetFiltergraph(graph);

    int numThreads = MAX(OSGetTotalCores()-2, 1);
    hConvertThreads = (HANDLE*)Allocate(sizeof(HANDLE)*numThreads);
    convertData = (ConvertData*)Allocate(sizeof(ConvertData)*numThreads);

    zero(hConvertThreads, sizeof(HANDLE)*numThreads);
    zero(convertData, sizeof(ConvertData)*numThreads);

    this->data = data;
    UpdateSettings();

    //if(!bFiltersLoaded)
    //    return false;

    Log(TEXT("Using directshow audio input"));

    return true;
}
Ejemplo n.º 4
0
String  String::Right(UINT iOffset)
{
    if(iOffset > curLength)
    {
        AppWarning(TEXT("Bad call to String::Right.  iOffset is bigger than the current length."));
        return String();
    }

    return String((lpString+curLength)-iOffset);
}
Ejemplo n.º 5
0
void SceneItem::SetRender(bool render)
{
    element->SetInt(TEXT("render"), (int)((render)?1:0));
    bRender = render;
    CTSTR lpClass = element->GetString(TEXT("class"));

    if (bRender) {
        if (!lpClass) {
            AppWarning(TEXT("No class for source '%s' in scene '%s'"), element->GetName(), API->GetSceneElement()->GetName());
        } else {
            XElement *data = element->GetElement(TEXT("data"));
            source = API->CreateImageSource(lpClass, data);
            if(!source) {
                AppWarning(TEXT("Could not create image source '%s' in scene '%s'"), element->GetName(), API->GetSceneElement()->GetName());
            } else {
                API->EnterSceneMutex();
                if (parent && parent->bSceneStarted) {
                    source->BeginScene();

                    if(scmp(lpClass, L"GlobalSource") == 0)
                        source->GlobalSourceEnterScene();
                }
                API->LeaveSceneMutex();
            }
        }
    } else {
        if (source) {
            API->EnterSceneMutex();

            ImageSource *src = source;
            source = NULL;

            if(scmp(lpClass, L"GlobalSource") == 0)
                src->GlobalSourceLeaveScene();

            if (parent && parent->bSceneStarted)
                src->EndScene();
            delete src;

            API->LeaveSceneMutex();
        }
    }
}
VBData* D3D10VertexBuffer::GetData()
{
    if(!bDynamic)
    {
        AppWarning(TEXT("D3D10VertexBuffer::GetData: Cannot get vertex data of a non-dynamic vertex buffer"));
        return NULL;
    }

    return data;
}
Ejemplo n.º 7
0
bool LoadPlugin()
{
    textureMutexes[0] = CreateMutex(NULL, NULL, TEXTURE_MUTEX1);
    if(!textureMutexes[0])
    {
        AppWarning(TEXT("Could not create texture mutex 1, GetLastError = %u"), GetLastError());
        return false;
    }

    textureMutexes[1] = CreateMutex(NULL, NULL, TEXTURE_MUTEX2);
    if(!textureMutexes[1])
    {
        AppWarning(TEXT("Could not create texture mutex 2, GetLastError = %u"), GetLastError());
        return false;
    }

    API->RegisterImageSourceClass(GRAPHICSCAPTURE_CLASSNAME, Str("Sources.GameCaptureSource"), (OBSCREATEPROC)CreateGraphicsCaptureSource, (OBSCONFIGPROC)ConfigureGraphicsCaptureSource);

    return true;
}
Ejemplo n.º 8
0
Scene* OBS::CreateScene(CTSTR lpClassName, XElement *data)
{
    for(UINT i=0; i<sceneClasses.Num(); i++)
    {
        if(sceneClasses[i].strClass.CompareI(lpClassName))
            return (Scene*)sceneClasses[i].createProc(data);
    }

    AppWarning(TEXT("OBS::CreateScene: Could not find scene class '%s'"), lpClassName);
    return NULL;
}
Ejemplo n.º 9
0
ImageSource* OBS::CreateImageSource(CTSTR lpClassName, XElement *data)
{
    for(UINT i=0; i<imageSourceClasses.Num(); i++)
    {
        if(imageSourceClasses[i].strClass.CompareI(lpClassName))
            return (ImageSource*)imageSourceClasses[i].createProc(data);
    }

    AppWarning(TEXT("OBS::CreateImageSource: Could not find image source class '%s'"), lpClassName);
    return NULL;
}
Ejemplo n.º 10
0
void D3D10Texture::ReleaseDC()
{
    if(!surface)
    {
        AppWarning(TEXT("D3D10Texture::ReleaseDC: no DC to release"));
        return;
    }

    surface->ReleaseDC(NULL);
    SafeRelease(surface);
}
Ejemplo n.º 11
0
SceneItem* Scene::InsertImageSource(UINT pos, XElement *sourceElement)
{
    if(GetSceneItem(sourceElement->GetName()) != NULL)
    {
        AppWarning(TEXT("Scene source '%s' already in scene.  actually, no one should get this error.  if you do send it to jim immidiately."), sourceElement->GetName());
        return NULL;
    }

    if(pos > sceneItems.Num())
    {
        AppWarning(TEXT("Scene::InsertImageSource: pos >= sceneItems.Num()"));
        pos = sceneItems.Num();
    }

    bool render = sourceElement->GetInt(TEXT("render"), 1) > 0;

    float x  = sourceElement->GetFloat(TEXT("x"));
    float y  = sourceElement->GetFloat(TEXT("y"));
    float cx = sourceElement->GetFloat(TEXT("cx"), 100);
    float cy = sourceElement->GetFloat(TEXT("cy"), 100);

    SceneItem *item = new SceneItem;
    item->element = sourceElement;
    item->parent = this;
    item->pos = Vect2(x, y);
    item->size = Vect2(cx, cy);
    item->crop.w = sourceElement->GetFloat(TEXT("crop.right"));
    item->crop.x = sourceElement->GetFloat(TEXT("crop.left"));
    item->crop.y = sourceElement->GetFloat(TEXT("crop.top"));
    item->crop.z = sourceElement->GetFloat(TEXT("crop.bottom"));
    item->SetRender(render);

    API->EnterSceneMutex();
    sceneItems.Insert(pos, item);
    API->LeaveSceneMutex();

    /*if(!source)
        bMissingSources = true;*/

    return item;
}
Ejemplo n.º 12
0
String  String::Mid(UINT iStart, UINT iEnd)
{
    if( (iStart >= curLength) ||
        (iEnd > curLength || iEnd <= iStart)   )
    {
        AppWarning(TEXT("Bad call to String::Mid.  iStart or iEnd is bigger than the current length (string: %s)."), lpString);
        return String();
    }

    String newString = lpString+iStart;
    return newString.SetLength(iEnd-iStart);
}
Ejemplo n.º 13
0
bool SharedTexCapture::Init(CaptureInfo &info)
{
    String strFileMapName;
    strFileMapName << TEXTURE_MEMORY << UIntString(info.mapID);

    hFileMap = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, strFileMapName);
    if(hFileMap == NULL)
    {
        AppWarning(TEXT("SharedTexCapture::Init: Could not open file mapping: %d"), GetLastError());
        return false;
    }

    sharedMemory = (LPBYTE)MapViewOfFile(hFileMap, FILE_MAP_ALL_ACCESS, 0, 0, info.mapSize);
    if(!sharedMemory)
    {
        AppWarning(TEXT("SharedTexCapture::Init: Could not map view of file"));
        return false;
    }

    //Log(TEXT("using shared texture capture"));

    //---------------------------------------

    texData = (SharedTexData*)sharedMemory;
    texData->frameTime = 1000000/API->GetMaxFPS()/2;

    sharedTexture = GS->CreateTextureFromSharedHandle(info.cx, info.cy, (HANDLE)texData->texHandle);
    if(!sharedTexture)
    {
        AppWarning(TEXT("SharedTexCapture::Init: Could not create shared texture"));
        return false;
    }

    copyTexture = GS->CreateTexture(info.cx, info.cy, (GSColorFormat)info.format, 0, FALSE, TRUE);

    Log(TEXT("SharedTexCapture hooked"));

    bInitialized = true;
    return true;
}
Ejemplo n.º 14
0
bool STDCALL ConfigureCloudSource(XElement *element, bool bCreating)
{
    if (!element)
    {
        AppWarning(TEXT("ConfigureIVASource: NULL element"));
        return false;
    }

    XElement *data = element->GetElement(TEXT("data"));
    if (!data)
        data = element->CreateElement(TEXT("data"));

    ConfigIVAInfo configInfo;
    configInfo.data = data;

    if (OBSDialogBox(hinstMain, MAKEINTRESOURCE(IDD_IVACLOUD), API->GetMainWindow(), IVACloudProc, (LPARAM)&configInfo) == IDOK)
    {
        int nIndex = data->GetInt(TEXT("SelIndex"));

        std::string strPath = g_pCloudData->m_vIPicDesc[nIndex].strFileName;
        std::wstring wstrPath;
        StringToWString(strPath, wstrPath);

        CTSTR lpBitmap = wstrPath.c_str();

        D3DX10_IMAGE_INFO ii;
        if (SUCCEEDED(D3DX10GetImageInfoFromFile(lpBitmap, NULL, &ii, NULL)))
        {
            element->SetInt(TEXT("cx"), ii.Width);
            element->SetInt(TEXT("cy"), ii.Height);
        }
        else
            AppWarning(TEXT("ConfigureBitmapSource: could not get image info for bitmap '%s'"), lpBitmap);

        return true;
    }

    return false;
}
Ejemplo n.º 15
0
void LogVideoCardStats()
{
    HRESULT err;

#ifdef USE_DXGI1_2
    REFIID iidVal = OSGetVersion() >= 8 ? __uuidof(IDXGIFactory2) : __uuidof(IDXGIFactory1);
#else
    REFIIF iidVal = __uuidof(IDXGIFactory1);
#endif

    IDXGIFactory1 *factory;
    if(SUCCEEDED(err = CreateDXGIFactory1(iidVal, (void**)&factory)))
    {
        UINT i=0;
        IDXGIAdapter1 *giAdapter;

        while(factory->EnumAdapters1(i++, &giAdapter) == S_OK)
        {
            DXGI_ADAPTER_DESC adapterDesc;
            if(SUCCEEDED(err = giAdapter->GetDesc(&adapterDesc)))
            {
                if (!(adapterDesc.VendorId == 0x1414 && adapterDesc.DeviceId == 0x8c)) { // Ignore Microsoft Basic Render Driver
                    Log(TEXT("------------------------------------------"));
                    Log(TEXT("Adapter %u"), i);
                    Log(TEXT("  Video Adapter: %s"), adapterDesc.Description);
                    Log(TEXT("  Video Adapter Dedicated Video Memory: %u"), adapterDesc.DedicatedVideoMemory);
                    Log(TEXT("  Video Adapter Shared System Memory: %u"), adapterDesc.SharedSystemMemory);

                    UINT j = 0;
                    IDXGIOutput *output;
                    while(SUCCEEDED(giAdapter->EnumOutputs(j++, &output)))
                    {
                        DXGI_OUTPUT_DESC desc;
                        if(SUCCEEDED(output->GetDesc(&desc)))
                            Log(TEXT("  Video Adapter Output %u: pos={%d, %d}, size={%d, %d}, attached=%s"), j,
                                desc.DesktopCoordinates.left, desc.DesktopCoordinates.top,
                                desc.DesktopCoordinates.right-desc.DesktopCoordinates.left, desc.DesktopCoordinates.bottom-desc.DesktopCoordinates.top,
                                desc.AttachedToDesktop ? L"true" : L"false");
                        output->Release();
                    }
                }
            }
            else
                AppWarning(TEXT("Could not query adapter %u"), i);

            giAdapter->Release();
        }

        factory->Release();
    }
}
Ejemplo n.º 16
0
void D3D10System::DrawSpriteEx(Texture *texture, DWORD color, float x, float y, float x2, float y2, float u, float v, float u2, float v2)
{
    if(!curPixelShader)
        return;

    if(!texture)
    {
        AppWarning(TEXT("Trying to draw a sprite with a NULL texture"));
        return;
    }

    HANDLE hColor = curPixelShader->GetParameterByName(TEXT("outputColor"));

    if(hColor)
        curPixelShader->SetColor(hColor, color);

    if(x2 == -998.0f && y2 == -998.0f)
    {
        x2 = float(texture->Width());
        y2 = float(texture->Height());
    }
    if(u == -998.0f && v == -998.0f)
    {
        u = 0.0f;
        v = 0.0f;
    }
    if(u2 == -998.0f && v2 == -998.0f)
    {
        u2 = 1.0f;
        v2 = 1.0f;
    }

    VBData *data = spriteVertexBuffer->GetData();
    data->VertList[0].Set(x,  y,  0.0f);
    data->VertList[1].Set(x,  y2, 0.0f);
    data->VertList[2].Set(x2, y,  0.0f);
    data->VertList[3].Set(x2, y2, 0.0f);

    List<UVCoord> &coords = data->UVList[0];
    coords[0].Set(u,  v);
    coords[1].Set(u,  v2);
    coords[2].Set(u2, v);
    coords[3].Set(u2, v2);

    spriteVertexBuffer->FlushBuffers();

    LoadVertexBuffer(spriteVertexBuffer);
    LoadTexture(texture);

    Draw(GS_TRIANGLESTRIP);
}
Ejemplo n.º 17
0
void DeviceSource::Start()
{
    if(bCapturing || !control)
        return;

    HRESULT err;
    if(FAILED(err = control->Run()))
    {
        AppWarning(TEXT("DShowAudioPlugin: control->Run failed, result = %08lX"), err);
        return;
    }

    bCapturing = true;
}
Ejemplo n.º 18
0
bool LoadPlugin()
{
    pluginLocale = new LocaleStringLookup;

    if(!pluginLocale->LoadStringFile(TEXT("plugins/PSVPlugin/locale/en.txt")))
        AppWarning(TEXT("Could not open locale string file '%s'"), TEXT("plugins/PSVPlugin/locale/en.txt"));

    if(scmpi(API->GetLanguage(), TEXT("en")) != 0)
    {
        String pluginStringFile;
        pluginStringFile << TEXT("plugins/PSVPlugin/locale/") << API->GetLanguage() << TEXT(".txt");
        if(!pluginLocale->LoadStringFile(pluginStringFile))
            AppWarning(TEXT("Could not open locale string file '%s'"), pluginStringFile.Array());
    }

    config.Open(OBSGetPluginDataPath() + CONFIG_FILE, true);

    LoadSettings();

    OnSceneSwitch(OBSGetSceneName());

    return true;
}
Ejemplo n.º 19
0
void D3D10System::Draw(GSDrawMode drawMode, DWORD startVert, DWORD nVerts)
{
    if(!curVertexBuffer)
    {
        AppWarning(TEXT("Tried to call draw without setting a vertex buffer"));
        return;
    }

    if(!curVertexShader)
    {
        AppWarning(TEXT("Tried to call draw without setting a vertex shader"));
        return;
    }

    if(!curPixelShader)
    {
        AppWarning(TEXT("Tried to call draw without setting a pixel shader"));
        return;
    }

    curVertexShader->SetMatrix(curVertexShader->GetViewProj(), curViewProjMatrix);

    curVertexShader->UpdateParams();
    curPixelShader->UpdateParams();

    D3D10_PRIMITIVE_TOPOLOGY newTopology = topologies[(int)drawMode];
    if(newTopology != curTopology)
    {
        d3d->IASetPrimitiveTopology(newTopology);
        curTopology = newTopology;
    }

    if(nVerts == 0)
        nVerts = static_cast<D3D10VertexBuffer*>(curVertexBuffer)->numVerts;

    d3d->Draw(nVerts, startVert);
}
Ejemplo n.º 20
0
Texture *ResourceManager::GetTexture(CTSTR lpName, BOOL bGenMipMaps)
{
    traceInFast(ResourceManager::GetTexture);

    assert(lpName);

    for(DWORD i=0; i<TextureList.Num(); i++)
    {
        TextureResource &res = TextureList[i];
        if(res.name.CompareI(lpName))
        {
            if(res.texture->IsOf(GetClass(Texture)))
            {
                ++res.refs;
                return (Texture*)res.texture;
            }
            else
                return NULL;
        }
    }

    //----------------------------------------

    String path;
    if(!Engine::ConvertResourceName(lpName, TEXT("textures"), path))
        return NULL;

    //----------------------------------------

    Texture *texOut = GS->CreateTextureFromFile(path, bGenMipMaps);

    if(!texOut)
    {
        AppWarning(TEXT("Could not create texture '%s'"), path.Array());
        return NULL;
    }

    TextureResource &res = *TextureList.CreateNew();
    res.texture = texOut;
    res.name = lpName;
    res.refs = 1;

    if(texOut)
        texOut->bGenMipMaps = bGenMipMaps;

    return texOut;

    traceOutFast;
}
Ejemplo n.º 21
0
    bool Encode(float *input, UINT numInputFrames, DataPacket &packet, QWORD &timestamp)
    {
        if(bFirstFrame)
        {
            curEncodeTimestamp = timestamp;
            bFirstFrame = false;
        }

        //------------------------------------------------

        UINT lastSampleSize = frameCounter;

        frameCounter += numInputFrames;
        if(frameCounter > outputFrameSize)
        {
            frameCounter -= outputFrameSize;

            bufferedTimestamps << curEncodeTimestamp;
            curEncodeTimestamp = timestamp + ((outputFrameSize-lastSampleSize)*1000/App->GetSampleRateHz());
        }

        int ret = lame_encode_buffer_interleaved_ieee_float(lgf, (float*)input, numInputFrames, MP3OutputBuffer.Array()+1, dwMP3MaxSize);

        if(ret < 0)
        {
            AppWarning(TEXT("MP3 encode failed"));
            return false;
        }

        if(ret > 0)
        {
            if(bFirstPacket)
            {
                header.CopyArray(MP3OutputBuffer.Array(), ret);
                bFirstPacket = false;
                ret = 0;
            }
            else
            {
                packet.lpPacket = MP3OutputBuffer.Array();
                packet.size     = ret+1;

                timestamp = bufferedTimestamps[0];
                bufferedTimestamps.Remove(0);
            }
        }

        return ret > 0;
    }
Ejemplo n.º 22
0
bool D3D10Texture::GetDC(HDC &hDC)
{
    if(!bGDICompatible)
    {
        AppWarning(TEXT("D3D10Texture::GetDC: function was called on a non-GDI-compatible texture"));
        return false;
    }

    HRESULT err;
    if(FAILED(err = texture->QueryInterface(__uuidof(IDXGISurface1), (void**)&surface)))
    {
        AppWarning(TEXT("D3D10Texture::GetDC: could not query surface interface, result = %08lX"), err);
        return false;
    }

    if(FAILED(err = surface->GetDC(TRUE, &hDC)))
    {
        AppWarning(TEXT("D3D10Texture::GetDC: could not get DC, result = %08lX"), err);
        SafeRelease(surface);
        return false;
    }

    return true;
}
Ejemplo n.º 23
0
bool D3D10Texture::Map(BYTE *&lpData, UINT &pitch)
{
    HRESULT err;
    D3D10_MAPPED_TEXTURE2D map;

    if(FAILED(err = texture->Map(0, D3D10_MAP_WRITE_DISCARD, 0, &map)))
    {
        AppWarning(TEXT("D3D10Texture::Map: map failed, result = %08lX"), err);
        return false;
    }

    lpData = (BYTE*)map.pData;
    pitch = map.RowPitch;

    return true;
}
Ejemplo n.º 24
0
Shader* D3D10VertexShader::CreateVertexShaderFromBlob(ShaderBlob const &blob, CTSTR lpShader, CTSTR lpFileName)
{
    ShaderProcessor shaderProcessor;
    if (!shaderProcessor.ProcessShader(lpShader, lpFileName))
        AppWarning(TEXT("Unable to process vertex shader '%s'"), lpFileName); //don't exit, leave it to the actual shader compiler to tell the errors

    //-----------------------------------------------

    if (!blob.size())
        return nullptr;

    ComPtr<ID3D11VertexShader> vShader;
    ID3D11InputLayout *vShaderLayout;

    HRESULT err = GetD3D()->CreateVertexShader(&blob.front(), blob.size(), NULL, vShader.Assign());
    if (FAILED(err))
    {
        CrashError(TEXT("Unable to create vertex shader '%s', result = %08lX"), lpFileName, err);
        return NULL;
    }

    err = GetD3D()->CreateInputLayout(shaderProcessor.generatedLayout.Array(), shaderProcessor.generatedLayout.Num(), &blob.front(), blob.size(), &vShaderLayout);
    if (FAILED(err))
    {
        CrashError(TEXT("Unable to create vertex layout for vertex shader '%s', result = %08lX"), lpFileName, err);
        return NULL;
    }

    //-----------------------------------------------

    D3D10VertexShader *shader = new D3D10VertexShader;
    shader->vertexShader = vShader.Detach();
    shader->inputLayout = vShaderLayout;
    if (!shader->ProcessData(shaderProcessor, lpFileName))
    {
        delete shader;
        return NULL;
    }

    shader->bHasNormals = shaderProcessor.bHasNormals;
    shader->bHasColors = shaderProcessor.bHasColors;
    shader->bHasTangents = shaderProcessor.bHasTangents;
    shader->nTextureCoords = shaderProcessor.numTextureCoords;
    shader->hViewProj = shader->GetParameterByName(TEXT("ViewProj"));

    return shader;
}
Ejemplo n.º 25
0
void Mesh::SaveMeshFile()
{
    traceIn(Mesh::SaveMeshFile);

    String path;
    Engine::ConvertResourceName(strName, TEXT("models"), path, FALSE);

    XFileOutputSerializer modelFile;
    if(!modelFile.Open(path, XFILE_CREATEALWAYS))
    {
        AppWarning(TEXT("Could not create model file '%s'"), path);
        return;
    }

    VBData *vbd = VertBuffer->GetData();

    DWORD temp = MODELFILE_VER;
    modelFile << temp;

    Vect::SerializeList(modelFile, vbd->VertList);
    Vect::SerializeList(modelFile, vbd->NormalList);
    modelFile << vbd->TVList[0];
    if(vbd->TVList.Num() < 2)
    {
        temp = 0;
        modelFile << temp;
    }
    else
        modelFile << vbd->TVList[1];
    Vect::SerializeList(modelFile, vbd->TangentList);

    modelFile << nFaces;
    modelFile.Serialize(FaceList, nFaces*sizeof(Face));

    modelFile << nEdges;
    if(nEdges) modelFile.Serialize(EdgeList, nEdges*sizeof(Edge));

    modelFile << DefaultMaterialList;

    modelFile << nSections;
    modelFile.Serialize(SectionList, nSections*sizeof(DrawSection));

    modelFile << bounds;
    modelFile.Close();

    traceOut;
}
Ejemplo n.º 26
0
String& String::InsertChar(UINT pos, TCHAR chr)
{
    if(pos > curLength)
    {
        AppWarning(TEXT("String::InsertChar - bad index specified"));
        return *this;
    }
    
    ++curLength;
    lpString = (TSTR)ReAllocate(lpString, (curLength+1)*sizeof(TCHAR));
    if(curLength > 1)
        mcpyrev(lpString+pos+1, lpString+pos, (curLength-pos)*sizeof(TCHAR));

    lpString[pos] = chr;

    return *this;
}
Ejemplo n.º 27
0
bool MMDeviceAudioSource::Initialize(bool bMic, CTSTR lpID)
{
    const IID IID_IMMDeviceEnumerator    = __uuidof(IMMDeviceEnumerator);
    const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);

    bIsMic = bMic;
    deviceId = lpID;

    HRESULT err = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&mmEnumerator);
    if(FAILED(err))
    {
        AppWarning(TEXT("MMDeviceAudioSource::Initialize(%d): Could not create IMMDeviceEnumerator = %08lX"), (BOOL)bIsMic, err);
        return false;
    }

    return Reinitialize();
}
Ejemplo n.º 28
0
bool D3D10Shader::ProcessData(ShaderProcessor &processor, CTSTR lpFileName)
{
    Params.TransferFrom(processor.Params);
    Samplers.TransferFrom(processor.Samplers);

    constantSize = 0;
    for(UINT i=0; i<Params.Num(); i++)
    {
        ShaderParam &param = Params[i];

        switch(param.type)
        {
            case Parameter_Bool:
            case Parameter_Float:
            case Parameter_Int:         constantSize += sizeof(float); break;
            case Parameter_Vector2:     constantSize += sizeof(float)*2; break;
            case Parameter_Vector:      constantSize += sizeof(float)*3; break;
            case Parameter_Vector4:     constantSize += sizeof(float)*4; break;
            case Parameter_Matrix3x3:   constantSize += sizeof(float)*3*3; break;
            case Parameter_Matrix:      constantSize += sizeof(float)*4*4; break;
        }
    }

    if(constantSize)
    {
        D3D11_BUFFER_DESC bd;
        zero(&bd, sizeof(bd));

        bd.ByteWidth        = (constantSize+15)&0xFFFFFFF0; //align to 128bit boundry
        bd.Usage            = D3D11_USAGE_DYNAMIC;
        bd.BindFlags        = D3D11_BIND_CONSTANT_BUFFER;
        bd.CPUAccessFlags   = D3D11_CPU_ACCESS_WRITE;

        HRESULT err = GetD3D()->CreateBuffer(&bd, NULL, &constantBuffer);
        if(FAILED(err))
        {
            AppWarning(TEXT("Unable to create constant buffer for shader '%s', result = %08lX"), lpFileName, err);
            return false;
        }
    }

    LoadDefaults();

    return true;
}
Ejemplo n.º 29
0
void D3D10System::SetRenderTarget(Texture *texture)
{
    if(curRenderTarget != texture)
    {
        if(texture)
        {
            ID3D10RenderTargetView *view = static_cast<D3D10Texture*>(texture)->renderTarget;
            if(!view)
            {
                AppWarning(TEXT("tried to set a texture that wasn't a render target as a render target"));
                return;
            }

            d3d->OMSetRenderTargets(1, &view, NULL);
        }
        else
            d3d->OMSetRenderTargets(1, &swapRenderView, NULL);

        curRenderTarget = static_cast<D3D10Texture*>(texture);
    }
}
Ejemplo n.º 30
0
String& String::RemoveChar(UINT pos)
{
    if(pos >= curLength)
    {
        AppWarning(TEXT("String::RemoveChar - bad index specified"));
        return *this;
    }
    
    
    if(curLength == 1)
        Clear();
    else
    {
        if(pos < curLength)
            mcpy(lpString+pos, lpString+pos+1, (curLength-pos)*sizeof(TCHAR));
        lpString = (TSTR)ReAllocate(lpString, (curLength)*sizeof(TCHAR));
        --curLength;
    }

    return *this;
}