使用pybind11修改SDL程序

问题描述

我正在将我的 .cpp 代码修改为图形渲染器,但遇到了一个问题。 这是我的代码

PYBIND11_MODULE(mygameengine,m)
{
    py::class_<GraphicsEngineRenderer>(m,"GraphicsEngineRenderer")
        .def(py::init<int,int>(),py::arg("w"),py::arg("h"))
        .def("GetRenderer",&GraphicsEngineRenderer::GetRenderer,py::return_value_policy::reference);

}

错误太多,我只能展示其中的一部分

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pybind11/include/pybind11/pybind11.h:1316:22: note: 
  in instantiation of function template specialization
  'pybind11::cpp_function::cpp_function<SDL_Renderer *,GraphicsEngineRenderer,pybind11::name,pybind11::is_method,pybind11::sibling,pybind11::return_value_policy>' requested here
    cpp_function cf(method_adaptor<type>(std::forward<Func>(f)),nam...
                 ^
  ./src/Export.cpp:24:14: note: in instantiation of function template
  specialization 'pybind11::class_<GraphicsEngineRenderer>::def<SDL_Renderer
  *(GraphicsEngineRenderer::*)(),pybind11::return_value_policy>' requested
  here
        .def("GetRenderer",(SDL_Renderer*(GraphicsEngineRenderer::*...
         ^
  /Library/Frameworks/SDL2.framework/Headers/SDL_render.h:131:8: note: forward
  declaration of 'SDL_Renderer'

  struct SDL_Renderer;

函数定义如下

  SDL_Renderer* GraphicsEngineRenderer::GetRenderer(){
      return m_renderer;
  }

我真的很想知道如何解决这个问题。我环顾四周,无法弄清楚。 提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)