But i can't understand the following algorithm

function nextHighestPowerOfTwo(x) {
    --x;
    for (var i = 1; i < 32; i <<= 1) {
        x = x | x >> i;
    }
    return x + 1;
}


2011/4/2 a a <[email protected]>:
> My god, the following algorithm is very very brilliant from your
> provider url code.
>
>
> function isPowerOfTwo(x) {
>    return (x & (x - 1)) == 0;
> }
>
> 2011/4/2 Dan Roberts <[email protected]>:
>> http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences
>>
>>> While OpenGL 2.0 and later for the desktop offer full support for
>>> non-power-of-two (NPOT) textures, OpenGL ES 2.0 and WebGL have only limited
>>> NPOT support.
>>
>> Chances are you're using OpenGL ES 1.1 anyways, unless the highest profile
>> is automagically selected for you when creating a context (I have no idea).
>> But if OpenGL ES 2.0 has only limited support, it seems likely NPOT is
>> almost entirely missing in 1.1 Someone more knowledgeable can correct me,
>> but this is likely at least close. Just use power of two sized textures, you
>> can pre-scale them is need be.
>>
>> Cheers,
>> Dan
>>
>> On Apr 1, 2011 6:24 PM, "a a" <[email protected]> wrote:
>>> Why should bitmap with 2, 4, 8, 16, 32, 64, 128.........otherwise, it
>>> will be white board?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to