代码之家  ›  专栏  ›  技术社区  ›  Alexis Wilke

gluTessVertex()的数据参数究竟是什么?

  •  1
  • Alexis Wilke  · 技术社区  · 3 年前

    阅读手册页 gluTessVertex() ,定义如下:

    void gluTessVertex( GLUtesselator* tess, GLdouble * location, void * data);
    

    我想 位置 是顶点,为 数据 至少对我来说,这听起来像是指向我的C++对象的指针,这样我就可以正确处理回调。

    数据
    指定通过顶点回调传递回程序的不透明指针(如gluTessCallback所指定)。

    然而,我发现我能找到的所有示例都对这两个参数使用了顶点指针,甚至在 my implementation ,只有我这样做,它才有效:

    gluTessVertex(tobj, polygon->at(p).f_coordinates, polygon->at(p).f_coordinates);
    

    如果我不这样做,我的输出中的坐标是相当随机的。然而,这几乎不是 不透明 如果GLUT解释 data 指针作为 vertex 位置。。。

    所以我的问题是:我误解了文件,还是文件不正确?


    回调列表,如 gluTessCallback 是:

    void beginData( GLenum type, void *polygon_data );
    void edgeFlagData( GLboolean flag, void *polygon_data );
    void vertexData( void *vertex_data, void *polygon_data );
    void endData( void *polygon_data );
    void combineData( GLdouble coords[3], void *vertex_data[4], 
                      GLfloat weight[4], void **outData, 
                      void *polygon_data );
    void errorData( GLenum errno, void *polygon_data );
    

    我的职能定义如下:

    static void tess_callback_edge(GLboolean edge, font_impl * impl);
    static void tess_callback_begin(GLenum type, font_impl * impl);
    static void tess_callback_vertex(GLdouble const * vertex, font_impl * impl);
    static void tess_callback_combine(
                                      GLdouble coords[3]
                                    , GLdouble * vertex_data[4]
                                    , GLfloat weight[4]
                                    , GLdouble ** out_data
                                    , font_impl * impl);
    static void tess_callback_end(font_impl * impl);
    static void tess_callback_error(GLenum errCode, font_impl * impl);
    
    0 回复  |  直到 3 年前