Window Resizing

Hi there,

I’m a beginner in openGL lib. I need to write a programme. User can make smaller the window of programme. But I don’t want the user make window smaller than my constant minimum window borders. Now, I can test how much big window is. Therefore I just need to stop the user. How could I do that?

Thanks in advance.

That depends on what system you are using. Are you on Windoww? Are you using MFC? .NET? c#?
Are you on Linux? Are you using the X library?
Are you on a Mac?
Are you using a toolkit like GLUT, freeGLUT, SDL, Qt, wxwwindows, GFLW?

I’m using Windows and working on Visual Studio 2008. I’m writing codes with c++.

You can call getClientRect to reterive the size of the window.

BOOL WINAPI GetClientRect(
__in HWND hWnd,
__out LPRECT lpRect
);

Supply the Opengl context window handle and a Rect Struct to receive the dimensions.

excume me i’m really a beginner :slight_smile: do you think it’s impossible that do it with ReSizeGLScene() function ?

Yes, you can call Win API functions from your ReSizeGLScene()

ok. but i need to use ReSizeGLScene() twice. One of funcs is resizeWindow. and now I should use ReSizeGLScene as well. How could I do that ?

I think you mix up the terms a bit.

Resizing the window is one thing, you got answer to this above,
and resizing the scene is another.
You can make the drawn objects get smaller and larger by scale matrices. Check this out, from the first lesson, how to setup window in Windows, then later when matrices come into the picture, you will get the idea:
http://nehe.gamedev.net/tutorial/lessons_01__05/22004/

Now I need to make my question more clear I guess :slight_smile:
What I want to do is to make stable my app’s window size after a certain value.

@Avit Thanks for the link.

Actually I’m lazy :slight_smile: If there’s a function to make window stable it’d be perfect and easy for me.

You mean a non-resizable window? Check out the documentation for CreateWindow and CreateWindowEx.
One of the dwStyle or dwStyleEx should do it.

I think he means if the user is resizing the window, it cannot be smaller lets say 320x200.

So i think in the ResizeWindow callback function the incoming new width and height should be checked with a simple if statement, if it goes under a certain limit, set it back to the limit.

Yes. I tried again&again to do it with Resize Func. But I never achieved. Now I’m thinking of another thing. I can check instantly what window’s size is. If user attemting to make window smaller than I want, I start a new window and it’s size is my minimum value. But the other window still living. I want to kill the older window! If I could do that, I’d be the happiest guy in the world.

If they’re running parallel, my idea never be achieved :frowning:

If user attemting to make window smaller than I want, I start a new window and it’s size is my minimum value. But the other window still living. I want to kill the older window! If I could do that, I’d be the happiest guy in the world.

Er, this sounds like madness! Using a sledge hammer to crack a wallnut is the expression that comes to mind!

In your glutReshape call back function you know the requested width and height. Check for the minimum size and if necessary issue a glutReshapeWindow call with the min width or height parameters. There is no need to create extra windows.