1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| if (m_nBytesPerPixel == 3) { nFormat = GL_BGR_EXT; } else if (m_nBytesPerPixel == 4) { nFormat = GL_BGRA_EXT; }
if (nWidthPowerOfTwo == m_nWidth nHeightPowerOfTwo == m_nHeight) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nWidthPowerOfTwo, nHeightPowerOfTwo, 0, nFormat, GL_UNSIGNED_BYTE, m_byData); } else { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nWidthPowerOfTwo, nHeightPowerOfTwo, 0, nFormat, GL_UNSIGNED_BYTE, NULL); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_nWidth, m_nHeight, nFormat, GL_UNSIGNED_BYTE, m_byData); fTexScaleX = 1.0 * m_nWidth / nWidthPowerOfTwo; fTexScaleY = 1.0 * m_nHeight / nHeightPowerOfTwo; glMatrixMode(GL_TEXTURE); glLoadIdentity(); glScaled(fTexScaleX, fTexScaleY, 1.0); }
|