Home > OS >  SDL_Vertex and SDL_RenderGeometry not found
SDL_Vertex and SDL_RenderGeometry not found

Time:12-31

I made a project with SDL2 under Windows.

When I try to compile it on Linux, these errors occur:

reilbas@reilbas:~/C/a/Labyrinthe-3D-main$ g   -o test -I include src/*.cpp $(sdl2-config --cflags --libs)
src/Affichage.cpp: In member function ‘void Affichage::drawRect(float, float, float, float, SDL_Color&)’:
src/Affichage.cpp:110:17: error: ‘SDL_Vertex’ was not declared in this scope; did you mean ‘SDL_mutex’?
  110 |     std::vector<SDL_Vertex> triUi1 = {
      |                 ^~~~~~~~~~
      |                 SDL_mutex
src/Affichage.cpp:110:27: error: template argument 1 is invalid
  110 |     std::vector<SDL_Vertex> triUi1 = {
      |                           ^
src/Affichage.cpp:110:27: error: template argument 2 is invalid
src/Affichage.cpp:110:29: error: scalar object ‘triUi1’ requires one element in initializer
  110 |     std::vector<SDL_Vertex> triUi1 = {
      |                             ^~~~~~
src/Affichage.cpp:115:27: error: template argument 2 is invalid
  115 |     std::vector<SDL_Vertex> triUi2 = {
      |                           ^
src/Affichage.cpp:115:29: error: scalar object ‘triUi2’ requires one element in initializer
  115 |     std::vector<SDL_Vertex> triUi2 = {
      |                             ^~~~~~
src/Affichage.cpp:120:5: error: ‘SDL_RenderGeometry’ was not declared in this scope; did you mean ‘SDL_RenderCopy’?
  120 |     SDL_RenderGeometry(renderer, nullptr, triUi1.data(), triUi1.size(), nullptr, 0);
      |     ^~~~~~~~~~~~~~~~~~
      |     SDL_RenderCopy
src/Affichage.cpp: In member function ‘void Affichage::displayTri(std::vector<triangle>)’:
src/Affichage.cpp:146:21: error: ‘SDL_Vertex’ was not declared in this scope; did you mean ‘SDL_mutex’?
  146 |         std::vector<SDL_Vertex> verts = {
      |                     ^~~~~~~~~~
      |                     SDL_mutex
src/Affichage.cpp:146:31: error: template argument 1 is invalid
  146 |         std::vector<SDL_Vertex> verts = {
      |                               ^
src/Affichage.cpp:146:31: error: template argument 2 is invalid
src/Affichage.cpp:146:33: error: scalar object ‘verts’ requires one element in initializer
  146 |         std::vector<SDL_Vertex> verts = {
      |                                 ^~~~~
src/Affichage.cpp:151:9: error: ‘SDL_RenderGeometry’ was not declared in this scope; did you mean ‘SDL_RenderCopy’?
  151 |         SDL_RenderGeometry( renderer, nullptr, verts.data(), verts.size(), nullptr, 0);
      |         ^~~~~~~~~~~~~~~~~~
      |         SDL_RenderCopy
src/AllMath.cpp: In static member function ‘static int AllMath::triangleClipAgainstPlane(vec3d, vec3d, triangle&, triangle&, triangle&)’:
src/AllMath.cpp:254:1: warning: control reaches end of non-void function [-Wreturn-type]
  254 | }
      | ^

I installed SDL2 with apt:

$ sudo apt-get install libsdl2

CodePudding user response:

SDL_RenderGeometry() & friends were introduced in SDL 2.0.18:

  • Added SDL_RenderGeometry() and SDL_RenderGeometryRaw() to allow rendering of arbitrary shapes using the SDL 2D render API

...so make sure you're using that version or higher.

SDL 2.0.18 was released in late 2021 so distros like Ubuntu 20.04 that ship older versions of SDL won't have those newer functions.

  • Related