簡體   English   中英

未找到 SDL_Vertex 和 SDL_RenderGeometry

[英]SDL_Vertex and SDL_RenderGeometry not found

我在 Windows 下用 SDL2 做了一個項目。

當我嘗試在 Linux 上編譯它時,會出現以下錯誤:

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 | }
      | ^

我用 apt 安裝了 SDL2:

$ sudo apt-get install libsdl2

SDL_RenderGeometry()和朋友 在 SDL 2.0.18 中被引入

  • 添加了 SDL_RenderGeometry() 和 SDL_RenderGeometryRaw() 以允許使用 SDL 2D 渲染器渲染任意形狀 API

...因此請確保您使用的是該版本或更高版本。

SDL 2.0.18 於 2021 年底發布,因此像 Ubuntu 20.04 這樣發布舊版本 SDL 的發行版將不具備這些新功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM