| 1907 | static int g_minor_version = 0; |
| 1908 | |
| 1909 | static void ParseVersionFromString(int *pOutMajor, int *pOutMinor, const char *strVersion) |
| 1910 | { |
| 1911 | const char *strDotPos = NULL; |
| 1912 | int iLength = 0; |
| 1913 | char strWorkBuff[10]; |
| 1914 | *pOutMinor = 0; |
| 1915 | *pOutMajor = 0; |
| 1916 | |
| 1917 | strDotPos = strchr(strVersion, '.'); |
| 1918 | if(!strDotPos) |
| 1919 | return; |
| 1920 | |
| 1921 | iLength = (int)((ptrdiff_t)strDotPos - (ptrdiff_t)strVersion); |
| 1922 | strncpy(strWorkBuff, strVersion, static_cast<size_t>(iLength)); |
| 1923 | strWorkBuff[iLength] = '\0'; |
| 1924 | |
| 1925 | *pOutMajor = atoi(strWorkBuff); |
| 1926 | strDotPos = strchr(strVersion + iLength + 1, ' '); |
| 1927 | if(!strDotPos) |
| 1928 | { |
| 1929 | /*No extra data. Take the whole rest of the string.*/ |
| 1930 | strcpy(strWorkBuff, strVersion + iLength + 1); |
| 1931 | } |
| 1932 | else |
| 1933 | { |
| 1934 | /*Copy only up until the space.*/ |
| 1935 | int iLengthMinor = (int)((ptrdiff_t)strDotPos - (ptrdiff_t)strVersion); |
| 1936 | iLengthMinor = iLengthMinor - (iLength + 1); |
| 1937 | strncpy(strWorkBuff, strVersion + iLength + 1, static_cast<size_t>(iLengthMinor)); |
| 1938 | strWorkBuff[iLengthMinor] = '\0'; |
| 1939 | } |
| 1940 | |
| 1941 | *pOutMinor = atoi(strWorkBuff); |
| 1942 | } |
| 1943 | |
| 1944 | static void GetGLVersion(void) |
| 1945 | { |