Re: SFML Wrapper Error?

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...
Icy_Viking said...
petelomax said...
Icy_Viking said...
 
  integer alt = peek4s(event+8) 
  integer control = peek4s(event+13) 
  integer shift = peek4s(event+16) 

I have to say that I would be quite surprised if that should not be

 
  integer alt = peek4s(event+8) 
  integer control = peek4s(event+12) 
  integer shift = peek4s(event+16) 

I did test with changing the +13 part to +12 and I still got the routine bad number error after I changed them to integer values just for testing purposes. I had to change them back to atom types for it to work again.

No, Pete's right. sfBool is typedef'd as an int so the offsets should all be four-byte aligned.

https://github.com/SFML/CSFML/blob/master/include/SFML/Config.h#L150

This is why I always recommend planning out structs with constant instead of using magic numbers.

https://github.com/SFML/CSFML/blob/master/include/SFML/Window/Event.h#L72

//////////////////////////////////////////////////////////// 
/// \brief Keyboard event parameters 
///  
//////////////////////////////////////////////////////////// 
typedef struct 
{ 
    sfEventType type; 
    sfKeyCode   code; 
    sfBool      alt; 
    sfBool      control; 
    sfBool      shift; 
    sfBool      system; 
} sfKeyEvent; 

constant 
    sfKeyEvent__type    =  0, -- sfEventType (int) 
    sfKeyEvent__code    =  4, -- sfKeyCode   (int) 
    sfKeyEvent__alt     =  8, -- sfBool      (int) 
    sfKeyEvent__control = 12, -- sfBool      (int) 
    sfKeyEvent__shift   = 16, -- sfBool      (int) 
    sfKeyEvent__system  = 20, -- sfBool      (int) 
    SIZEOF_SFKEYEVENT   = 24, 
$ 
 
atom alt     = peek4s( event + sfKeyEvent__alt ) 
atom control = peek4s( event + sfKeyEvent__control ) 
atom shift   = peek4s( event + sfKeyEvent__shift ) 

-Greg

Thanks for the tips. I'll keep this in mind.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu