Scaling Textures
Hi all,
I''m loading and preparing textures using code culled from Nehe''s tutorials (lesson 6) and it works fine (thanks Nehe!).
What I want to know is this... Once I load a bitmap I would like to scale it and reduce its size, say form 256x256 to 128x128... how do I do that?
Thanks
If you make the texture with glTexImage2D you can specify 1 as your mipmap level and it should do everything for you.
http://msdn.microsoft.com/library/en-us/opengl/glfunc03_16jo.asp?frame=true
http://msdn.microsoft.com/library/en-us/opengl/glfunc03_16jo.asp?frame=true
Hmmm... specifying one as the level of detail turns the texture into pure white.
Besides I''m not sure that''s what I''d want to do.... essentially I want to reduce the amount of video memory used to store a texture by reducing the texture size, but without changing the actual bitmap file.
Besides I''m not sure that''s what I''d want to do.... essentially I want to reduce the amount of video memory used to store a texture by reducing the texture size, but without changing the actual bitmap file.
The solution is to make your own, homebrew re-scaler...
For a simple 256x256 to 128x128, it would look something like this
for(y=0;y<256;y++)
for(x=0;x<256;x++)
dst[x + (y*surface_pitch)] = src[(x*2) + ((y*2)*surface_pitch)];
Scaling images down can get pretty complicated.. Weighted interpolation, more accurate scaling techniques, and different dimentioned images...
Anyways, that''s a good starting ground.
-=|Mr.Oreo|=-
Code Monkey, Serpent Engine
For a simple 256x256 to 128x128, it would look something like this
for(y=0;y<256;y++)
for(x=0;x<256;x++)
dst[x + (y*surface_pitch)] = src[(x*2) + ((y*2)*surface_pitch)];
Scaling images down can get pretty complicated.. Weighted interpolation, more accurate scaling techniques, and different dimentioned images...
Anyways, that''s a good starting ground.
-=|Mr.Oreo|=-
Code Monkey, Serpent Engine
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement