Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting images with non-power-of-two width does not work #27

Open
PFischbeck opened this issue Aug 31, 2014 · 5 comments
Open

converting images with non-power-of-two width does not work #27

PFischbeck opened this issue Aug 31, 2014 · 5 comments

Comments

@PFischbeck
Copy link

When converting this image
hpicgs
with glraw-cmd -f GL_RGB -t GL_UNSIGNED_BYTE hpicgs.png, the program glraw-cmd crashes. The glraw file is generated, but it has a strip in the top row:
hpicgs-strip

I did this on Windows 8.1.

@cgcostume
Copy link
Member

thanks for the report. what i found:
converting images with a power-of-two width always works. but for textures with non-power-of-two width, glGetTexImage always returns GL_RGBA format, ignoring the provided format. this obviously writes more data into the QByteArray than anticipated, and either results in a crash in glGetTexImage, glFinalize, or when destroying the QByteArray instance, which asserts that data with more than reserved size was written.

The following images can be used to try this (also with various formats like GL_RED etc.) and debug with, e.g., photoshop raw import.

This works not due to non-power-of-two width of 111px (111x128px):
hpicgs-111-128

These are working (128x111px and 128x128px):
hpicgs-128-111 and hpicgs-128-128

Note: i also tried to use glReadPixels instead of glGetTexImage, but the same issue occured. Furthermore, i tested on IntelHD, NVIDIA, and AMD mobility, with the exact same results.

To fix this issue, we need to handle this case explicitly; getting texture data in GL_RGBA and selecting the channels depending on the requested format. I hope this is not an issue for compressed textures though, because this fix would not apply on these.

@cgcostume cgcostume changed the title Converting a certain image will crash glraw-cmd and leave a strip in the result converting images with non-power-of-two width does not work Sep 1, 2014
@cgcostume
Copy link
Member

alternative approach: extend the texture to match the next power of two width and fill the additional vertical lines with some fill color. after reading it back in the desired format, remove the filled area. Note: this would only work for uncompressed textures...

@cgcostume
Copy link
Member

in any case - if no "good" solution is available or until this is not fixed, a warning/error should be provided.

@mjendruk
Copy link
Contributor

I did some tests permutating the pictures, formats and types. I came up with this, the checked cases crash:
screen shot 2014-11-27 at 00 40 21
I think we should present our issue to some opengl mailing list.

@cgcostume
Copy link
Member

thanks a lot, this is good - we could try this on stackoverflow or here: https://www.opengl.org/discussion_boards/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants