SFML community forums

Help => General => Topic started by: Takoo on December 26, 2017, 12:42:13 am

Title: How to draw VertexArray ?
Post by: Takoo on December 26, 2017, 12:42:13 am
Hello,
My goal is to draw a tylemap from int*.
After 2 hours of research i didn't resolve my problem :
[Takoo@localhost my_runner_2017]$ make re
rm -f ./src/main.o
rm -f my_runner
gcc -g3 -Wextra -Wall -Werror -I./include   -c -o src/main.o src/main.c
src/main.c: In function ‘main’:
src/main.c:60:50: error: incompatible type for argument 3 of ‘sfRenderWindow_drawVertexArray’
   sfRenderWindow_drawVertexArray(window, vertex, states);
                                                  ^~~~~~
In file included from /usr/local/include/SFML/Graphics.h:46:0,
                 from src/../include/my.h:11,
                 from src/main.c:8:
/usr/local/include/SFML/Graphics/RenderWindow.h:432:25: note: expected ‘const sfRenderStates * {aka const struct <anonymous> *}’ but argument is of type ‘sfRenderStates {aka struct <anonymous>}
 CSFML_GRAPHICS_API void sfRenderWindow_drawVertexArray(sfRenderWindow* renderWindow, const sfVertexArray* object, const sfRenderStates* states);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [<builtin>: src/main.o] Error 1
[Takoo@localhost my_runner_2017]$
 

I don't understand why my sfRenderWindow_drawVertexArray (L.60) wait a * sfRenderStates while every examples on web uses sfRenderStates without "*".

Here is my code :
(click to show/hide)

Thank's for ur help !  :(
Title: Re: How to draw VertexArray ?
Post by: FRex on December 26, 2017, 01:58:56 am
Most examples online are in C++ and not C. The error is clear, you need to pass a pointer to render states to that function.
Title: Re: How to draw VertexArray ?
Post by: Takoo on December 26, 2017, 02:24:04 pm
Most examples online are in C++ and not C. The error is clear, you need to pass a pointer to render states to that function.

Hi, thanks for ur reply.
I found the problem but now my program segfault when I set texture to my RenderState (L.42: states->texture = texture;).
Error :
(click to show/hide)
My code :
(click to show/hide)
Title: Re: How to draw VertexArray ?
Post by: Laurent on December 26, 2017, 07:20:05 pm
states is NULL, you can't access its texture member. You need a valid sfRenderStates instance.