Texture loading code check.

Moderator
Posts: 102
Joined: 2003.07
Post: #1
Here is some code I am using to load RGB data into an array of GLubytes and I was just wondering if there were any problems with it

Code:
// in HeightMapView.h

    GLubyte lowestTexture  [3] [256] [256];
    GLubyte lowTexture     [3] [256] [256];
    GLubyte highTexture    [3] [256] [256];
    GLubyte highestTexture [3] [256] [256];




//in HeightMapView.m

-(void) loadAltitudePictureLowest: (NSString *) lowestName low: (NSString *) lowName high: (NSString *) highName highest: (NSString *) highestName
{
    NSBitmapImageRep *bitmap;
    NSImage *image;
    long i;
    long j;
    int bitmapSize;
    
    image = [ NSImage imageNamed: lowestName];
    
    bitmap = [[NSBitmapImageRep alloc]initWithData: [ image TIFFRepresentation]];
    bitmapSize = [bitmap size].width;
    if (bitmap == nil)
    { NSLog(@"lowestTexture: not loaded!"); return;}
    
    for (i = 0; i <  bitmapSize; i++)
    {
        for( j = 0; j < bitmapSize; j++)
        {
            lowestTexture[0] [i] [j] = (GLubyte) ([bitmap bitmapData][(i+(j*bitmapSize))*24/8]);
            lowestTexture[1] [i] [j] = (GLubyte) ([bitmap bitmapData][(i+(j*bitmapSize))*24/8+1]);
            lowestTexture[2] [i] [j] = (GLubyte) ([bitmap bitmapData][(i+(j*bitmapSize))*24/8+2]);
        }
    }


I think that's about all of the relevant code for this particular function

the textures are 256x256 pixels in size, all I want to know is "will this load the image data into the textures properly?"

-CarbonX
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Howto check whether Ipod is playing music Bersaelor 2 4,366 Jan 2, 2010 09:54 AM
Last Post: Bersaelor
  iPhone texture loading issue yotryu 0 3,462 Mar 11, 2009 03:40 AM
Last Post: yotryu
  Texture Mapping: Loading a texture from a .bmp file? ishrock 5 6,476 Dec 13, 2008 09:27 AM
Last Post: ThemsAllTook
  OpenGL Texture Loading &amp; Sprites corporatenewt 2 11,117 Jan 30, 2008 12:39 PM
Last Post: ynda20
  Texture Loading in Cocoa... dave05 3 8,155 Dec 11, 2007 03:12 AM
Last Post: DoG