1
Graphics / [SOLVED] Mix RenderWindow with OpenGL
« on: January 28, 2021, 07:48:19 am »
Hello everyone,
I am working on programming a game in which there are two threads, Thread A (which renders using SFML based calls to draw) and Thread B (which uses direct OpenGL based calls). What happens is that I draw some text on screen in Thread A, then pause and switch to Thread B where I draw a Purple Triangle with a blue background. When it switches back from Thread B to Thread A and tries to draw using SFML again, the purple triangle persists and the text does not appear. This triangle then stays on screen forever and nothing overrides it. I am using a RenderWindow when creating my window for the game. I believe that I am missing some call that is needed to switch from OpenGL back to SFML but I am not sure what it is. Maybe it is something else I am missing.
I went and created a fresh .cpp file that contains only the base code needed to run this example. Each Thread runs for 3 seconds then switches (mostly documented in code) and if you run the code, the ESC key is a kill key as it runs in full screen.
I am using the latest version of SFML and GLEW to run this .cpp example file. I have attached the .cpp file (which is the code in the spoiler above)
Please let me know if there is something that I missed in my code that causes it to not be able to switch back from OpenGL drawing to SFML drawing.
I am working on programming a game in which there are two threads, Thread A (which renders using SFML based calls to draw) and Thread B (which uses direct OpenGL based calls). What happens is that I draw some text on screen in Thread A, then pause and switch to Thread B where I draw a Purple Triangle with a blue background. When it switches back from Thread B to Thread A and tries to draw using SFML again, the purple triangle persists and the text does not appear. This triangle then stays on screen forever and nothing overrides it. I am using a RenderWindow when creating my window for the game. I believe that I am missing some call that is needed to switch from OpenGL back to SFML but I am not sure what it is. Maybe it is something else I am missing.
I went and created a fresh .cpp file that contains only the base code needed to run this example. Each Thread runs for 3 seconds then switches (mostly documented in code) and if you run the code, the ESC key is a kill key as it runs in full screen.
(click to show/hide)
I am using the latest version of SFML and GLEW to run this .cpp example file. I have attached the .cpp file (which is the code in the spoiler above)
Please let me know if there is something that I missed in my code that causes it to not be able to switch back from OpenGL drawing to SFML drawing.