# glGetTexImage crashes, and I don't know why

This topic is 2544 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi!

My game engine is crashing (silently exiting) on one user's computer (Win XP with a Radeon X1600 with the latest drivers), but it's working fine everywhere else (both on Mac, Windows and Linux). I've been unable to reproduce it, so debugging consists of sending that user executables that print information to a log file.

Through fprintf-debugging, I've been able to find that the crash happens on this line:
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, newFreezer -> backdropTexture);

But I don't know why this is happening or what to do about it. I have checked that the texture is the size I expect (with glGetTexLevelParameteriv), I've set GL_PACK_ALIGNMENT to 1, I've checked the pointer after allocating the memory (newFreezer->backdropTexture = new GLubyte [w*h*4]). I have also checked glGetError before the call that crashes, and it's clean.

Does anyone have any ideas? I've tried everything I can think of.

(In case you're interested, the game where the crash was found in is Life Flashes By. The crash happens when clicking "New Game" from the main menu.)

##### Share on other sites
You seem to be doing and checking everything, and from all I can tell, it should just work.

What I'd try is add a glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); just to be 101% sure that no buffer is bound (which would transform your pointer into an offset and cause an crash).
And, I would try to allocate a little more memory (rounding the width up to the nearest 4) in case there is a driver bug so that GL_PACK_ALIGNMENT isn't properly respected. Or, try and just allocate a buffer twice as much as you need. If this "magically" removes the crash, you'll know.

##### Share on other sites
Why do you need glGetTexImage? Aren't your textures on the harddrive?

##### Share on other sites
Hm... this seems strange, has he tried some different drivers? (maybe older ones) - because it might be driver bug (but I dont think so).

It can also be hidden in that pointer you're addressing .. but then it wouldn't work on more GPUs, not just particulary this one. I can test it on some Radeons if you havent (HD2900, HD6800 or Mobility HD5470) if it works (both linux and windows), if it works on AMD gpus, if you wish (if you have demo or such somewhere).

##### Share on other sites
Quote:
 Original post by samothWhat I'd try is add a glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); just to be 101% sure that no buffer is bound (which would transform your pointer into an offset and cause an crash).

Thanks, I'll try that.

Quote:
 And, I would try to allocate a little more memory (rounding the width up to the nearest 4) in case there is a driver bug so that GL_PACK_ALIGNMENT isn't properly respected. Or, try and just allocate a buffer twice as much as you need. If this "magically" removes the crash, you'll know.

I've tried that with a buffer four times the needed size. Did nothing.

Quote:
 Original post by V-manWhy do you need glGetTexImage? Aren't your textures on the harddrive?

It's a scene that's rendered for later use as a texture. (In this case to be used for a transition between scenes.)

Quote:
 Original post by Vilem OtteHm... this seems strange, has he tried some different drivers? (maybe older ones) - because it might be driver bug (but I dont think so).

Quote:
 It can also be hidden in that pointer you're addressing .. but then it wouldn't work on more GPUs, not just particulary this one. I can test it on some Radeons if you havent (HD2900, HD6800 or Mobility HD5470) if it works (both linux and windows), if it works on AMD gpus, if you wish (if you have demo or such somewhere).

My Windows computer has a HD4550 on Vista, so I know it's at least not a problem with all ATI cards, but if you don't mind testing it, that'd be great. If file size is not an issue, the link to the full game Life Flashes By is in my first post. It's worth checking out anyway IMHO. (This game is not by me - I'm only responsible for the engine.) Or I could put together a smaller test.

##### Share on other sites
Huh... strange, on all Radeons I have it seems working good (HD2900, HD6800 and HD5470). I even don't have same updated versions of drivers everywhere ... on linux too (through WinE).

##### Share on other sites
Quote:
 Original post by TrumgottistIt's a scene that's rendered for later use as a texture. (In this case to be used for a transition between scenes.)

In that case, bind the FBO and use glReadPixels.

Yes, since it sounds like a driver bug, ask your user to try some other driver.

##### Share on other sites
Re-writing the code to render the texture and then use readPixels worked. Thanks!

##### Share on other sites

This topic is 2544 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628676
• Total Posts
2984179

• 13
• 12
• 9
• 10
• 10