Simultaneous updates in two display contexts in openGL

I have a C # .NET application with which I created a custom image display control. Each image display presents its own display context and draws the image using glDrawPixels (yes, I know it would be better to use textures, I'm planning into futures, but this application is too far away and my time is limited).

Now I am trying to use both images at the same time. That is, when one image moves ten pixels, the second image moves ten pixels. For example:

imageOne.YPan -= 10;
imageTwo.YPan -= 10;
imageOne.Invalidate(); //This forces a redraw.
imageTwo.Invalidate(); //This forces a redraw.

      

Ok, here is the problem I am having. Only one of the images displays overdraw. If I pause between two calls to Invalidate and pause for at least 110 milliseconds, both will redraw, but not at the same time. So it looks like the second image is always trying to catch up with the first. In addition, a pause of 110 milliseconds slows down movement too much.

I tried to post the update and invalidation of each image in my thread, but it didn't help.

At the beginning of the drawing, I make the relevant context relevant, and at the end I call swapbuffers (). I tried adding glFinish to the end of the draw function, but there was no change.

Could it be a graphics card issue? I am stuck using an integrated gpu that only has openGL 1.4.

I hope I have told you in sufficient detail that you can find an answer to my problem.

+1


source to share


2 answers


It's hard to tell what's wrong with what you are doing since you are giving so few details. Here are some pointers that might help.
- before doing anything in context, make sure you make it current. If you want to pan two contexts, make the first one current, adjust it, and then make the second one current and pan it. This is not the real reason why this shouldn't work.
- If it looks like there is a synchronization problem, adding glFinish()

in strategic locations can help fix the problem - As you should always do, sometimes call glError()

and make sure everything went well.
- I'm not sure how this is done within the framework you are talking about, but you have to make sure both contexts get calledswapBuffers()

for each frame.



+1


source


Invalidate

does not immediately redraw. This means the window is invalid and when the message queue ends up from other messages a paint message will be generated and processed. But that won't happen until you finish processing the current message and return to the main message loop, which can delay even more.



In general, OpenGL animation is an exception to the rule of executing the entire drawing inside Control.OnPaint

(or in an event handler Control.Paint

).

0


source







All Articles