• 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
Re: Problem applying texture to rectangle.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem applying texture to rectangle.


  • Subject: Re: Problem applying texture to rectangle.
  • From: Jon Trainer <email@hidden>
  • Date: Sun, 3 Jun 2007 08:39:49 -0400

I recently found these two forum discussions about this very issue:

http://www.idevgames.com/forum/showthread.php? t=11806&highlight=texture+loading

	http://www.idevgames.com/forum/showthread.php?t=13651&highlight=texture

Hope this helps...

Jon Trainer
http://outerlevel.com


On Jun 3, 2007, at 12:05 AM, Ian was here wrote:

I am trying to attach a texture to a rectangle. I've
Googled the heck out of this and have tried various
configurations, but cannot get the texture to apply.
All I get is a white rectangle. Can anyone tell me
what's NOT going on here?



- (void)awakeFromNib
{
	// Make OpenGL commands render into our GL context.

	NSOpenGLContext		*glContext = [self openGLContext];

	[glContext makeCurrentContext];


	cameraEyeX = 1.0;
	cameraEyeY = 0.0;
	cameraEyeZ = 4.0;
	cameraCenterX = 0.0;
	cameraCenterY = 0.0;
	cameraCenterZ = 0.0;
	cameraUpX = 0.0;
	cameraUpY = 1.0;
	cameraUpZ = 0.0;


	// Setup texture image.

	glEnable( GL_TEXTURE_2D );


	NSImage		*image = [NSImage imageNamed:@"myImage"];
	NSBitmapImageRep	*bitmapImageRep = [[NSBitmapImageRep
alloc] initWithData:[image TIFFRepresentation]];


glGenTextures( 1, &testTexture ); glBindTexture( GL_TEXTURE_2D, testTexture ); glPixelStorei( GL_UNPACK_ROW_LENGTH, [bitmapImageRep pixelsWide] ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, (GLsizei)[bitmapImageRep pixelsWide], (GLsizei)[bitmapImageRep pixelsHigh], 0, GL_RGB, GL_UNSIGNED_BYTE, [bitmapImageRep bitmapData] ); [bitmapImageRep release]; }



- (void)drawRect:(NSRect)rect
{
	// Clear the buffers.

	glClearColor( 0.0, 0.0, 0.0, 1.0 );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );


// Set the camera position. glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( cameraEyeY * sin( cameraEyeZ ), cameraEyeY * cos( cameraEyeX ), cameraEyeZ, cameraCenterX, cameraCenterY, cameraCenterZ, cameraUpX, cameraUpY, cameraUpZ );


// Draw a rectangle with the texture image applied to it.

	glBegin( GL_QUADS );
		glTexCoord2f( 0.0, 0.0 );
		glVertex3f( -2.0, -2.0, 0.0 );
		glTexCoord2f( 0.0, 1.0 );
		glVertex3f( -2.0, 2.0, 0.0 );
		glTexCoord2f( 1.0, 1.0 );
		glVertex3f( 2.0, 2.0, 0.0 );
		glTexCoord2f( 1.0, 0.0 );
		glVertex3f( 2.0, -2.0, 0.0 );
	glEnd();

	glFlush();
}



Thanks!


______________________________________________________________________ ______________
Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Problem applying texture to rectangle.
      • From: Ian was here <email@hidden>
References: 
 >Problem applying texture to rectangle. (From: Ian was here <email@hidden>)

  • Prev by Date: Re: String Contains String
  • Next by Date: Re: Creating dynamic views
  • Previous by thread: Problem applying texture to rectangle.
  • Next by thread: Re: Problem applying texture to rectangle.
  • Index(es):
    • Date
    • Thread