Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SiN

finding the dimensions of a texture

This topic is 5632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi i am coding in c++, after creating a texture and storing it in a GLuint variable, is there any way i can retrieve the dimensions of that texture in pixels? i dont wanna go with a class-based solution for textures, so dont bother suggesting that thanx! SiN

Share this post


Link to post
Share on other sites
Advertisement
thanx alot ... but, well, im pretty much a c++ newbie, although i have lots of java experience (so im good w/ the syntax and oop).

i understand that the 4th parameter should be a pointer into which you want the information to be stored, i cant seem to get it to work ... heres the code im using :

/////////////////////////////////////////////////

GLfloat xSize = 0;
GLfloat ySize = 0;

GLfloat *pxSize = 0;
GLfloat *pySize = 0;

pxSize = &xSize;
pySize = &ySize;

glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, pxSize );
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, pySize );

delete pxSize;
delete pySize;

///////////////////////////////////////////////////

im pretty sure that should work (although i dont have much experience with pointers), but c++ gives me all sorts of access violation errors ... that cant be good ! :D

help, anyone? thanx!

SiN

Share this post


Link to post
Share on other sites
There''s no need to delete anything, you never allocated anything.

GLfloat xSize, ySize;

glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &xSize);
glGetTexLevelParameterfv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &ySize);


Share this post


Link to post
Share on other sites
hey, great stuff, works perfectly !

i actually tried that before, but i think i forgot to remove the delete statements ....

thanx again !

SiN

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!