🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
gluScaleImage, HELP?!?!
Can anyone explain me how to use the gluScaleImage function?
Let me get more specific.
gluScaleImage(GLenum format, GLint widthin, GLint heightin, GLenum typein, const void *datain, GLint widthout, GLint heightout, GLenum typeout, void *dataout);
The problem is that i want to be able to load an image with wrong dimensions e.g 144x200 and scale it to e.g 256 x 256 , so that the image data can be uploaded into a texture object.
What i do is this (in pseudo code):
- Copy texture data
- Calculate closest valid dimensions (64 x 64, 128 x 128, etc.)
- Delete the original texture data
- Allocate memory for the original texture data
- call gluScaleImage()
This doesn't work, I only see one line at the bottom of the quad (that line seems the be correct).
After copying the texture data, I check if(pCopiedTextureData[100] == pOriginalTextureData[100]) to see if the copying worked, it does.
Then I checked if the calculated valid dimensions were really valid, so I did and they were. So no problem there.
So now I checked if(pCopiedTextureData[100] == pOriginalTextureData[100]) after i deleted and allocated new memory for the pOriginalTextureData, AND THEY EQUAL?!?!
So I believe that the problem lies there.
----------
Drago
Edited by - drago on 4/29/00 7:51:30 AM
Here is the modified code:
----------
Drago
Edited by - drago on 4/29/00 10:31:54 AM
typedef unsigned char byte;typedef unsigned int uint;void CTexture::ScaleTexture(byte *pTexData, uint nTexWidth, uint nTexHeight, uint nTexColorDepth, GLenum format){ // Copy the original texture data uint nTempTexWidth = nTexWidth; uint nTempTexHeight = nTexHeight; uint nTempTexColorDepth = nTexColorDepth; uint nTempTexMemSpace = nTempTexWidth * nTempTexHeight * (nTempTexColorDepth / 8); byte *pTempTexData = new byte[nTexMemSpace]; memcpy(pTempTexData, pTexData, nTexMemSpace); // Set new texture properties for the original texture data nTexWidth = nTexHeight = 256; // Delete the original texture data and allocate new memory for the scaled texture delete [] pTexData; uint nScaledTexMemSpace = nTexWidth * nTexHeight * (nTexColorDepth / 8); pTexData = new byte[nScaledTexMemSpace]; // Scale the texture gluScaleImage(format, nTempTexWidth, nTempTexHeight, GL_UNSIGNED_BYTE, pTempTexData, nTexWidth, nTexHeight, GL_UNSIGNED_BYTE, pTexData);}
----------
Drago
Edited by - drago on 4/29/00 10:31:54 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement