PDA

View Full Version : same old question, maybe I did not ask the question correctly last time... :)



Quan
01-08-2001, 01:14 PM
Hi,
I'm still new to opengl. I have an opengl view to display a digital image in three bands (rgb). To make it easy, I use the rgba format and then pass it into glDrawPixels function to draw to the screen. everything works fine, resize and everything. Now i've gone back and added an overlaying semi transparent image (or polygon, whatever) and it displays correctly. But when i go to resize the window, the newly drawn item does not get resized. Is there a different surface that i am drawing to which does not know how to resize? This is my resize function, very simple:
>>glViewport(0, 0, w, h);
>>glMatrixMode(GL_PROJECTION);
>>Reset coordinate system
>>glLoadIdentity();
>>gluOrtho2D(0.0,(GLfloat) w,(GLfloat) h,0.0);
>>glMatrixMode(GL_MODELVIEW);
>>glLoadIdentity();

Is there something I am not doing correctly here? Or is it a sin to try to draw over an image after glDrawPixels have been called?

thanx for any help,
-Quan

DFrey
01-08-2001, 02:28 PM
Well, simply put, you are keeping the pixels the same size. By resetting the orthographic projection to the same extent of the viewport, you are keeping the content of the window at a fixed size. Secondly, glDrawPixels output is not transformed like primitives are. The raster position is, but not the output. You can however change the scale of its output by using glPixelZoom.

Quan
01-08-2001, 03:33 PM
Originally posted by DFrey:
Well, simply put, you are keeping the pixels the same size. By resetting the orthographic projection to the same extent of the viewport, you are keeping the content of the window at a fixed size. Secondly, glDrawPixels output is not transformed like primitives are. The raster position is, but not the output. You can however change the scale of its output by using glPixelZoom.

Great, thanx DFrey. But I am still a little confused about the "keeping the window at a fixed size" part. In my RenderImage function, I call glRasterPos and glPixelZoom before I call glDrawPixels. Then to test, I called glRecti to draw a simple rectangle on top of the image. I still don't understand why the image would resize correctly (the pixel sizes gets larger as i zoomed in or resized the window), but the rectangle would just stay the same size. I thought glPixelZoom would also enlarge the pixel size for the rectangle as well. oh well i don't think so... i'll try something else.
thanx for your help.
-Quan