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

Usage of deprecated glGetString( GL_EXTENSIONS ) #8

Open
DashW opened this issue Oct 3, 2014 · 9 comments
Open

Usage of deprecated glGetString( GL_EXTENSIONS ) #8

DashW opened this issue Oct 3, 2014 · 9 comments

Comments

@DashW
Copy link

DashW commented Oct 3, 2014

http://stackoverflow.com/questions/17923782/simple-opengl-image-library-soil-uses-deprecated-functionality

https://www.opengl.org/sdk/docs/man3/xhtml/glGetString.xml

GL_EXTENSIONS has been deprecated as a paremeter to glGetString. All calls to glGetString( GL_EXTENSIONS ) fail under OpenGL 3+ with error GL_INVALID_ENUM. This breaks all query_x_capability functions... which breaks most of SOIL.

Apparently, the correct approach is now to iterate over and compare each extension substring using glGetStringi( GL_EXTENSIONS, i ).

@njcrawford
Copy link
Contributor

I may be interested in implementing this. According to https://www.opengl.org/sdk/docs/man/html/glGetString.xhtml, glGetStringi() is present in 3.0 and up, so this change would exclude devices that only support up to OpenGL 2.1. I think that's probably an acceptable tradeoff, but if anyone thinks differently, please chime in.

For my own reference when I come back to this, the number of extensions can be queried with glGetIntegerv(GL_NUM_EXTENSIONS).

njcrawford added a commit to njcrawford/Simple-OpenGL-Image-Library that referenced this issue Nov 14, 2014
@njcrawford
Copy link
Contributor

I wasn't able to find a cross-platform solution for this issue, but for anyone interested, I have a branch that works for Windows here: https://github.com/njcrawford/Simple-OpenGL-Image-Library/tree/issue-8-attempt2
The definition for GL_NUM_EXTENSIONS introduces a dependency on glext.h from the OpenGL registry, which can be found here: https://www.opengl.org/registry/ (look under the API and Extension Header Files section for downloads)

With that said, I found that my applications were only calling SOIL_load_image_from_memory(), which is a direct pass-through to stbi_load_from_memory(). For my purposes it's far easier to include stb_image.h directly in my source than to update SOIL for OpenGL 3.0 compatibility, so I've stopped working on this issue.

@0nix
Copy link

0nix commented Apr 12, 2017

+1 for this issue.

@jpaoneMines
Copy link

I've solved this issue by having SOIL depend on GLEW. Would that be an acceptable correction/dependency to submit?

@stevenwdv
Copy link

Sad to see this is still not fixed; took me some time to figure out what went wrong :/

@njcrawford
Copy link
Contributor

Just out of curiosity, is anyone using any SOIL functions other than SOIL_load_image() or SOIL_load_image_from_memory()?

@stevenwdv
Copy link

@njcrawford I tried to use SOIL_load_OGL_texture but I'm new to OpenGL and stuff so that may be not the best option or something; I don't know what other functions there are exactly and what the differences are.

@njcrawford
Copy link
Contributor

@stevenwdv It's a bit more work, but you can get about the same effect with code like this:
(This code came from a working program, but I edited it down for conciseness so I can't guarantee it will work as-is)

int MyLoadImage(const char * filename)
{
int x,y,n;
unsigned char * tempData = stbi_load(filename, &x, &y, &n, 0);

// Generate and activate OpenGL texture handle
int tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);

// Give textures a voxel look - optional
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Repeat textures - optional
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

// Match texture data format to the image we loaded
GLuint texDataFormat = 0;
if (n == 3)
{
	texDataFormat = GL_RGB;
}
else if (n == 4)
{
	texDataFormat = GL_RGBA;
}
// Send the image to OpenGL
glTexImage2D(GL_TEXTURE_2D, 0, texDataFormat, w, h, 0, texDataFormat, GL_UNSIGNED_BYTE, tempData);

// Go back to the default texture
glBindTexture(GL_TEXTURE_2D, 0);
// Free stbi data
stbi_image_free((void *)tempData);

return tex;
}

@stevenwdv
Copy link

stevenwdv commented Aug 4, 2018

@njcrawford For now I already got it to work with lodepng (after some struggling with the order of bindBuffer etc.), but I will probably switch to some compressed texture format supported by the GPU like S3TS sooner or later; but thanks anyway!
Edit: Ah it seems like your solution would also work for these compressed images; didn't notice that at first ;)

0kk470 added a commit to 0kk470/learnOpenGL that referenced this issue Aug 7, 2020
2.use stb_image.h to load texture instead of SOIL.h

Why?
GL_EXTENSIONS has been deprecated as a paremeter to glGetString. All calls to glGetString( GL_EXTENSIONS ) fail under OpenGL 3+ with error GL_INVALID_ENUM. This breaks all query_x_capability functions... which breaks most of SOIL.
Check kbranigan/Simple-OpenGL-Image-Library#8
ascherer added a commit to ascherer/HINT that referenced this issue Sep 27, 2023
ascherer added a commit to ascherer/HINT that referenced this issue Sep 27, 2023
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

5 participants