I am trying to catch the error that comes from incompatible image texture resolution in
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->width, img->height, 0, GL_RGB, GL_UNSIGNED_BYTE, imgdata);
1. Compatible resolution, working fine = 1024x1024, 1920x1200, 1920x1080, 704x891
2. Incompatible resolutions, all giving error = 2058x1734, 1018x1280, 591x602, etc.
I don't know why glTexImage2D is working fine with #1 resolutions and giving error with #2 resolutions. I couldn't extract the resolution pattern that it follows means that some resolution are working fine and some not. I don't know why.
Now the issue is, if user try to create a texture with incompatible resolution then OpenGL should catch the error and I should get 0 if texture is not created but glTexImage2D is not returning anything so we are unable to make something secure for user OK. "This resolution is not supported, do not use it." But the issue is OpenGL doesn't not catch the glTexImage2D error.
During run-time execution
cout<<until here working fine..<<endl;
glTexImage2D(......) run-time execution stops here and windows gives not responding error.
cout<<"output of something that never executed"<<endl;
Here If I use glGetError() it never works. Because windows gives error in glTexImage2D.
So, is anybody know how can I catch glTexImage2D error. If it gives error then I display OK "Dont use this Image, Use another one." and return 0.
How to achieve this task ? I also thought about to restrict the user in only some resolutions but this isn't the solution. Right ?
Those image formats not accepted in your case are not multiples of 4. This leads me to the question: Do you set the pixel storage parameters? Set all GL_UNPACK_…
parameters to match your image data right before the call to glTexImage. GL_UNPACK_ALIGNMENT
is of particular interest for your problem.