tigr icon indicating copy to clipboard operation
tigr copied to clipboard

wglMakeCurrent Very Slow

Open nsmryan opened this issue 1 year ago • 2 comments

Thank you for tigr! I've been having a lot of fun with it.

One thing I'm having trouble with though is that I have been finding that the call to wglMakeCurrent on Windows is very slow, ~10-15 ms.

I would really like to use tigr for some GUIs at work (small, no dependencies, and responsive!), but I would like the application to not take so much time just to draw.

I have not been able to figure out the root cause here: there are forum threads discussing similar problems, even similar slow downs, but it is not at all clear what is wrong. I tried to avoid the call to wglMakeCurrent by comparing wglGetCurrentContext and the hglrc field of GLStuff, but I'm not clear enough on the design to know which calls might be omitted if we are already in the current context.

Do you have any thoughts about this? The lines I'm looking at are: https://github.com/erkkah/tigr/blob/ff7307a534082b903446ddcda3aa6f42c7eb4328/src/tigr_win.c#L210

and especially

https://github.com/erkkah/tigr/blob/ff7307a534082b903446ddcda3aa6f42c7eb4328/src/tigr_win.c#L215

which seems to be what is causing the slow down.

Thank you!

nsmryan avatar Jul 23 '23 15:07 nsmryan

Hi there. Thanks for the report.

  • What resolution is your tigrWindow?
  • Do you use the TIGR_AUTO?
  • Are you using more than one window?

Theoretically, we should not need the NULL call, and I guess doing a check like you suggest could be a good idea. I don't have my windows dev env accessible right now, so I can't test atm.

erkkah avatar Jul 23 '23 17:07 erkkah

At the time I was trying 64x64, with TIGR_2X, and only one window.

I'm not sure what to make of my performance tests. TIGR_AUTO did not make a difference if the drawing code is fast (just drawing a simple circle with tigrCircle), but when I added in the 'blur' effect from the examples, tigrUpdate takes 0 ms and the drawing (a simple circle, blurred) takes 25 ms.

nsmryan avatar Jul 24 '23 21:07 nsmryan