PDA

View Full Version : How do I get the width and height of a texture



justin123
11-28-2009, 03:29 PM
How do i get the width and height of image I loaded as a texture? I used SOIL to load the image.

Thanks,

~justin123

ZbuffeR
11-28-2009, 04:59 PM
The normal way is to "tell OpenGL the size of the texture", not the way round. This SOIL library seem too basic for your needs. Maybe hacking through its source code will provide you an API to ask for the texture size.

justin123
11-28-2009, 08:33 PM
I'll provide it with the size.

Thanks

AdrianPi
11-28-2009, 09:21 PM
int w, h;
int miplevel = 0;
glGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_WIDTH, &w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_HEIGHT, &h);