My code is kind of a Rube Goldberg machine–I’m trying to execute a shader, using sdl_gpu, which is built on SDL, and I’m trying to do it in Ada.
But I think my problem is more fundamental than that. So fundamental that nobody asks it, so I can’t find the answer. My question is how do I apply a shader?
Tutorials always talk about installing the shader, which I can definitely do. I know this because if I do it wrong, it doesn’t show black, but instead shows the image I want to eventually process. So if it turns black, I’m at least telling the GPU not to do the normal thing.
My question is more like, I’ve installed the shader (I think) but what do I do now? Do I have to pass it a quadrilateral to draw on? Does installing it make it automatically adjust anything I draw? When should I activate it? When should I deactivate it? How do I know it’s done before I deactivate it?
I’ve been at it for months. Read the Orange Book. Read the whole sdl_gpu documentation. Countless tutorials. Invariably, my shader compiles fine but just shows black. Black black black.
According to the Orange Book, if I don’t specify a vertex shader, it will just default to the default Vertex stuff, which… I guess is a good thing? I didn’t have anything I wanted or needed to do at the vertex level. I’m trying to (eventually) adjust a flat image. You know, Gaussian Blur, Rain, that kind of thing. But before I do anything that complicated, I just want the screen to turn orange. Why orange? Well, it’s my favorite color, but more importantly, it’s not black, so if the screen turns orange, I’ll know it works.
Here’s my fragment shader code:
#version 130
void main()
{
gl_FragColor = vec4(1.0, 0.5, 0.0, 1.0);
}
Sources disagree about whether I’m supposed to declare my own out variable to set the color to, or use this gl_FragColor. I’ve tried it both ways and both ways it’s all black. I’ve also tried it with a generic passthrough vertex shader, and with or without, it’s also always black.
The one thing I suspect is that I can find nothing in the sdl_gpu documentation to bind the output (analogous to glBindFragData). So not being able to do that may (or may not) be an issue.
I can post my application code, if anybody feels up to the challenge of debugging something so far abstracted. But like I mentioned, I have a feeling it’s something I misunderstand about the process.
Thanks! I hope I don’t sound as frustrated as I feel, haha.