[Solved] Best way of drawing text in graphics mode
Posted: Fri Aug 19, 2016 3:33 am
Hello.
I need some help with drawing text to the screen. At the moment I have a function that can draw one individual character, and it works very well.
I use this to draw one character:
Now I need a method that would recognize my Input like for example DrawText((Point) {0, 0}, "Abc123Test", ColorRed); and use that function above to draw text at given position. Now I am facing some issues. I have exactly 100 characters. That means 100 different cases inside my switch statement. I don't think that function it is efficient enough. I tried using switch statement but I was getting overlapping issues (if one of the characters inside a string was not the same...etc). I just need a simple but efficient method to recognize my input from my method, draw wanted character, + calculate spacing between characters (character width + 1) and if I type \n I just need to add 16 to my Y.
Let's just begin with:
I hope you all understand what I want.
I need some help with drawing text to the screen. At the moment I have a function that can draw one individual character, and it works very well.
I use this to draw one character:
Code: Select all
InternalDrawCharacter(Point position, int characterWidth, int characterArraySize, Color drawColor, int* character);
Let's just begin with:
Code: Select all
void DrawText(string text, Color colorText, Point position)
{
for(int i = 0; i < stringLength(text); i++)
{
DrawCharacterMethodIneed(position, color, text[i]);
}
}