コード例 #1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
String ShaderSourceRepository::shaderSource(ShaderIdent shaderIdent)
{
    String shaderProg;

    CharArray rawSource;
    if (rawShaderSource(shaderIdent, &rawSource))
    {
        if (rawSource.size() > 0)
        {
#ifdef CVF_OPENGL_ES
            // Always version 100 on OpenGL ES
            shaderProg = "#version 100\nprecision highp float;\n";
#else
            // Default on desktop is GLSL 1.2 (OpenGL 2.1) unless the shader explicitly specifies a version
            if (rawSource[0] != '#')
            {
                shaderProg = "#version 120\n";
            }
#endif
    
            shaderProg += rawSource.ptr();
        }
    }

    return shaderProg;
}
コード例 #2
0
//--------------------------------------------------------------------------------------------------
/// Show the trace output in console and DevStudio output window
//--------------------------------------------------------------------------------------------------
void Trace::showTraceOutput(String text, bool addNewLine)
{
#ifdef WIN32
    AllocConsole();

    HANDLE hStdOutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);

    if (hStdOutputHandle)
    {
        unsigned long iDum = 0;
        CharArray ascii = text.toAscii();
        DWORD stringLength = static_cast<DWORD>(System::strlen(ascii.ptr()));

        WriteConsoleA(hStdOutputHandle, ascii.ptr(), stringLength, &iDum, NULL);
        if (addNewLine) WriteConsole(hStdOutputHandle, "\n", 1, &iDum, NULL);
    }
#elif defined(CVF_ANDROID)
    __android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", "%s", text.toAscii().ptr());
#else
    fprintf(stderr, "%s", text.toAscii().ptr());
    if (addNewLine) 
    {
        fprintf(stderr, "\n");
    }
#endif

    // Show output in "Output window" in Visual Studio
#if defined(WIN32) && defined(_DEBUG)
    // Alternativly use OutputDebugStringA(text.toAscii().ptr()); if this does not work on some platforms
    _RPT0(_CRT_WARN, text.toAscii().ptr());
    if (addNewLine)
    {
        _RPT0(_CRT_WARN, "\n");
    }
#endif
}
コード例 #3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
String ShaderSourceProvider::getSourceFromFile(String shaderName)
{
    const String fileName = shaderName + ".glsl";

    size_t i;
    for (i = 0; i < m_searchDirectories.size(); i++)
    {
        String fullPath = m_searchDirectories[i] + fileName;

        CharArray fileContents;
        if (loadFile(fullPath, &fileContents))
        {
            return String(fileContents.ptr());
        }
    }

    return "";
}
コード例 #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void LogDestinationFile::log(const LogEvent& logEvent)
{
    String str;
    bool addLocationInfo = false;

    Logger::Level logEventLevel = logEvent.level();
    if (logEventLevel == Logger::LL_ERROR)
    {
        str = logEvent.source() + "**ERROR**: " + logEvent.message();
        addLocationInfo = true;
    }
    else if (logEventLevel == Logger::LL_WARNING)
    {
        str = logEvent.source() + "(warn):  " + logEvent.message();
    }
    else if (logEventLevel == Logger::LL_INFO)
    {
        str = logEvent.source() + "(i): " + logEvent.message();
    }
    else if (logEventLevel == Logger::LL_DEBUG)
    {
        str = logEvent.source() + "(d): " + logEvent.message();
    }

    if (addLocationInfo)
    {
        str += "\n";
        str += String("        -func: %1\n").arg(logEvent.location().functionName());
        str += String("        -file: %1(%2)").arg(logEvent.location().shortFileName()).arg(logEvent.location().lineNumber());
    }

    CharArray charArrMsg = str.toAscii();
    const char* szMsg = charArrMsg.ptr();

    Mutex::ScopedLock lock(m_mutex);
    writeToFile(szMsg, true);
}