Archived

This topic is now archived and is closed to further replies.

Questions for the pros

This topic is 6357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello ppl, I have a number of questions to ask related to OpenGL (3rd question is not related to OpenGL): 1. If I have an object/picture on the screen, how do I fade in/out the entire screen? 2. How do I "clip" the upper and lower portions of the screen. For example, you might have seen when watching a film at the movies. Note: I have used glViewPort() but couldn''t get it to work the way i wanted to. 3. How do I stop an application window from moving? Is there a command to disable it? sig u say?

Share this post


Link to post
Share on other sites
Who are you callin'' a pro?

1. Simple girlie can''t be arsed thinking about it answer:

a) Turn on alpha blending (glEnable(GL_BLEND)) and change the alpha of your object slowly from 1.0 to 0.0 and it''ll gradually fade to the background colour.
b) If you don''t want the hassle of making everything in your scene have an alpha value that you have to control, then draw your whole scene as per normal (GL_BLEND disabled) and then turn on blending and draw a big black quad in front of the camera. Start with it''s alpha value = 0.0 and gradually increase it to 1.0 with each successive frame.

2. Ehm... use big black quads infront of the camera at the top and bottom of the screen?

3. Use black quads..? ehm no... In your message loop (you''re not using glut are you?) you can trap a windows message and prevent it being handled automatically. Unfortunately I can''t remember the correct one you''ll want. Maybe someone else will tell you. I think you can use WM_HITTEST but that might not be the best one.
Anyway, in the appropriate message case (e.g. case WM_HITTEST) just use the code:
    
case WM_HITTEST:
{
return(0);
} break;

and this will prevent your window getting the message to move in the first place.

Laters

=================================================================
I accept no responsibiliy for the fact that I may have plucked the WM_HITTEST keyword out of thin air
=================================================================



Share this post


Link to post
Share on other sites
Another approach:

1. Use the alpha channel, or make all lighting go 100% black (or white).

2. Use another window as background, and put your OpenGL window on top of the first. It must be possible using glViewPort! Maybe posting your code may help...

3. Catch the WM_MOVING. Or use WM_NCHITTEST! as Poontardis pointed out, but then you have to check in what part of a window you are. You can also just create a window without a border! With popup window style for example...


A pro he? I just wish...

Share this post


Link to post
Share on other sites
ok thanx for the responses so far:
for Q1, I''ll try alpha blending and see how that works.
for Q2, glViewport doesn''t work the way i wanted to, for example,
If I create a window and set the glViewport to the same dimension
as the window, I want the object to be drawn all over it BUT, I want some sort of clipping, like clipping the top and bottom
of the screen.
for Q3, I have used WM_MOVING, that is useless (unless I''m using it incorrectly. The problem with WM_MOVING is that if I put a return 0 to that, then nothing happens, that is, the window still moves. If I put a messagebox, then it calls it, but i don''t wnat a messagebox! I just want to user to stop moving the window!!! Hmmm, one of you guys mentioned WM_HITTEST. What is that used for?

And I am not using GLUT. I hate it since I have to use glut.lib or glut.dll can''t remember which one right now....


sig u say?

Share this post


Link to post
Share on other sites
For Q1, The best approach is just putting the big black square in front of everything as described before.


----------------------------------------
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant and she fell on me? Then it wouldn't seem quite so funny.

Share this post


Link to post
Share on other sites

Hi all,
for Q3, using WM_NCHHITTEST is kinda what I want except that I have a close button at the upper right corner and it doesn''t respond to a close. I looked it up, and the doc says DefWindowProc returns HTCLOSE if close button is pressed. Whereabouts do I test that condition? I don''t see a DefWindowProc! could someone give an example of how to capture the return and check for HTCLOSE plz?

sig u say?

Share this post


Link to post
Share on other sites
ok. I know how to do Q2 thanx to zedzeek although I did it by trial and error, it needed an equation, and since it took in 4 params I assumed it might be the coefficients of the line equation such as ax+by+cz+d = 0 . And somehow I got it to work!


for Q3, i found the DefWindowProc but i don''t know what to do with it I tried doing a test such as:
if (DefWindowProc(.....)==HT_CLOSE) {PostQuitMessage(0); return 0;}
but it still would not close the window.

Q1 seems easy yet hard to implement. I enabled ALPHA testing thru glEnable and so I''m kinda lost in how to superimpose the white or black colours onto the screen, so i can see the "fading" effect.



sig u say?

Share this post


Link to post
Share on other sites
Extreme, I don't know if this works but you can give it a try:
        
case WM_NCHITTEST:
{
LRESULT lResult = DefWindowProc(.....);
if (lResult==HT_CLOSE)
{ DestroyWindow(hWnd);
}
return lResult;
}


You can also make a window without a border and do a DestroyWindow on a WM_KEYUP with VK_ESCAPE...


(ps: calling PostQuitMessage(0) will work, but is not so nice. Better to call DestroyWindow(hWnd), then do the PostQuitMessage(0) in the WM_DESTROY)



Edited by - baskuenen on July 18, 2000 12:44:15 AM

Share this post


Link to post
Share on other sites
baskuenen the code u wrote doesn''t work properly.
as soon as i run the program it quits! i tried postquitmessage
instead of destroy window and that didnt work either
by the way, its HTCLOSE...

sig u say?

Share this post


Link to post
Share on other sites
To stop a window from moving, overriding the default handler for WM_MOVING does work, but slightly different:

Instead of just returning NULL, you should set the values of the rectangle in lParam to those of the current window-rectangle...

Hope this works for your program.

Greetings, CondorWitte

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Regarding Q2, Isn''t the scissor test usable here?

Share this post


Link to post
Share on other sites
i understand what you mean there CondorWitte but the window might wove a bit before it goes back to its position. What i want is like when you right click your mouse on that application you see options such as "restore, maximise, minise, move" etc.
Now if I use SYS_MENU when setting up my menu, I can see that the Maximum & Minimum options are disabled, but Move option isn''t! I want to know what command disables the "MOVE" option from the menu.

sig u say?

Share this post


Link to post
Share on other sites