• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSBitmapImageRep to OpenGL texture
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBitmapImageRep to OpenGL texture


  • Subject: NSBitmapImageRep to OpenGL texture
  • From: Aidas Dailide <email@hidden>
  • Date: Wed, 1 Oct 2003 18:24:31 +0300

Hi,

I am using NSBitmapImageRep's - (id)initWithFocusedViewRect:(NSRect)rect to load "screenshot" of view to NSBitmapImageRep. The next thing what I want to do is to use it as OpenGL texture in OpenGL drawing. I can easily load .bmp files to NSBitmapImageRep and then to OpenGL texture, but for some reason initWithFocusedViewRect doesn't work. Could anyone help me?

I am using code from one of the ports of NeHe tutorials. Here it is:
BOOL success = FALSE;
int bitsPPixel, bytesPRow;
unsigned char *theImageData;
int rowNum, destRowNum;
NSLog(@"ziurim");
if( theImage != nil )
{
NSLog(@"ne nilas");
bitsPPixel = [ theImage bitsPerPixel ];
bytesPRow = [ theImage bytesPerRow ];
if( bitsPPixel == 24 ) // No alpha channel
texFormat[ texIndex ] = GL_RGB;
else if( bitsPPixel == 32 ) // There is an alpha channel
texFormat[ texIndex ] = GL_RGBA;
texSize[ texIndex ].width = [ theImage pixelsWide ];
texSize[ texIndex ].height = [ theImage pixelsHigh ];
texBytes[ texIndex ] = calloc( bytesPRow * texSize[ texIndex ].height,
1 );
if( texBytes[ texIndex ] != NULL )
{
success = TRUE;
// theImageData=[theImage bitmapData];
theImageData = [ theImage bitmapData ];
destRowNum = 0;
for( rowNum = texSize[ texIndex ].height - 1; rowNum >= 0;
rowNum--, destRowNum++ )
{

// Copy the entire row in one shot
memcpy( texBytes[ texIndex ] + ( destRowNum * bytesPRow ),
theImageData + ( rowNum * bytesPRow ),
bytesPRow );
}


}
}

return success;


Thanks,
Aidas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: NSString creating problem when contains chinese font
  • Next by Date: Re: labelling some NSString objects, without making a new class?
  • Previous by thread: Re: NSString creating problem when contains chinese font
  • Next by thread: Re: Call CFM shlb from Cocoa
  • Index(es):
    • Date
    • Thread