A quick question here - that maybe is not so OpenGL related, but might be - that I would like a bit of guidance on. I have a full-screen OpenGL application - OpenGL set to render straight onto the TForm. Mostly my users use the Windows Media Centre remote control to navigate around the application - I'd also added some keyboard commands recently - and that works fine.
Recently, a user asked if the mouse could be used and I told them that it was not coded that way, but I would look into it. Today I started and the first thing I wanted to use was the FormMouseWheelDown and FormMouseWheelUp procedures of the TForm to move up and down a list of OpenGL items - so I'm not doing anything complicated like picking - just detecting the FormMouseWheelDown and FormMouseWheelUp events and changing the user interface just as I would with the remote buttons or the up and down arrow keys.
The thing I noticed is that when using a USB-connected mouse with a scroll wheel everything works as you would expect - the selected list item moves up and down. But... I'm using an IBM ThinkPad here... if I try to press the little blue "hold" button while moving the mouse pointer up and down (which does something almost equivalent to FormMouseWheel, in appearance anyway) then I get full-screen flicker on the OpenGL application.
I'm guessing the ThinkPad has specific drivers for the blue "hold" button and I'm also getting a different event to the FormMouseWheel[Down/Up] too. What I'm wondering is whether other laptops include this kind of functionality (and I'm betting they do) and how I might detect and stop those messages causing flickering in my full screen OpenGL application.
Does anyone know off the top of their head how I might stop this flicker, before I start delving into whether it is actually FormMouseDown with middle button pressed (or something like that) that I should be looking at? Or is it something 'outside' of my control, with there probably being specific drivers for the inbuilt mouse functionality on various laptop computers? Any assistance would be appreciated as it might save me some time.
my laptop has something similar, allthough it is not a thinkpad and I am not completely sure as what that fancy blue hold button of yours could be
But it might help, too: There is a button next to the touchpad along with the regular left and right "mouse" button which is used for scrolling in most windows applications like Explorer etc..
Surprisingly using this button does not just emulate an mouse wheel, but moves the mouse cursor temporarily onto the appropriate buttons of the scrollbar itself and presses them. I do not know why the choose that way of implementing this stuff, but obviously they did. And it may be similar with your thinkpad's blue hold button
To be honest - I've no idea as why your form start to flicker around when using it... seems strange to me.
Edit: Oh I almost forgot: You are right, MouseWheelUp /-Down is the right place to go if you want to catch those scrolling events
Hope this helps,
~ Frase
_________________ "Für kein Tier wird so viel gearbeitet wie für die Katz'."
Zuletzt geändert von Frase am Sa Mai 09, 2009 12:39, insgesamt 1-mal geändert.
Pressing the blue button (middle mouse button on a ThinkPad) seems to generate a WM_MOUSEMOVE with wParam being 0 and lParam holding the X and Y mouse coordinates.
Releasing it then does the same - another WM_MOUSEMOVE.
Pressing it and then using the mouse moving nipple to move up and down generates multiple WM_VSCROLL messages with wParam indicating the direction with either a 1 or a 0. That's pretty much as you might expect also, I guess.
I can detect the WM_MOUSEMOVE in Delphi quite easily, but can't yet stop the flickering when I press this blue button, even setting Handled to True. I think this is the key - detecting the blue button press properly and stopping the flicker - the scrolling shouldn't be a problem then.
Thank you for that insight. Yes, I also see a bunch of other one-time messages - WM_IME_SETCONTEXT, WM_IME_NOTIFY, WM_SETFOCUS, WM_KILLFOCUS, WM_IME_SETCONTEXT and another WM_SETFOCUS before the many WM_VSCROLLs... but also a WM_SETCURSOR. MSDN says "The WM_SETCURSOR message is sent to a window if the mouse causes the cursor to move within a window and mouse input is not captured."
I wonder if the blue button on the ThinkPad is trying to do something like set focus to an underlying window - other than my full-screen OpenGL application that obviously has no scroll bars... hence the flickering. I'll continue and see what the OpenGL application can 'swallow' without trace, see if that helps.
I am using an IBM Thinkpad T60 and I have never encountered such problems. Though I have got to admit, I'm doing my very best to avoid using that blue button, because I figure that button all the time works against the user. I just use the button to scroll up and down but this did never cause any flickering on my Screen.
I just checked, what happens, when i actually press the button during an application: No flickering, Nothing
I'm now starting to think this is related to something else. I've tried intercepting and smothering a variety of observed messages but it hasn't stopped this. So, I then started to think that it might be something to do with how I'm setting up full screen OpenGL, but I'm stumped as to why.
For information, my TForm is set up to have no border icons, bi* all = False. It has a BorderStyle of bsNone, a BorderWidth of 0 and a Caption of nothing, i.e. ''. It has a Top of 0, a Left of 0, a Width of Screen.Width and a Height of Screen.Height. I'm not making any calls to SetWindowLong for GWL_STYLE or GWL_EXSTYLE as I haven't seen the need to, yet.
I display my background with the following straightforward code:
Code:
glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_PROJECTION);
glLoadIdentity;
glOrtho (0,1,0,1,-1,1);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity;
{ Static background... }
glColor3f (1,1,1);
glBindTexture (GL_TEXTURE_2D,BackgroundTexture);
glBegin (GL_QUADS);
glTexCoord2f (0,0);
glVertex2f (0,0);
glTexCoord2f (1,0);
glVertex2f (1,0);
glTexCoord2f (1,1);
glVertex2f (1,1);
glTexCoord2f (0,1);
glVertex2f (0,1);
glEnd;
SwapBuffers (DC);
...nothing special there. However, if I comment out just the glBegin (GL_QUADS) block then I get a solid colour background and no flicker. So I started to suspect it was something to do with the background image I was using. However, when I tried not even loading the image, but leaving the glBindTexture in, I then got a plain white quad - as you'd expect - but still experienced the flicker when holding down the ThinkPad's blue button. The last thing I tried was bringing the size of the quad down, so it wasn't at the extreme screen edges by using 0.1 and 0.9 for the limits... still flickered.
So... solid colour with no texture = no flicker, display of quad with no bound texture = flicker, display of quad with a bound texture = flicker, showing a texture that is not full screen = flicker.
Frustrating, to say the least.
So... is there something I should be doing special to my setup if I want full-screen OpenGL rendering to a TForm? Apart from what I'm already doing.
And yet again with SDL... in case you have some ready-to-use templates available
Additional thoughts to throw in:
Seems unlikely, but are you handling the mouse wheel events somewhere else already in a manner that the "camera" is hopping behind the quad so it disappears for a moment?
Almost as unlikely as the above stuff: What's about the zNear and zFar settings? They are maybe causing the flickering stuff by cutting your quad sometimes
Does the flicker still occur when you remove the mouse wheel event handling code? Could be possibly very interesting to know...
Magic issue solving tipps:
Try using Doublebuffering in your Form itself. Via "DoubleBuffered := True;" in your TForm.OnCreate
May the source be with you,
~ Frase
_________________ "Für kein Tier wird so viel gearbeitet wie für die Katz'."
Registriert: Do Sep 02, 2004 19:42 Beiträge: 4158
Programmiersprache: FreePascal, C++
Well, well, sounds really strange.
Did you try a quad without a bound texture and just colored? My attempt would be, that due to some fancy code the drawing gets interrupted, the screen buffer flushed and your quad might be half-drawn.
Next thing: Try another background color and check if the flickering is between black and quad or background color and quad.
In that case, I would also recommend the double buffering approach.
If this does not work... No idea, especially if the things Frase already told had no success.
greetings and good luck
Lord Horazont
_________________ If you find any deadlinks, please send me a notification – Wenn du tote Links findest, sende mir eine Benachrichtigung. current projects: ManiacLab; aioxmpp zombofant network • my photostream „Writing code is like writing poetry“ - source unknown
„Give a man a fish, and you feed him for a day. Teach a man to fish and you feed him for a lifetime. “ ~ A Chinese Proverb
I can't get rid of it, so I have now figured "stuff it"... "how many people have ThinkPads" and "how many of those use the blue button vs. using a real mouse?"
So, I've rationalised it away as it won't affect the majority of my users. If they use the blue button and red nipple expecting things to "wheel" I'll just tell them that it's not actually a "wheel" at all, it's a setfocus and a scroll... so there.
If you plug in a real mouse then it all works perfectly... so, in effect, I have given the user what they wanted.
As an interesting problem to solve, it's way down my list, I'd say.
Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.