Jump to content

  • Log In with Google      Sign In   
  • Create Account

gluScaleImage, HELP?!?!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 drago   Members   -  Reputation: 150

Like
Likes
Like

Posted 28 April 2000 - 01:43 PM

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

Sponsor:

#2 drago   Members   -  Reputation: 150

Like
Likes
Like

Posted 29 April 2000 - 02:09 AM

Here is the modified code:


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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS