There are 2 problems with draw_text(). It draws the text at wrong coordinates, and the text looks like this:Above should read "Hello world!" (the space shows as green background color because it is not drawn).

If you want to continue with glDrawPixels you need to change your pixel reading routine, like Silhouette suggested.

To clarify the problem:

Suppose we have a texture containing 4 characters.The pixels now are laid out in the following way (the numbers represent which character the pixel belongs to):

111222333444111222333444111222333444

or in the file: 111222333444111222333444111222333444

Our character size in pixels is 3 x 3 = 9.

So if you read all 9 pixels at once and in a contigous array, you'd get the following for your 4 characters:

111444333222222111444333333222111444

You see that pixels are intermixed and thus characters are not displayed correctly.

So you need to either apply an offset of one line when reading the characters one by one, e.g. linestart = char_offset + linenum * linesize.

Or you read line by line and distribute the pixels to the different pixels, i.e.in the example you'd read each 111222333444 line and put 111 into the corresponding line of character 1, 222 into the line of character 2 etc.

Don't presume that a thread only exists for your benefit just because you created it, these topics tend to be very high up on googles results,

if i enter "glDrawpixels fontrendering garbage" in google (not a unlikely search term for someone faced with the same problem you had) this very topic is the top result.

Posting the solution to the problem if you figure it out on your own may be valuable to others and even if you consider a problem to be solved others might benefit from further discussion on the topic at hand.

I don't suffer from insanity, I'm enjoying every minute of it.The voices in my head may not be real, but they have some good ideas!