|
NeHe's OpenGL TutorialsThis moves the text into the center of the screen. Otherwise it would be more to the right of the screen because it would be drawn from the center to the right. The fancy(?) math does pretty much the same thing as the color setting math does. It moves the text on the x axis from –0.50 to –0.40 (remember, we subtract 0.45 right off the start). This keeps the text on the screen at all times. It swings left and right using COS and counter 1. It moves from –0.35 to +0.35 on the Y axis using SIN and counter 2. // Position The Text On The Screen glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)), 0.35f*float(sin(cnt2))); Now for my favorite part… Writing the actual text to the screen. I tried to make it super easy, and very user friendly. You'll notice it looks alot like an OpenGL call, combined with the good old fashioned Print statement :) All you do to write the text to the screen is glPrint("{any text you want}"). It's that easy. The text will be drawn onto the screen at the exact spot you positioned it. Shawn T. sent me modified code that allows glPrint to pass variables to the screen ...» |
Код для вставки книги в блог HTML
phpBB
текст
|
|