Announcement

Collapse
No announcement yet.

Help Converting C Header

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help Converting C Header

    Hello,

    I am trying to convert a C Header, but have come a little bit unstuck.

    Here is the sample driver program.

    Code:
    int main()
    {
    	void *render = zg_create(ZG_RENDER);
    	
    	void *scene = zg_create(ZG_SCENE);
    	zg_render_add(render, scene);
    	
    	void *node = zg_create(ZG_NODE);
    	zg_scene_root(scene, node);
    	
    	void *light = zg_create(ZG_LIGHT);
    	zg_node_add(node, light);
    
    	void *poly = zg_create(ZG_POLYGON);
    	zg_node_add(node, poly);
    	
    	void *vert = zg_create(ZG_VERTEX);
    	void *norm= zg_create(ZG_VERTEX);
    	zg_polygon_vertex(poly, vert);
    	zg_polygon_vertexnormal(poly, norm);
    	zg_polygon_color(poly, 0, 0, 0.8, 1.0);
    	zg_polygon_type(poly, "triangles");
    	
    	zg_vertex_sphere(vert, norm, 150, 5);
    	
    	zg_render_show(render);
    	
    	return 0;
    }
    The header that I am having 'issues' with is as follows.

    Code:
    DLL_API const char* zg_get_error();
    // A API function usually returns 0 or NULL to indicate error and this function may be called to get the error message.
    
    DLL_API void* zg_create(ZG_TYPE type);
    // Creates and returns a ZeGraph object.
    
    DLL_API int zg_delete(void *object);
    // A ZeGraph object must be deleted safely using this function.
    My conversion of these headers is as follows:

    Code:
    DECLARE Function zg_get_error LIB "zeGraph.DLL" Alias "zg_get_error" () as dword
    '// A API function usually returns 0 or NULL to indicate error and this function may be called to get the error message.
    
    DECLARE Function zg_create LIB "zeGraph.DLL" Alias "zg_create" (zgType as DWORD) as DWORD
    '// Creates and returns a ZeGraph object.
    
    DECLARE Function zg_delete LIB "zeGraph.DLL" Alias "zg_delete" (Object as DWORD) as DWORD
    '// A ZeGraph object must be deleted safely using this function.
    Do these conversions look correct, also, for the first one, how do I use the string that is returned by the function?

    Regards

    Andrew

    ------------------
    --------------
    andrew dot lindsay at westnet dot com dot au
    --------------
    andrew dot lindsay at westnet dot com dot au

  • #2

    DECLARE Function zg_get_error LIB "zeGraph.DLL" Alias "zg_get_error" () as ASCIIZ PTR

    DECLARE Function zg_create LIB "zeGraph.DLL" Alias "zg_create" (BYVAL zgType as DWORD) as DWORD

    DECLARE Function zg_delete LIB "zeGraph.DLL" Alias "zg_delete" (BYVAL Object as DWORD) as DWORD

    > how do I use the string that is returned by the function?
    With the new declaration:

    DIM szError AS ASCIIZ PTR
    szError = zg_get_error()
    MSGBOX @szError
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment

    Working...
    X