GPU_Init() is the easy way to get a window and render target created. That will help us catch some mistakes that we might make along the way. With GPU_SetDebugLevel(), we can tell SDL_gpu to print out the errors just as they happen. But we’re just starting off! We need to know right when errors occur. SDL_gpu also maintains an error stack that you can check manually (sometimes a silent program is bliss). GPU_Init() will return a NULL render target on error. Some functions can have an obvious return value when there’s an error. There are a couple of ways that SDL_gpu lets you know when something goes wrong. GPU_Target* GPU_Init(Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags) Void GPU_SetDebugLevel(GPU_DebugLevelEnum level) This doesn’t actually change much in your code, but makes scaling and rotating sprites work without hassle. The most blatant convention difference you’ll see is that GPU_Blit() and the other blitting functions draw sprites at their center instead of from the upper-left corner. They do the same basic things, but SDL_gpu has a lot more functionality and a few different conventions. If you’ve used SDL’s built-in rendering before, then SDL_gpu shouldn’t feel too different. These will be everything we need to put together a simple simulation to play with. To start things off, here’s a listing of the functions we’ll be using: I’ll post installation instructions for SDL_gpu some other time, though if you use SDL then you probably already have that down. If you are comfortable with C or C++ and SDL, then you’re ready for this. Hey there! This is a tutorial on some of the basics of using SDL_gpu. New_node->value = (char*)malloc(size + 1) *node = (StringList*)malloc(sizeof(StringList)) Doesn't technically support UTF-8, but it's probably fine, right? Static StringList* explode(const char* text, char delimiter) Returns a linked list of malloc'ed NULL-terminated strings. No guarantees, you’re granted the code under the MIT license. At least it can’t be any worse than my C++ implementation! This implementation uses malloc(), so it’s going to be a little less performant than a static one, though easier to use. I’m just putting it here for general reference. I was working on porting some code from C++ to C and I couldn’t really find a simple explode() function for C online.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |