Hmmph. Must be something i am doing wrong then. Here is my test case as simple as i can get it and as close to C as possible (i use D so ignore the .ptr it just converts string to char* and the switch/case/default may be a little different but that should be it in the way of differences).
const sfContextSettings settings;
sfRenderWindow* win = sfRenderWindow_create(sfVideoMode(800,600,32), "SFML Test", sfDefaultStyle, &settings);
sfImage* fg = sfImage_createFromColor(400, 300, sfGreen);
sfTexture* fgt = sfTexture_createFromImage(fg, null);
sfSprite* fgs = sfSprite_create();
fgs.sfSprite_setTexture(fgt, 0);
sfRenderStates state;
string frag = r"
void main() {
gl_FragColor = vec4(1,0,0,1);
}";
sfShader* shader = sfShader_createFromMemory(null, frag.ptr);
state.shader = shader;
state.blendMode = sfBlendAlpha;
sfEvent event;
while (sfRenderWindow_isOpen(win)) {
while (sfRenderWindow_pollEvent(win, &event)) {
switch (event.type) {
case sfEvtClosed:
sfRenderWindow_close(win);
continue;
default:
}
}
sfRenderWindow_clear(win, sfBlack);
//sfRenderWindow_drawSprite(win, fgs, &state); //Causes crash
sfRenderWindow_drawSprite(win, fgs, null);
sfRenderWindow_display(win);
}
So down by the last few lines, when i render the sprite with the state it instantly crashes however if i draw it without the state then it works and draws a green rect up the top left of the screen. If the state where to work along with the shader then it would draw a red rect instead.
What am i doing wrong here?