Resize Window\Resize Image

Hi,

I’m just getting my feet wet with OpenGL. And I think this problem is very easy, but I can’t get it.

I have a program that displays a pixmap and some freehand drawing on top of that. I need to resize the image AND the window. I believe I have gotten the image to be bigger (I just duplicated each pixel to the element beside and below it in the array). The window size is initially the same as the image size. When I go to resize the image and window, the window gets bigger but the image is drawn on only the area originally used. It appears to redraw the image and then resize the window–with white everywhere else. The picture is bigger but it ‘wraps’ around on itself. I hope this make some sense, and any help is much appreciated!! This is the code I have (after I have obtained an array that is 4 times bigger than the original–2 x width + 2 x height):

	glutReshapeWindow(2*imageWidth, 2*imageHeight);
	glDrawPixels(imageWidth, imageHeight, GL_RGB, GL_UNSIGNED_BYTE, tmpPixArray);
	copyCurrentImage();
	glutSwapBuffers();

Thanks,
Bob

[This message has been edited by Cerv36 (edited 02-15-2003).]

Try using the pixmap, I assume obtained by glReadPixels, as a texture to be used with a quad which you resize whenever window size changes. Use glTexImage2D to specify the texture as your pixmap. Quad texture coordinates should range from 0 to 1 on both axes.

You must remember a 2D pixel operation is a one to one operation and is not effected by the matrix and is applied directly to the screen. You can not stretch or rotate it, as least not in the way you are calling the function.

Also is not the prefered why to place graphics on the scrren, since it can cause a slowdown.

Best to used a textured map quad with the graphic applied to it, this way is can be stretch, srinked and rotated to fit your needs.

nehe.gamedev.net has a good tutors on this

Originally posted by Cerv36:
[b]Hi,

I’m just getting my feet wet with OpenGL. And I think this problem is very easy, but I can’t get it.

I have a program that displays a pixmap and some freehand drawing on top of that. I need to resize the image AND the window. I believe I have gotten the image to be bigger (I just duplicated each pixel to the element beside and below it in the array). The window size is initially the same as the image size. When I go to resize the image and window, the window gets bigger but the image is drawn on only the area originally used. It appears to redraw the image and then resize the window–with white everywhere else. The picture is bigger but it ‘wraps’ around on itself. I hope this make some sense, and any help is much appreciated!! This is the code I have (after I have obtained an array that is 4 times bigger than the original–2 x width + 2 x height):

  glutReshapeWindow(2*imageWidth, 2*imageHeight);
  glDrawPixels(imageWidth, imageHeight, GL_RGB, GL_UNSIGNED_BYTE, tmpPixArray);
  copyCurrentImage();
  glutSwapBuffers();

Thanks,
Bob

[This message has been edited by Cerv36 (edited 02-15-2003).][/b]