Skip to content

csGraphics

Stephen P edited this page Aug 31, 2020 · 10 revisions

CoSprite's Graphics handling. Also for the most part, the "central" hub of the engine; holds the current version number, initializes SDL2 and a window, and more.

Structs

Important Functions

initCoSprite

int initCoSprite(char* iconPath, char* windowName, int windowWidth, int windowHeight, char* fontPath, int fontSize, int renderLayers, SDL_Color transparentColor, Uint32 windowFlags)
Initializes the CoSprite system. Do this once when you're launching the graphical portion of your program, and nowhere else. In order of the function arguments: Adds a window icon, names the window, sets the window width, sets the height, sets the font to be used in text from a font file, sets the amount of priority layers there can be, sets the color to be interpreted as transparent, sets the SDL window flags.

closeCoSprite

void closeCoSprite()
Closes CoSprite. Do this once when you're about to exit your program, or are otherwise done with CoSprite, and nowhere else. It also closes SDL and all its extensions loaded by CoSprite (TTF, Image, and Mixer).

loadIMG

bool loadIMG(char* imgPath, SDL_Texture** dest)
Passing in a string for the path and a de-referenced SDL_Texture* fills in that texture with the image from the path.

loadTTFont

bool loadTTFont(char* filePath, TTF_Font** dest, int sizeInPts)
Pass in a string for the path, a de-referenced TTF_Font*, and the size of the font (pixel height / 2): the function loads the font in.

loadTextTexture

int* loadTextTexture(char* text, SDL_Texture** dest, int maxW, SDL_Color color, bool isBlended)
Used internally by cText to convert a string to a texture. Pass in the text, de-referenced destination SDL_Texture*, max desired width, text color, and the isBlended flag to convert a string. The isBlended flag should always be set to true for wrapped, smooth text.

createFile

int createFile(char* filePath)
Creates an empty file with the given filepath. If already exists, overwrites it.

checkFile

int checkFile(char* filePath)
Checks the amount of lines a given file has.

appendLine

int appendLine(char* filePath, char* stuff, bool addNewline)
Appends a string to the end of a file.

replaceLine

int replaceLine(char* filePath, int lineNum, char* stuff, int maxLength, bool addNewline)
Replaces a line in a file with the given string.

readLine

char* readLine(char* filePath, int lineNum, int maxLength, char** output)
Gets a line from a file, and copies it into *output. No free()ing required.

Clone this wiki locally