Re: SDL2 Wrapper Not Working Under 4.1.0

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...
Icy_Viking said...

Is there something wrong with my flag values?

public constant SDL_INIT_TIMER = 1, 
                SDL_INIT_AUDIO = 16, 
                SDL_INIT_VIDEO = 32, 
                SDL_INIT_JOYSTICK = 512, 
                SDL_INIT_HAPTIC = 4096, 
                SDL_INIT_GAMECONTROLLER = 8192, 
                SDL_INIT_EVENTS = 16384, 
                SDL_INIT_NOPARACHUTE = 1048576, 
                SDL_INIT_EVERYTHING = SDL_INIT_TIMER and SDL_INIT_AUDIO and SDL_INIT_VIDEO and SDL_INIT_EVENTS and SDL_INIT_JOYSTICK and SDL_INIT_HAPTIC and SDL_INIT_GAMECONTROLLER 

Yes. I can see right here that you've got a problem.

The keywords and and or are logical or boolean (true/false) operators not bitwise (flags/math) operations. You'll need to use the library function or_all() to combine flags.

include std/math.e 
 
public constant SDL_INIT_TIMER = 1, 
                SDL_INIT_AUDIO = 16, 
                SDL_INIT_VIDEO = 32, 
                SDL_INIT_JOYSTICK = 512, 
                SDL_INIT_HAPTIC = 4096, 
                SDL_INIT_GAMECONTROLLER = 8192, 
                SDL_INIT_EVENTS = 16384, 
                SDL_INIT_NOPARACHUTE = 1048576, 
                SDL_INIT_EVERYTHING = or_all({ SDL_INIT_TIMER, SDL_INIT_AUDIO, SDL_INIT_VIDEO, SDL_INIT_EVENTS, SDL_INIT_JOYSTICK, SDL_INIT_HAPTIC, SDL_INIT_GAMECONTROLLER }) 

If you're translating Euphoria constants from C macros, you'll need to be aware of the difference between boolean and bitwise operations.

operation C Euphoria
bitwise AND & and_bits() function
bitwise OR | or_bits() or or_all() function
bitwise XOR ^ xor_bits() function
bitwise NOT ~ not_bits() function
boolean AND && and keyword
boolean OR || or keyword
boolean NOT ! not keyword

Hope this helps.

-Greg

P.S. If you have a lot of code to share, try using Pastey (link on the right of this page under Misc Menu) instead of dumping it all into the discussion directly.

Thanks for the help. Also, thanks for the tip. I made the changes, but the SDL window is still not showing up. I added some more flags I forgot and still nothing. I'm beginning to think that there is some sorta compatbility bug with 4.1.0 and SDL2. My wrapper worked fine under 4.0.5. I might have to go back to that.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu