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

Division by Zero in SOIL_load_OGL_texture on VS2017 15.9.11 #24

Closed
SpartanJ opened this issue Apr 20, 2019 · 5 comments
Closed

Division by Zero in SOIL_load_OGL_texture on VS2017 15.9.11 #24

SpartanJ opened this issue Apr 20, 2019 · 5 comments
Labels
bug Something isn't working major

Comments

@SpartanJ
Copy link
Owner

Original report by Michael Legner (Bitbucket: Sokar, GitHub: Sokar).


Hi,

I'm currently working with the Book "Computer Graphics Programming in OpenGL with C++" ( http://merclearning.com/titles/Computer_Graphics_Programming_in_OpenGL_with_C++.html ) which uses your library to load textures.

Unfortunatly, I encountered a problem with it: just calling SOIL_load_OGL_texture as described in the book results in division by zero exception.

Code:
GLuint texId = SOIL_load_OGL_texture(texFilePath.c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);

texFilePath is a std::string and valid path, otherwise SOIL results in "unable to fopen" error. Loading with stb_image.h works. I'm on Windows 10 x64 in Visual Studio 2017 Community Edition Version 15.9.11.

@SpartanJ
Copy link
Owner Author

Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).


Hi Michael!
Can you please share:

  1. A minimal working example.
  2. The source image.
  3. Indicate the line / the stack trace were the division by zero is happening.

Thanks.

@SpartanJ
Copy link
Owner Author

Original comment by Michael Legner (Bitbucket: Sokar, GitHub: Sokar).


Hi Martin,

If created a small application with which I can reproduce it just fine: https://bitbucket.org/Sokar/soil_issue24/src/master/
Only cloning the repo somewhere and starting the solution file with VS2017 should be enough to compile. I tried it on a second computer and it works fine.

the image use ist "img_test.bmp" from the bin folder of SOIL2.

I also got a bit more information, the exception happens in Line 1618 of Soil2.c which reads

#!c++

new_width = iwidth / reduce_block_x;

with reduce_block_x being zero.

soil2_issue24.PNG

I hope it helps to reproduce the exception.

@SpartanJ
Copy link
Owner Author

Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).


You must initialize an OpenGL context before trying to load any image. Your example will never work. It's crashing in that line because it's being unable to determine the max texture size, because there's no GL context to obtain it.

Regards

@SpartanJ
Copy link
Owner Author

Original comment by Michael Legner (Bitbucket: Sokar, GitHub: Sokar).


Your right. I just checked with a different project that has an OpenGL context initialized and works. I wasn't aware of that, even though it makes sense.
And sorry for the delay, had some other stuff going on.

@SpartanJ
Copy link
Owner Author

Original comment by Michael Legner (Bitbucket: Sokar, GitHub: Sokar).


missing OpenGL context, not an actual bug.

@SpartanJ SpartanJ added major bug Something isn't working labels Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major
Projects
None yet
Development

No branches or pull requests

1 participant