is it possible to stretch a 3D scene in openGL?

I know it is possible in glOrtho() but how would I make a 3D scene stretch.

for example if I rendered a cube, in the middle of a window, and then made the window longer, instead of the cube stretching, I would see more to the left and right of it, and I do not want this :(.

I think you'll have to reset the viewport on resize. Using the window's size in the viewport *should* give you the desired effect.

hi again:).
I'm not 100% sure what you mean by

window's size in the view port

but here is my resize handling code

void Window::UpdateGLProjection()
{
	GetDimensions();
	if(fullscreen == true)
    {
        glViewport(0, 0, ScreenWidth, ScreenHeight);
    }
    else
    {
    	if(ClientHeight == 0)
    	{
    		ClientHeight = 1;
		}
		glViewport(0, 0, ClientWidth, ClientHeight);
	}

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	if(dimensions == 2)
	{
		glOrtho(0, WorldWidth, WorldHeight, 0, -1, 1);
	}
	else if(dimensions == 3)
	{
		gluPerspective(45, float(ClientWidth) / float(ClientHeight), 0, 100);
	}
	else
	{
		MessageBox(NULL, "Invalid Number Of Dimensions", "ERROR", MB_OK | MB_ICONEXCLAMATION);
	}

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

return;
}

as you would expect, when I use glOrtho, everything is stretched, but not when using gluPerspective

(50 posts!!!)

I think using glScale would work.

I think I may have had it backwards. When you do your resize, try resetting the viewport to use the original client height & width. I.E., if you had your window open at 1024 * 768, use those same numbers on resize. This way, the size of the box/torus/sphere/whatever never changes, but just the way OpenGL views it. I'll take a look at some of my 3D code tonight and make sure, but I think that may work. It's been a while since I've done any good graphics stuff, like 4 years =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.