In the S.D.L tutorial that I'm following, a pointer is declared at the start of the program, of type SDL_Surface, and assigned NULL. This is later assigned to TTF_RenderText_Solid(arguments...). Does this mean that SDL_Surface is the base class from which TTF_RenderText_Solid is derived? - I read something about SDL_Surface being a struct.

Could someone please help to clear up my confusion?

SDL_Surface is just a structure that holds the needed information for drawing. TTF_RenderText_Solid() will just return a pointer to a block of memory where a SDL_Surface is being stored and then you make a pointer point to the memory location of that object so then you can draw it to the screen.

TTF_RenderText_Solid() is just a function that returns a pointer to a SDL_Surface and is not derived from the SDL_Surface type (because it is a function and SDL_Surface is not a class).

SDL is written in C, so I very much doubt that anything is derived from anything since inheritance in not possible in C. And, yes, SDL_surface is a structure, here is the doc.

Very often (but not always), you should treat SDL_surface pointers and any other pointers from SDL as "opaque pointers", meaning that you should not worry about what it actually points to, that's for the SDL library to worry about. This is similar to windows HANDLE type. Essentially, you should never have to manipulate an opaque pointer yourself, you just get it from SDL functions, then keep it and use it only with other SDL functions. SDL is made such that this is what you should do, but you can also access some low-level information via the fields of the structures like SDL_surface, but for the most part you shouldn't really have to.

Thanks for clearing that up guys :)
Really nice explanations :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.