当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicsDevice::CastD3D9方法代码示例

本文整理汇总了C++中GraphicsDevice::CastD3D9方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsDevice::CastD3D9方法的具体用法?C++ GraphicsDevice::CastD3D9怎么用?C++ GraphicsDevice::CastD3D9使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice::CastD3D9方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RenderBox

void Indicator::RenderBox(GraphicsDevice &GD, MatrixController &MC, float Radius, const Rectangle3f &Rect, RGBColor Color)
{
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Color);

    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Color);

    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Color);

    Matrix4 Scale = Matrix4::Scaling(Rect.Dimensions());
    Matrix4 Translate = Matrix4::Translation(Rect.Min);

    MC.World = Scale * Translate;

    LPDIRECT3DDEVICE9 Device = GD.CastD3D9().GetDevice();
    
    D3DCOLOR D3DColor = RGBColor(90, 90, 90);
    Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_BLENDFACTOR);
    Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVBLENDFACTOR);
    Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    Device->SetRenderState(D3DRS_BLENDFACTOR, D3DColor);

    _Box.SetColor(Color);
    _Box.Render();

    Device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
开发者ID:kbinani,项目名称:dxrip,代码行数:35,代码来源:Indicator.cpp

示例2: file

void D3D9PixelShader::Reset(GraphicsDevice &graphics)
{
    FreeMemory();

    HRESULT hr;

    _device = graphics.CastD3D9().GetDevice();
    Assert(_device != NULL, "_device == NULL");

    DWORD dwShaderFlags = 0;
    #ifdef DEBUG_PS
        dwShaderFlags |= D3DXSHADER_SKIPOPTIMIZATION | D3DXSHADER_DEBUG;
    #endif

    LPD3DXBUFFER pCode = NULL;
    LPD3DXBUFFER pErrors = NULL;

    PersistentAssert(Utility::FileExists(_shaderFile), String("Shader file not found: ") + _shaderFile);

    // Assemble the vertex shader from the file
    hr = D3DXCompileShaderFromFile( _shaderFile.CString(), NULL, NULL, "PShaderEntry",
                                    "ps_3_0", dwShaderFlags, &pCode,
                                    &pErrors, &_constantTable );
    
    String ErrorString;
    if(pErrors)
    {
        char *ErrorMessage = (char *)pErrors->GetBufferPointer();
        DWORD ErrorLength = pErrors->GetBufferSize();

        ofstream file("ShaderDebug.txt");
        for(UINT i = 0; i < ErrorLength; i++)
        {
            file << ErrorMessage[i];
            ErrorString += String(ErrorMessage[i]);
        }
        file.close();
    }

    PersistentAssert(!FAILED(hr), String("D3DXCompileShaderFromFile failed: ") + ErrorString);

    hr = _device->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(),
                                            &_shader );

    if(pErrors)
    {
        pErrors->Release();
    }
    if(pCode)
    {
        pCode->Release();
    }
    PersistentAssert(!FAILED(hr), "CreatePixelShader failed");
}
开发者ID:dmead,项目名称:sc2bot,代码行数:54,代码来源:D3D9PixelShader.cpp

示例3: FreeMemory

void D3D9Font::Reset(GraphicsDevice &graphics)
{
    FreeMemory();

    _Device = graphics.CastD3D9().GetDevice();
    Assert(_Device != NULL, "Device == NULL");

    HRESULT hr;
    hr = D3DXCreateFont(
            _Device,
            _FontHeight,                 // Height
            0,                           // Width
            _FontWeight,                 // Weight
            1,                           // MipLevels, 0 = autogen mipmaps
            FALSE,                       // Italic
            DEFAULT_CHARSET,             // CharSet
            OUT_DEFAULT_PRECIS,          // OutputPrecision
            DEFAULT_QUALITY,             // Quality
            DEFAULT_PITCH | FF_DONTCARE, // PitchAndFamily
            _FontName.CString(),         // pFaceName
            &_Font);                     // ppFont
    Assert(SUCCEEDED(hr) && _Font != NULL, "D3DXCreateFont failed");
}
开发者ID:kbinani,项目名称:dxrip,代码行数:23,代码来源:D3D9Font.cpp

示例4: Reset

void D3D9VertexShader::Init(const String &Filename, GraphicsDevice &GD)
{
    _ShaderFile = Filename;
    Reset(GD.CastD3D9().GetDevice());
}
开发者ID:ghsoftco,项目名称:basecode14,代码行数:5,代码来源:D3D9VertexShader.cpp

示例5:

void D3D9Texture::Reset(GraphicsDevice &graphics)
{
    _Device = graphics.CastD3D9().GetDevice();
}
开发者ID:kbinani,项目名称:dxrip,代码行数:4,代码来源:D3D9Texture.cpp


注:本文中的GraphicsDevice::CastD3D9方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。