| 34 | } |
| 35 | |
| 36 | void CGLSLCompiler::ParseLine(std::string &Line, const char *pReadLine, EGLSLShaderCompilerType Type) |
| 37 | { |
| 38 | EBackendType BackendType = m_IsOpenGLES ? BACKEND_TYPE_OPENGL_ES : BACKEND_TYPE_OPENGL; |
| 39 | bool IsNewOpenGL = (BackendType == BACKEND_TYPE_OPENGL ? (m_OpenGLVersionMajor >= 4 || (m_OpenGLVersionMajor == 3 && m_OpenGLVersionMinor == 3)) : m_OpenGLVersionMajor >= 3); |
| 40 | if(!IsNewOpenGL) |
| 41 | { |
| 42 | const char *pBuff = pReadLine; |
| 43 | char aTmpStr[1024]; |
| 44 | size_t TmpStrSize = 0; |
| 45 | while(*pBuff) |
| 46 | { |
| 47 | while(*pBuff && str_isspace(*pBuff)) |
| 48 | { |
| 49 | Line.append(1, *pBuff); |
| 50 | ++pBuff; |
| 51 | } |
| 52 | |
| 53 | while(*pBuff && !str_isspace(*pBuff) && *pBuff != '(' && *pBuff != '.') |
| 54 | { |
| 55 | aTmpStr[TmpStrSize++] = *pBuff; |
| 56 | ++pBuff; |
| 57 | } |
| 58 | |
| 59 | if(TmpStrSize > 0) |
| 60 | { |
| 61 | aTmpStr[TmpStrSize] = 0; |
| 62 | TmpStrSize = 0; |
| 63 | if(str_comp(aTmpStr, "layout") == 0) |
| 64 | { |
| 65 | //search for ' in' |
| 66 | while(*pBuff && (*pBuff != ' ' || (*(pBuff + 1) && *(pBuff + 1) != 'i') || *(pBuff + 2) != 'n')) |
| 67 | { |
| 68 | ++pBuff; |
| 69 | } |
| 70 | |
| 71 | if(*pBuff == ' ' && *(pBuff + 1) == 'i' && *(pBuff + 2) == 'n') |
| 72 | { |
| 73 | pBuff += 3; |
| 74 | Line.append("attribute"); |
| 75 | Line.append(pBuff); |
| 76 | return; |
| 77 | } |
| 78 | else |
| 79 | { |
| 80 | dbg_msg("shadercompiler", "Fix shader for older OpenGL versions."); |
| 81 | } |
| 82 | } |
| 83 | else if(str_comp(aTmpStr, "noperspective") == 0 || str_comp(aTmpStr, "smooth") == 0 || str_comp(aTmpStr, "flat") == 0) |
| 84 | { |
| 85 | //search for 'in' or 'out' |
| 86 | while(*pBuff && ((*pBuff != 'i' || *(pBuff + 1) != 'n') && (*pBuff != 'o' || (*(pBuff + 1) && *(pBuff + 1) != 'u') || *(pBuff + 2) != 't'))) |
| 87 | { |
| 88 | // append anything that is inbetween noperspective & in/out vars |
| 89 | Line.push_back(*pBuff); |
| 90 | ++pBuff; |
| 91 | } |
| 92 | |
| 93 | bool Found = false; |
no test coverage detected