CS作弊器菜单制作指南
Well After the voteing the most wanted tutorial was the openGL menu. So here we go. First off when building a menu you must think, what kind of menu do you want the generic style that everyone uses seems to be the norm, so that is what is discussed here. Another thing to take into consideration is weather or not to use a class or to just wing it, this tutorial will provide you with a way to do menus that does not involve classes, though they can make things much more convinent in the long run. Ok so now you have decided to make a menu, and you have the menu entrys that you will use lined up, now what does every menu need, first off it needs a background, a highlighted item, text, and a way to toggle things on and off. So here we go: Menu Background:
For the menu background i would suggest makeing a DrawBox function or something simmilar, to simplify your code, here is an example of such a function:
void DrawBox(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
{
glBegin(GL_QUADS);
glVertex3f(x,y,z);
glVertex3f(x+width,y,z);
glVertex3f(x+width,y+height,z);
glVertex3f(x,y+height,z);
glEnd();
}
That function will draw us a nice box to use for the menu background. Now that we have a box function we can start drawing the basic elements of the menu, such as title bar and background, for conveince we will use a function to draw our menu, here it is so far, with the code to draw a background and menu bar:
void DrawMenu( void )
{
//Draw The Background
glColor4f(0.0f,0.0f,0.0f,0.25f); // Black See Through Background
DrawBox(200.0f,200.0f,-1.0f,200.0f,300.0f); // X,Y ( 200,200 ) Width-200 Height-300
//Draw The TitleBar
glColor4f(0.0f,0.0f,0.0f,1.0f); // Black Completely Opaque
DrawBox(200.0f,200.0f,-1.0f,200.0f,14.0f); // X,Y ( 200,200 ) Width-200 Height-14
}
So far our menu function will draw us a nice background and a title bar. But what is a menu without text?
Menu Text:
Drawing text is somewhat complicated, so i will not attempt to explain it, here is the code that most people these days are useing to do text:
NOTE: YOU CAN FIND THE FONT CODE AT THE BOTTOM OF THIS TUTORIAL
Whew.. quite a lot of code isnt it, like i said its kinda complex, so for the sake of simplicity i wont explain it all, all you need to know is the glPrint function that will print our text to the screen. So now that we can print things, lets add a title, here is the new DrawMenu function with the title added in :
void DrawMenu( void )
{
//Draw The Background
glColor4f(0.0f,0.0f,0.0f,0.25f); // Black See Through Background
DrawBox(200.0f,200.0f,-1.0f,200.0f,300.0f); // X,Y ( 200,200 ) Width-200 Height-300
//Draw The TitleBar
glColor4f(0.0f,0.0f,0.0f,1.0f); // Black Completely Opaque
DrawBox(200.0f,200.0f,-1.0f,200.0f,14.0f); // X,Y ( 200,200 ) Width-200 Height-14
//Draw The Title
glPrint(201.0f,201.0f,"Tutorial Menu",1.0f,1.0f,1.0f); // Draws the title "Tutorial Menu" at 201,201
// so that it is in the title bar, and so its white
}
NOTE: The font's height is 12 pixels
Ok so now we have a grip on how to use the glPrint and DrawBox functions, menus dont really seem that complex anymore do they :) now on to the rest of the menu!
Menu Entrys:
Alright, now we are ready to add the menu entrys, so first you will need to think of what you want in your menu, for the purpose of this tutorial we will have a wallhack toggle, a lambert toggle, and a wireframe toggle. All three of these hack functions will be controled by boolean varaibles named wallhack,lambart,and wireframe. So here is our code:
void DrawMenu( void )
{
//Draw The Background
glColor4f(0.0f,0.0f,0.0f,0.25f); // Black See Through Background
DrawBox(200.0f,200.0f,-1.0f,200.0f,300.0f); // X,Y ( 200,200 ) Width-200 Height-300
//Draw The TitleBar
glColor4f(0.0f,0.0f,0.0f,1.0f); // Black Completely Opaque
DrawBox(200.0f,200.0f,-1.0f,200.0f,14.0f); // X,Y ( 200,200 ) Width-200 Height-14
//Draw The Title
glPrint(201.0f,213.0f,"Tutorial Menu",1.0f,1.0f,1.0f); // Draws the title "Tutorial Menu" at 201,213
// so that it is in the title bar, and so its white
//Set Menu Entrys
char whEntry[30],lmEntry[30],wiEntry[30];
if(wallhack) // Is the wallhack on?
{
sprintf(whEntry," Wallhack -> %s","On");
}
else
{
sprintf(whEntry," Wallhack -> %s","Off");
}
if(lambart) // Is lambart on?
{
sprintf(lmEntry," Lambart -> %s","On");
}
else
{
sprintf(lmEntry," Lambart -> %s","Off");
}
if(wireframe) // Is wireframe on?
{
sprintf(wiEntry," Wireframe -> %s","On");
}
else
{
sprintf(wiEntry," Wireframe -> %s","Off");
}
//Display Menu Entrys
glPrint(201.0f,226.0f,whEntry,1.0f,1.0f,1.0f);
glPrint(201.0f,238.0f,lmEntry,1.0f,1.0f,1.0f);
glPrint(201.0f,250.0f,wiEntry,1.0f,1.0f,1.0f);
}
Ok now to explain it, first off we draw the title at x201 and y213 this is so the text is in the title bar, and not all the way on the left edge of the menu, then we declare some strings to hold our text, and based on the current state of the hacks they display either on or off, and then finnaly we display them, we still use 201 as the x so the entrys are not rideing on the left side, but you will notice that the y values start at 226 and incriment by 12 to 250, that is because the height of the font is 12. So now we have all our entrys, now to make a highlighted selector type thing.
Menu Highlighted Item:
Well a menu would not be a menu without being able to select things :) so we will use a global int variable to keep track of the selected item, then we will draw a box that will act as the
highlighter for the current item, so here is the code:
void DrawMenu( void )
{
//Draw The Background
glColor4f(0.0f,0.0f,0.0f,0.25f); // Black See Through Background
DrawBox(200.0f,200.0f,-1.0f,200.0f,300.0f); // X,Y ( 200,200 ) Width-200 Height-300
//Draw The TitleBar
glColor4f(0.0f,0.0f,0.0f,1.0f); // Black Completely Opaque
DrawBox(200.0f,200.0f,-1.0f,200.0f,14.0f); // X,Y ( 200,200 ) Width-200 Height-14
//Draw Selected Item
glColor4f(1.0f,0.5f,0.0f,0.7f); // Orangeish Color
DrawBox(200.0f,(214.0f+(menuPos*12)+1),-1.0f,200.0f,12.0f); // Draws the selector bar
//Draw The Title
glPrint(201.0f,213.0f,"Tutorial Menu",1.0f,1.0f,1.0f); // Draws the title "Tutorial Menu" at 201,213
// so that it is in the title bar, and so its white
//Set Menu Entrys
char whEntry[30],lmEntry[30],wiEntry[30];
if(wallhack) // Is the wallhack on?
{
sprintf(whEntry," Wallhack -> %s","On");
}
else
{
sprintf(whEntry," Wallhack -> %s","Off");
}
if(lambart) // Is lambart on?
{
sprintf(lmEntry," Lambart -> %s","On");
}
else
{
sprintf(lmEntry," Lambart -> %s","Off");
}
if(wireframe) // Is wireframe on?
{
sprintf(wiEntry," Wireframe -> %s","On");
}
else
{
sprintf(wiEntry," Wireframe -> %s","Off");
}
//Display Menu Entrys
glPrint(201.0f,226.0f,whEntry,1.0f,1.0f,1.0f);
glPrint(201.0f,238.0f,lmEntry,1.0f,1.0f,1.0f);
glPrint(201.0f,250.0f,wiEntry,1.0f,1.0f,1.0f);
}
Ok you will notice that we added this code before the entrys, this is so it does not completely block them out, we will also use a nice orange color for the selected item. Now as im sure you have guessed the global int that we will use to store the current menu item is indeed called menuPos, so to draw the selector at the correct place we multiply it by the font height, and that will give us the correct y value to draw our box.
--------------------------------------------------------------------------------
And there we go, the DrawMenu function is all done! now all thats left is to make a few functions to toggle things on and off, and of course to move the selector up and down :) so without further adue, here we go.
--------------------------------------------------------------------------------
Menu Manipulation:
Okey dokey, now its time to create functions to allow the user to move up and down, and to select things, they are really easy, so here they are:
void MenuUp()
{
if(menuPos<2)
{
menuPos=1;
}
else
{
menuPos--;
}
}
void MenuDown()
{
if(menuPos>MAXENTRYS-1)
{
menuPos=MAXENTRYS;
}
else
{
menuPos++;
}
}
void MenuSelect()
{
switch(menuPos)
{
case 1:
{
wallhack=!wallhack;
}
case 2:
{
lambart=!lambart;
}
case 3:
{
wireframe=!wireframe;
}
}
}
See told ya it would be simple, the menu down function checks to see if you are at the end, so you dont go past the last entry, that is what MAXENTRYS shuld be, the number of menu entrys in your menu. menuselect checks to see which one is highlighted and toggles the appropriate function on or off.
Menu Keys:
Now somewhere in your hack you will have to have a keywatching procedure, i will not explain how to make on of these, it is in another tutorial of mine somewhere... anyway, all you have to do is watch for the keys you want to corespond to the various menu functions and call MenuUp,MenuDown, or MenuSelect respectivly.
End Garbage:
Well that is how to make a menu, i hope that you enjoyed my tutorial, and i have a few things to say before you are done reading, first off the code in this tutorial was not ment to be copied and pasted, i have not checked it for errors and i have not tested it, i am writeing it as i go, its is purely for example, you can use it if you want, but i give no warentee as to how it will work. Also if you want to add entrys you will have to add more switch cases in menu select, chance the MAXENTRYS in menu down, change the height of the background, and just print more on the screen, thats it. Once again i hope you enjoyed this tuorial, and you can look forward to more wonderful opengl tutorials from me.
NOTE++++++++++++++++++++++++++++++++++++
In order to draw the menu put this in glEnable:
glPushMatrix();
glDisable(GL_TEXTURE_2D);
DrawMenu();
glEnable(GL_TEXTURE_2D);
glPopMatrix();
also MAXENTRYS shuld be 3 in this tut :)
NOTE++++++++++++++++++++++++++++++++++++
--------------------------------------------------------------------------------
The following is the sourcecode of the font functions:
#define FIRST 32
#define LAST 126
static GLubyte bitmapFont[][1+13] = {
{
32,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
33,
0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18
},
{
34,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x36, 0x36, 0x36, 0x36
},
{
35,
0x00, 0x00, 0x00, 0x66, 0x66, 0xff, 0x66,
0x66, 0xff, 0x66, 0x66, 0x00, 0x00
},
{
36,
0x00, 0x00, 0x18, 0x7e, 0xff, 0x1b, 0x1f,
0x7e, 0xf8, 0xd8, 0xff, 0x7e, 0x18
},
{
37,
0x00, 0x00, 0x0e, 0x1b, 0xdb, 0x6e, 0x30,
0x18, 0x0c, 0x76, 0xdb, 0xd8, 0x70
},
{
38,
0x00, 0x00, 0x7f, 0xc6, 0xcf, 0xd8, 0x70,
0x70, 0xd8, 0xcc, 0xcc, 0x6c, 0x38
},
{
39,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x1c, 0x0c, 0x0e
},
{
40,
0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x18, 0x0c
},
{
41,
0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30
},
{
42,
0x00, 0x00, 0x00, 0x00, 0x99, 0x5a, 0x3c,
0xff, 0x3c, 0x5a, 0x99, 0x00, 0x00
},
{
43,
0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff,
0xff, 0x18, 0x18, 0x18, 0x00, 0x00
},
{
44,
0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
45,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
46,
0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
47,
0x00, 0x60, 0x60, 0x30, 0x30, 0x18, 0x18,
0x0c, 0x0c, 0x06, 0x06, 0x03, 0x03
},
{
48,
0x00, 0x00, 0x3c, 0x66, 0xc3, 0xe3, 0xf3,
0xdb, 0xcf, 0xc7, 0xc3, 0x66, 0x3c
},
{
49,
0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x78, 0x38, 0x18
},
{
50,
0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30,
0x18, 0x0c, 0x06, 0x03, 0xe7, 0x7e
},
{
51,
0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07,
0x7e, 0x07, 0x03, 0x03, 0xe7, 0x7e
},
{
52,
0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0xff, 0xcc, 0x6c, 0x3c, 0x1c, 0x0c
},
{
53,
0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07,
0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff
},
{
54,
0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc7,
0xfe, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e
},
{
55,
0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x18,
0x0c, 0x06, 0x03, 0x03, 0x03, 0xff
},
{
56,
0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7,
0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e
},
{
57,
0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x03,
0x7f, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e
},
{
58,
0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00,
0x38, 0x38, 0x00, 0x00, 0x00, 0x00
},
{
59,
0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00,
0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00
},
{
60,
0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60,
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06
},
{
61,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
0xff, 0xff, 0x00, 0x00, 0x00, 0x00
},
{
62,
0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06,
0x03, 0x06, 0x0c, 0x18, 0x30, 0x60
},
{
63,
0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18,
0x0c, 0x06, 0x03, 0xc3, 0xc3, 0x7e
},
{
64,
0x00, 0x00, 0x3f, 0x60, 0xcf, 0xdb, 0xd3,
0xdd, 0xc3, 0x7e, 0x00, 0x00, 0x00
},
{
65,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff,
0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18
},
{
66,
0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7,
0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe
},
{
67,
0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0,
0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e
},
{
68,
0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3,
0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc
},
{
69,
0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0,
0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff
},
{
70,
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff
},
{
71,
0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf,
0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e
},
{
72,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3,
0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3
},
{
73,
0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x7e
},
{
74,
0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06
},
{
75,
0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0,
0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3
},
{
76,
0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0,
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0
},
{
77,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3,
0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3
},
{
78,
0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf,
0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3
},
{
79,
0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3,
0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e
},
{
80,
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe
},
{
81,
0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3,
0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c
},
{
82,
0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0,
0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe
},
{
83,
0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07,
0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e
},
{
84,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0xff
},
{
85,
0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3,
0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3
},
{
86,
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66,
0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3
},
{
87,
0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb,
0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3
},
{
88,
0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c,
0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3
},
{
89,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3
},
{
90,
0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30,
0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff
},
{
91,
0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x3c
},
{
92,
0x00, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x0c,
0x18, 0x18, 0x30, 0x30, 0x60, 0x60
},
{
93,
0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c
},
{
94,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18
},
{
95,
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{
96,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x38, 0x30, 0x70
},
{
97,
0x00, 0x00, 0x7f, 0xc3, 0xc3, 0x7f, 0x03,
0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00
},
{
98,
0x00, 0x00, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3,
0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0
},
{
99,
0x00, 0x00, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0,
0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00
},
{
100,
0x00, 0x00, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3,
0x7f, 0x03, 0x03, 0x03, 0x03, 0x03
},
{
101,
0x00, 0x00, 0x7f, 0xc0, 0xc0, 0xfe, 0xc3,
0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00
},
{
102,
0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30,
0xfc, 0x30, 0x30, 0x30, 0x33, 0x1e
},
{
103,
0x7e, 0xc3, 0x03, 0x03, 0x7f, 0xc3, 0xc3,
0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00
},
{
104,
0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3,
0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0
},
{
105,
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x00, 0x00, 0x18, 0x00
},
{
106,
0x38, 0x6c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x00
},
{
107,
0x00, 0x00, 0xc6, 0xcc, 0xf8, 0xf0, 0xd8,
0xcc, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0
},
{
108,
0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x78
},
{
109,
0x00, 0x00, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb,
0xdb, 0xfe, 0x00, 0x00, 0x00, 0x00
},
{
110,
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00
},
{
111,
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6,
0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00
},
{
112,
0xc0, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0xc3,
0xc3, 0xfe, 0x00, 0x00, 0x00, 0x00
},
{
113,
0x03, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3,
0xc3, 0x7f, 0x00, 0x00, 0x00, 0x00
},
{
114,
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0,
0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00
},
{
115,
0x00, 0x00, 0xfe, 0x03, 0x03, 0x7e, 0xc0,
0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00
},
{
116,
0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x30,
0x30, 0xfc, 0x30, 0x30, 0x30, 0x00
},
{
117,
0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6,
0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00
},
{
118,
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66,
0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00
},
{
119,
0x00, 0x00, 0xc3, 0xe7, 0xff, 0xdb, 0xc3,
0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00
},
{
120,
0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c,
0x66, 0xc3, 0x00, 0x00, 0x00, 0x00
},
{
121,
0xc0, 0x60, 0x60, 0x30, 0x18, 0x3c, 0x66,
0x66, 0xc3, 0x00, 0x00, 0x00, 0x00
},
{
122,
0x00, 0x00, 0xff, 0x60, 0x30, 0x18, 0x0c,
0x06, 0xff, 0x00, 0x00, 0x00, 0x00
},
{
123,
0x00, 0x00, 0x0f, 0x18, 0x18, 0x18, 0x38,
0xf0, 0x38, 0x18, 0x18, 0x18, 0x0f
},
{
124,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18
},
{
125,
0x00, 0x00, 0xf0, 0x18, 0x18, 0x18, 0x1c,
0x0f, 0x1c, 0x18, 0x18, 0x18, 0xf0
},
{
126,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00
}
};
int fontBitmapString(char *str)
{
int len,i;
GLint swapbytes, lsbfirst, rowlength;
GLint skiprows, skippixels, alignment;
len=(int)strlen(str);
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
for(i=0;i < len;i++)
{
char ch = str[i];
if(ch==0) /* end of string */
break;
if(ch < FIRST)
continue;
if(ch > LAST)
continue;
ch -= FIRST;
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, &bitmapFont[ch][1]);
}
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
return(1);
}
void glPrint(int x, int y, char *string, GLfloat red, GLfloat green, GLfloat blue)
{
char buffer[256];
va_list args;
GLfloat color[4], position[4];
GLboolean texturing;
va_start(args, string);
vsprintf(buffer, string, args);
va_end(args);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glGetFloatv(GL_CURRENT_COLOR, color);
glGetBooleanv(GL_TEXTURE_2D, &texturing);
glGetFloatv(GL_CURRENT_RASTER_POSITION, position);
glColor3f(red,green,blue);
glRasterPos2i(x, y);
fontBitmapString(buffer);
glPopAttrib();
glColor4fv(color);
glEnable(GL_TEXTURE_2D);
glPopMatrix();
}