Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen I load a texture as RGBA4444 in openGL, how much memory is consumed in the device?
    primarykey
    data
    text
    <p>How much memory will consume a texture loaded with this method ?</p> <p>With this method, will a 1024x1024 texture consume 4MB anyway ? ( regardless of loading it as RGBA4444 ) ?</p> <pre><code>-(void)loadTexture:(NSString*)nombre { CGImageRef textureImage =[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:nombre ofType:nil]].CGImage; if (textureImage == nil) { NSLog(@"Failed to load texture image"); return; } // Dimensiones de nuestra imagen imageSizeX= CGImageGetWidth(textureImage); imageSizeY= CGImageGetHeight(textureImage); textureWidth = NextPowerOfTwo(imageSizeX); textureHeight = NextPowerOfTwo(imageSizeY); GLubyte *textureData = (GLubyte *)calloc(1,textureWidth * textureHeight * 4); CGContextRef textureContext = CGBitmapContextCreate(textureData, textureWidth,textureHeight,8, textureWidth * 4,CGImageGetColorSpace(textureImage),kCGImageAlphaPremultipliedLast ); CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)textureWidth, (float)textureHeight), textureImage); /**************** Convert data to RGBA4444******************/ //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" void *tempData = malloc(textureWidth * textureHeight * 2); unsigned int* inPixel32 = (unsigned int*)textureData; unsigned short* outPixel16 = (unsigned short*)tempData; for(int i = 0; i &lt; textureWidth * textureHeight ; ++i, ++inPixel32) *outPixel16++ = ((((*inPixel32 &gt;&gt; 0) &amp; 0xFF) &gt;&gt; 4) &lt;&lt; 12) | // R ((((*inPixel32 &gt;&gt; 8) &amp; 0xFF) &gt;&gt; 4) &lt;&lt; 8) | // G ((((*inPixel32 &gt;&gt; 16) &amp; 0xFF) &gt;&gt; 4) &lt;&lt; 4) | // B ((((*inPixel32 &gt;&gt; 24) &amp; 0xFF) &gt;&gt; 4) &lt;&lt; 0); // A free(textureData); textureData = tempData; // Ya no necesitamos el bitmap, lo liberamos CGContextRelease(textureContext); glGenTextures(1, &amp;textures[0]); glBindTexture(GL_TEXTURE_2D, textures[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, textureData); free(textureData); //glEnable(GL_BLEND); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload