• ### Popular Now

• 15
• 15
• 11
• 9
• 10

#### Archived

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

# Questions for the pros

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

## 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 on other sites
Who are you callin'' a pro?

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 on other sites
for the first question about fading, why don''t you try something with the alph channel?

JoeMont001@aol.com www.polarisoft.n3.net

##### 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 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 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 on other sites
1 - like others have said transparent quad over the whole screen

2 - glClipPlane(...)
glEnable(GL_CLIP_PLANE0)

3 - whats this i hear about glut

##### 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 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?

For Q2: