return !(theNumber & (theNumber - 1));
}
-static inline GLsizei getPowerOfTwo (const GLsizei theNumber,
- const GLsizei theThreshold)
-{
- for (GLsizei p2 = 2; p2 <= theThreshold; p2 <<= 1)
- {
- if (theNumber <= p2)
- {
- return p2;
- }
- }
- return theThreshold;
-}
-
OpenGl_FrameBuffer::OpenGl_FrameBuffer (GLint theTextureFormat)
: mySizeX (0),
mySizeY (0),
// upscale width/height if numbers are odd
if (toForcePowerOfTwo)
{
- GLint aMaxTexDim = 2048;
- glGetIntegerv (GL_MAX_TEXTURE_SIZE, &aMaxTexDim);
- mySizeX = getPowerOfTwo (theViewportSizeX, aMaxTexDim);
- mySizeY = getPowerOfTwo (theViewportSizeY, aMaxTexDim);
+ mySizeX = OpenGl_Context::GetPowerOfTwo (theViewportSizeX, theGlContext->MaxTextureSize());
+ mySizeY = OpenGl_Context::GetPowerOfTwo (theViewportSizeY, theGlContext->MaxTextureSize());
}
else
{