Hello everyone, I have a small problem with SDL2.
In my program I have two functions for drawing elements on the screen.
The first one draws in the ‘SDL_Renderer’ and at the end of the function is shown on screen with ‘SDL_RenderPresent (renderer)’.
The second draws with direct OpenGL functions with ‘glBegin’, ‘glVertex3f’ … and at the end of the function is shown on screen with ‘SDL_GL_SwapWindow (screen)’.
Everything works fine until I want to merge the two functions. My goal is to draw the elements of function 1, then of function 2, and finally display them on the screen together.
My code looks something like this:
---- Function 1 ---- // Another code SDL_RenderCopy (renderer, my_sdl_texture, NULL, & my_sdl_rect); SDL_RenderPresent (renderer); ---- Function 2 ---- // OpenGL operations glBegin (GL_QUADS); glTexCoord2f (0, 0); ... glEnd (); SDL_GL_SwapWindow (screen);
If I only execute function 1, the objects of function 1 are correctly displayed. The same if I only execute the function 2. But when I execute both followed a blinking in the image occurs.
I’ve seen that the ‘SDL_RenderPresent (renderer)’ ends with the ‘SDL_GL_SwapWindow (screen)’, I think that’s the flicker problem.
I tried to remove ‘SDL_RenderPresent (renderer)’ when I execute both functions, but then the elements of function 1 are not visible, only those of function 2.
I have also tried to remove ‘SDL_GL_SwapWindow (screen)’ and put ‘SDL_RenderPresent (renderer)’ instead, but then you do not see the elements of function 2, only those of function 1.
I hope it has become clear and that someone can help me.
Thank you very much.