Re: Help wrapping SDL2.0

new topic     » goto parent     » topic index » view thread      » older message » newer message
mb7001 said...
typedef struct SDL_RWops 
{ 
    Sint64 (SDLCALL * size) (struct SDL_RWops * context); 
. 
. 
. 
} 

I can see that there is a structure being declared there with the type of SDL_RWops, but not sure how to call a struct within a struct. Or even exactly what this line is saying.

According to the SDL Wiki, that structure is a set of callbacks for low-level SDL programming with some additional data tacked on then end (a "type" and some "hidden" data). You can probably skip wrapping it.

If you do want to wrap it, each function callback should be a pointer (e.g. C_POINTER), in which you will store (using poke4()) a value from call_back() that points to a routine_id() of a function with the matching parameters (which are always atoms). In this case, that first callback wants to accept a single parameter that is a pointer to a "SDL_RWopts" struct called "context".

function SDL_RWops_size_callback( atom context ) 
 
    -- 'context' is a pointer to an SDL_RWops structure, use it here as you need 
 
    return 0 -- callbacks must return a value, see relevant documentation for possible values 
end function 
atom SDL_RWops_size_callback_cb = call_back( routine_id("SDL_RWops_size_callback") ) 

Here's a good StackOverflow discussion on Understanding typedefs for function pointers in C.

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu