loading a texture in opengl with carbon

Post: #1
I am trying to figure out OpenGL and I just recently got to the point where I decided that I should know how to load textures to objects. I used GraphicsImporter to load in a jpeg and then created an off screen Gworld and loaded it into that, or at least that's what I thought I did. Then I used glTexImage2D to load it into OpenGL. But here's where things got messed up. When I ran the program, it displayed the jpeg that I loaded at the top left corner of the screen(even though I never told it to) and then when the window opened, the object loads with a weird texture that in no way resembles the image. I am pretty sure that the image somehow never got into memory and that the texture is being loaded from an unregistered memory block, especially since the texture that appears is different every time I open it. I'm pretty confused as of what went wrong. Here's the relevant code:

void LoadTexturesGL(){
MakeFSSpecFromPath("road026.jpg", &spec);
err = GetGraphicsImporterForFile(&spec, &gi);
cr = GraphicsImportGetNaturalBounds(gi, &bounds);
err = QTNewGWorldFromPtr(&gw, k32RGBAPixelFormat, &bounds, NULL, NULL,0, buffer,4 * bounds.right);
cr = GraphicsImportSetGWorld(gi, gw, NULL);
cr = GraphicsImportDraw(gi);
err = CloseComponent(gi);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 4,bounds.right, bounds.bottom, 0,GL_RGBA, GL_UNSIGNED_INT,buffer);

If you have any ideas, please help me out! Thanks!
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
k32RGBAPixelFormat doesn't work on Mac OS X.

working QuickTime texture loading code: http://onesadcookie.is-a-geek.net/svn/repos/QTValuePak/
Quote this message in a reply
Post: #3
Okay, so I switched k32RGBAPixelFormat for k32ARGBPixelFormat, but it still does the same thing.
Quote this message in a reply
Posts: 156
Joined: 2002.11
Post: #4
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES Texture Masking airfire 6 23,174 Mar 17, 2014 07:07 PM
Last Post: baioses
  OpenGL ES Texture Compression ajrs84 9 11,567 May 7, 2013 03:36 PM
Last Post: ajrs84
  OpenGL ES Texture Masking dalasjoe sin 0 5,344 Apr 13, 2012 12:17 AM
Last Post: dalasjoe sin
  Texture in OpenGL ES 2 looks pixelated vunterslaush 18 39,323 Aug 30, 2011 09:44 PM
Last Post: Frogblast
  Lighting and changing texture colors in OpenGL agreendev 2 11,007 Aug 13, 2010 03:47 PM
Last Post: agreendev