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

Can I control the quality of the texture?

This topic is 5047 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

I am trying to write a gl program that takes info from the framebuffer, lowers the quality, and then puts that info into a texture. (sort of like rendering into a low-quality texture, but I dont know how to do that.) (pseudocode) I did it using glReadPixels(,P) gluScaleImage(, 64,64,P) //I want the new texture size to be 64x64); glTexImage2D(, 64,64,P) however, that reads the pixels into main memory, scales them, and puts them back into texture memory, which is painfully slow. I found a way to use glCopyImage2D() to get the image from the framebuffer and into the texture that I want, and that is blazing fast because it is a direct video memory to video memory copy, however I dont know how to do a resize on a texture that is niside video memory. can anyone out there help? perhaps rendering to a small texture? perhaps some cool trick with mipmaps? Texture coordinates? any other way to do what I want? help would be very much appreciated. Thanks in advance

Share this post

Link to post
Share on other sites
If you're using double buffering, why don't you do this:

- use glViewport to set the frame buffer to 64x64
- draw your scene (but don't swap the buffers)
- use glCopyTexImage2D to copy the data into your 64x64 texture
- use glViewport to set the frame buffer to whatever resolution you're rendering to (e.g. 800x600)
- clear the colour buffer, depth buffer etc.
- render your scene
- swap the buffers

Essentially you're rendering the scene twice, but the first "pass" is only rendering to a small framebuffer which is the same size as your texture, so its really fast. As you do the first pass before swapping the buffers, and then overwrite it after you save the texture, you won't get any flicker as the scene changes between two resolutions.

Hope that helps

EDIT: typo

[edited by - Custard Slice on February 22, 2004 10:35:26 AM]

Share this post

Link to post
Share on other sites
Overlord, I tried to do that at first, but how do you access the textures generated by gluBuild2DMipmaps fo an Nth level of detail? More importantly, how do you generate mipmaps directly from texture memory? Any ideas on how to help would be nice (Custard''s Idea didn''t work quite right. Probly my fault because it was a good idea and should have worked). However, I did some optimization and my glReadPixels solution is working at a decent enough framerate. Doing it in hardware would be nice tho


Share this post

Link to post
Share on other sites