예제 #1
0
CLbool Cloud::Input::InputManager::Initialise(const Settings& settings)
{
    m_settings = settings;

#pragma warning(suppress: 26490)
    auto result = DirectInput8Create(m_settings.m_hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, reinterpret_cast<LPVOID*>(&m_directInput), 0);
    if (FAILED(result))
    {
        CL_ASSERT_MSG("Couldn't create initialise direct input!");
        Shutdown();
        return false;
    }

    result = m_directInput->CreateDevice(GUID_SysKeyboard, &m_directInputKeyboard, 0);
    if (FAILED(result))
    {
        CL_ASSERT_MSG("Couldn't create initialise direct input keyboard device!");
        Shutdown();
        return false;
    }

    result = m_directInput->CreateDevice(GUID_SysMouse, &m_directInputMouse, 0);
    if (FAILED(result))
    {
        CL_ASSERT_MSG("Couldn't create initialise direct input mouse device!");
        Shutdown();
        return false;
    }

    m_directInputKeyboard->SetCooperativeLevel(m_settings.m_hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
    m_directInputMouse->SetCooperativeLevel(m_settings.m_hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);

    m_directInputKeyboard->SetDataFormat(&c_dfDIKeyboard);
    m_directInputMouse->SetDataFormat(&c_dfDIMouse);

    m_directInputKeyboard->Acquire();
    m_directInputMouse->Acquire();


    m_controllerInputDeadzone = 0.24f * CLfloat(0x7FFF); // Default to 24% of the +/- 32767 range.

    return true;
}
예제 #2
0
TVec3 proj(const TVec4& v)       
{
    TVec3 result;
    
    CL_ASSERT_MSG(v[3] != 0, "(Vec4/proj) last elt. is zero");
    
    result[0] = v[0] / v[3];
    result[1] = v[1] / v[3];
    result[2] = v[2] / v[3];
    
    return result;
}
예제 #3
0
CLbool Cloud::Renderer::SpriteFactory::ParseSprite(const std::string& spriteName, Sprite& spriteOutput)
{
    Json::Value root;
    auto spritePath = "data/assets/sprites/" + spriteName + ".sprite";
    std::ifstream jsonFile(spritePath.c_str());
    Json::Reader reader;

    CLbool parseSuccessful = reader.parse(jsonFile, root);
    if (!parseSuccessful)
    {
        std::stringstream assertMessage;
        assertMessage << "Failed to parse " << spritePath << " file" << std::endl << reader.getFormatedErrorMessages();

        CL_TRACE_CHANNEL("ERROR", assertMessage.str().c_str());
        CL_ASSERT_MSG("Failed to parse effect file!");
        return false;
    }

    // Parsing from json

    spriteOutput.Init(RenderCore::Instance().GetTextureContainer().GetTexture(root["Texture"].asString()));

    return true;
}
예제 #4
0
void Cloud::Renderer::DebugRenderer::AddBar(const ClFloat2& position, const ClFloat2& size, const ClFloat4& colour, CLfloat value, BarDirection direction)
{
    const CLfloat c_minValue = 0.01f;
    ClFloat2 topLeft(0.0f, 0.0f);
    ClFloat2 bottomRight(0.0f, 0.0f);

    switch (direction)
    {
    case Cloud::Renderer::DebugRenderer::BarDirection::Up:
        {
            topLeft.Set(position.x - size.x, position.y - size.y);
            bottomRight.Set(position.x + size.x, position.y + size.y);

            value = Cloud::Math::Max(value, c_minValue);
            CLfloat length = topLeft.y - bottomRight.y;
            topLeft.y = bottomRight.y + length * value;
            
        } break;
    default:
        CL_ASSERT_MSG("Only 'Up' is implemented!");
    }

    AddQuad(topLeft, bottomRight, colour);
}