Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to draw VertexArray ?  (Read 1890 times)

0 Members and 1 Guest are viewing this topic.

Takoo

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
How to draw VertexArray ?
« 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 !  :(

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: How to draw VertexArray ?
« Reply #1 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.
Back to C++ gamedev with SFML in May 2023

Takoo

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: How to draw VertexArray ?
« Reply #2 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)
« Last Edit: December 26, 2017, 02:29:36 pm by Takoo »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to draw VertexArray ?
« Reply #3 on: December 26, 2017, 07:20:05 pm »
states is NULL, you can't access its texture member. You need a valid sfRenderStates instance.
Laurent Gomila - SFML developer

 

anything