1
votes

I am new to SDL and just got a simple platform game with wall jumping and music to run:

http://postimg.org/image/k31mjej1h/

I have spent a lot of time trying to figure out how to implement an OpenGL Shader into this game. I use SDL_Surfaces rendered with an SDL_Renderer. I an OpenGL context initialized in my SDL program, and my question is: How do I set up OpenGL fragment shaders so that they will shade what SDL renders?

My plan is to use a God Ray shader, like the one used here: http://xnauk-randomchaosblogarchive.blogspot.com/2012/10/2d-crepuscular-god-rays.html

1
Im not sure if you'd want to do something this complecated,but Chris ck this ou, you are probably going to modify the shader a bit and if you dont know already youay want to learn a little more about kodern opengl and shaders and how sdl is ompleneted (from a high level perspecrltive) hg.libsdl.org/SDL/file/default/test/testshader.cThe Floating Brain
That is an excellent link! So it looks like the SDL_Texture is bound to an OpenGL quad in DrawGLScene. Is that how I have to draw textures if I want to us shaders?Luminaire
I did it! Here is a video: vimeo.com/161093497Luminaire

1 Answers

4
votes

You should do it like it was a pure OpenGL application but you need to add the SDL_WINDOW_OPENGL flag when creating the window so you application will use OpenGL not DirectX or some other rendering library!