In this code:
#include <SFML/Graphics.h>
int _cdecl main(void)
{
sfVideoMode mode = {800, 200, 32};
sfRenderWindow * window;
sfEvent event;
sfVector2f v = {10, 0};
window = sfRenderWindow_create(mode, "SFML window", sfClose, NULL);
sfRenderWindow_setFramerateLimit(window, 60);
sfCircleShape* c1 = sfCircleShape_create();
sfCircleShape_setFillColor(c1, sfGreen);
sfCircleShape_setRadius(c1, 100);
while (sfRenderWindow_isOpen(window)){
while (sfRenderWindow_pollEvent(window, &event)){if (event.type == sfEvtClosed) sfRenderWindow_close(window);}
sfRenderWindow_clear(window, sfYellow);
sfRenderWindow_drawCircleShape(window, c1, NULL);
sfRenderWindow_display(window);
sfCircleShape_move(c1, v);
if ((sfCircleShape_getPosition(c1).x >= 600) || (sfCircleShape_getPosition(c1).x < 0)) v.x *= -1;
}
sfRenderWindow_destroy(window);
return 0;
}
int WinMain(void)
{
return main();
}
64bit
sfVector2f is struct with float x and float y;
When compile with NONE optimization - works fine.
When compile with optimization:
Building main.obj.
\main.c(26): error #3114: [asm] Invalid combination of opcode and operands.
*** Error code: 1 ***
Done.
problem is with code:
v.x *= -1;
Generally at try to change struct member var.