how does one resize images to be used for textures?
how does one resize images to be used for textures?
- Subject: how does one resize images to be used for textures?
- From: email@hidden
- Date: Thu, 5 Jul 2001 12:16:45 -0400
I'm trying to load images of arbitrary dimensions, to be used as OpenGL
textures. The textures have to have dimensions of powers of 2. Is there
a way to resize these things? The setSize method of NSImageRep does not
seem to do the job. My code is below. It works on images that already
have dimensions as powers of two.
thanks in advance,
Alex
NSBitmapImageRep *myimage;
NSSize mysize;
myimage = [NSBitmapImageRep
imageRepWithContentsOfFile:@"worlds.bmp"];
if(myimage == nil) printf("NIL IMAGE!!!");
mysize.width = 64;
mysize.height = 64;
[myimage setSize: mysize];
data = [myimage bitmapData];
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texName);
glBindTexture(GL_TEXTURE_2D, texName);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, [myimage size].width,
[myimage size].height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);