Closed vault-thirteen closed 1 year ago
Hi @vault-thirteen, thank you for the input! I agree that the colour should be generated using the SDL2 function in the example so I have updated the README with updated example. I will leave PollEvent()
as the default because it's easier to write game loop with it in my opinion. The user has choice to use WaitEvent()
if that's not the case.
Thank you, @veeableful !
After struggling several hours with colour bug, I have a suggestion to make the "Hello-World" code example on the main page (ReadMe file) more user-friendly. By that I mean, colours should not be hard-coded as it is now (
0xffff0000
) because it is platform-dependent and does not produce same results on all computers. Instead, it would be cool to set colours via functions.I have written my Hello-World while I was solving the previous isssue. Some parts of it may be useful.
Here, colour is set via
sdl.Color
object andsdl.MapRGBA
function. This is the official SDL way which works everywhere.We use
WaitEvent
function which does not create idle load loops on CPU and is good for beginners like me. When I usedPollEvent
in a loop, even with a delay, one of the CPU cores was loaded to 100% by doing nothing :)You can throw away my pedantic error checks and combining errors.
Thank you.