how to scale a rgb image with opengl api
I am a beginner and have a src_buffer of RGB image 800x480 and dst_buffer of RGB image 720x480, want to scaler a RGB image with opengl API, here is my source code, but it doesn't work:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 800, 480, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, src_buffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
glScalef(0.9, 1.0, 1.0);
glReadPixels(0, 0, 720, 480, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, dst_buffer);
But the data of dst_buffer is same as the data of src_buffer, could you point out where I am wrong?
Last edited by ccczzzlll; 08-16-2012 at 07:37 PM.
It's not entirely the same. It only has the first 720 horizontal pixels, for example.
You gave OpenGL image data. Then you read part of that same image data back.
OpenGL isn't really for doing image scaling. That's something you could do easily enough on the CPU, and probably faster (no round-trip of copying the data to the GPU and then copying the scaled data back).
No, I compared all data, it is same. Actually, it will run on embedded system, CPU is too slow for this kind process and consume CPU usage.
Originally Posted by Alfonse Reinheart