Run this through gDEBugger (if you have an ATI video card) or something
like apitrace if gDEBugger won’t work for you, and you’ll most likely find
that SDL is changing shaders on you. This is a very annoying thing to work
around: SDL’s renderer wasn’t designed to work with other systems making
render calls, and it behaves as if it owns the entire GL state. So you
need to make sure that, as you mix SDL calls with OpenGL of your own, you
keep the GL render state the same as what SDL’s internal caching thinks it
is. Otherwise, you run into problems like this.
Mason
From: Doug <douglas.linder at gmail.com>
To: SDL Development List
Sent: Thursday, September 5, 2013 6:36 AM
Subject: Re: [SDL] Mixing opengl and renderer?
humm. I saw that thread, but I don’t see any useful actual code from it,
just talk about opengl. I’m specifically interested in mixing both, not
using purely opengl.
Here’s an example of actual code that renders exactly 1 perfect frame of
a red triangle and green square, followed by black.
If you comment out the SDL_RenderCopyEx it renders the triangle
correctly; if you comment out the opengl, it renders the square correctly.
SDL2 OpenGL + Normal renderer example · GitHub
I had a look at the sdl-gpu code, and as far as I can see I’m doing the
same thing; ie. glOrtho with the size matching the renderer size. 
~
Doug.
On Thu, Sep 5, 2013 at 8:27 PM, Gabriel Jacobo <@Gabriel_Jacobo> wrote:
2013/9/5 Doug <douglas.linder at gmail.com>
Is there a good starting point somewhere for mixing the rendering
functions and opengl functions?
I want to implement:
SDL_RenderQuad(
SDL_Renderer *renderer,
SDL_Texture *texture,
SDL_Shader *shader, // ← Written by me, just compiles and uses a
GLSL shader
float *geometry, // 4x x,y point <— Where to draw.
float *uv, // 4x u,v coordinate <— Data for the shader to use.
float *color, // 4x rgba color <— Data for the shader to use.
)
To do useful things like; procedural fog, fading, tinting in real time
(those tint functions are so terrribly slow on surfaces. :(, and generally
speaking to use as a total replacement for SDL_RenderCopyEx, which I find
not particularly useful (largely because it doesn’t let me use a shader).
I setup a opengl 2d context, rendered it, used RenderPresent() and tried
a few things, but I’m having no luck. I can either get the renderer to
draw, or opengl, but not both, even without calling SDL_RenderClear() or
any opengl clear functions.
I’ve seen a bunch of old posts about this, but any actual examples that
work would be really great.
Anyone seen any?
I’m rather fond of just treating everything as pixel surfaces and using
the SDL blit operations, but a few things there are just terribly slow if
you try to do them without using a shader.
A few ideas (and implementations!) from a recent thread:
SDL :: View topic - SDL_RenderCopyEx taking integer arguments...
–
Gabriel.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org