Well i would like to do a console (like in quake) and so i use glOrtho but i wan’t to have the coordinates like this:
(x, y)
0,0 ------x-----1,0
| |
| |
| |
y |
| |
| |
0,1-------------1,1
and add text with
glTexCoord2f( u, v); glVertex2f( x, y);
glTexCoord2f(u + 1/16, v); glVertex2f(x+1/MAX_CONSOLE_COLUMN, y);
glTexCoord2f(u + 1/16, v + 1/16); glVertex2f(x+1/MAX_CONSOLE_COLUMN, y-1/MAX_CONSOLE_ROW);
glTexCoord2f( u, v + 1/16); glVertex2f( x, y-1/MAX_CONSOLE_ROW);
x := x + 1/MAX_CONSOLE_COLUMN;
BUT i don’t manage to do it… let’s look some code (sorry , it’s in delphi):
>>>>>>>>>>>>>>>
WM_LBUTTONDOWN:
begin
glViewport(0,0,dwWidth,dwHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.,800/600,0.01,100);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
(*
// WORK a little
glOrtho (-1.0, 1.0, // (left, bottom)
-1.0, 1.0, // (right, top)
-1.0, 1.0);// (znear, zfar)
glTranslatef(0.0, 0.0, 1.0);
*)
glOrtho(g_fOrthoVars[ORTHO_LEFT], g_fOrthoVars[ORTHO_RIGHT],
g_fOrthoVars[ORTHO_BOTTOM], g_fOrthoVars[ORTHO_TOP],
g_fOrthoVars[ORTHO_ZNEAR], g_fOrthoVars[ORTHO_ZFAR]);
glTranslatef(0.0, 0.0, 1.0);
(*
// WORK
glRotatef(180, 1.0, 0.0, 0.0);
glTranslatef( 0.0, 0.0, 1.0);
glTranslatef(-0.55, -0.39, 0.0);
*)
//glTranslatef( 0.0, 0.0, -1.0);
// Axis
glDisable(GL_TEXTURE_2D);
glbegin(GL_LINES);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(1.0, 0.0, 0.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 1.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, 1.0);
glEnd();
Font.Bind();
glEnable(GL_TEXTURE_2D);
glDisable(GL_CULL_FACE);
glColor3f(1.0, 1.0, 1.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
x := 0;
y := 0;
//strText := 'Hello World! Test : ²&é"''(-è_çà)=^$ù*,;:!~#{[|`\^@]}¨£%µ?./§';
case nCurrent of
ORTHO_LEFT : strText := 'ORTHO_LEFT = ';
ORTHO_RIGHT : strText := 'ORTHO_RIGHT = ';
ORTHO_BOTTOM : strText := 'ORTHO_BOTTOM = ';
ORTHO_TOP : strText := 'ORTHO_TOP = ';
ORTHO_ZNEAR : strText := 'ORTHO_ZNEAR = ';
ORTHO_ZFAR : strText := 'ORTHO_ZFAR = ';
end;
strText := strText + FloatToStrF(g_fOrthoVars[nCurrent], ffFixed, 0, 3);
n := Length(strText);
// **********
glBegin(GL_QUADS);
for i:=1 to n do
begin
c := strText[i];
nc := Integer(c);
(*
0 1
3 2
*)
u := (nc mod 16) / 16;
v := 1 - ((nc div 16) + 1 )/ 16;
//glNormal3f(0.0, 0.0, -1.0);
glTexCoord2f( u, v); glVertex2f( x, y);
glTexCoord2f(u + 1/16, v); glVertex2f(x+1/MAX_CONSOLE_COLUMN, y);
glTexCoord2f(u + 1/16, v + 1/16); glVertex2f(x+1/MAX_CONSOLE_COLUMN, y-1/MAX_CONSOLE_ROW);
glTexCoord2f( u, v + 1/16); glVertex2f( x, y-1/MAX_CONSOLE_ROW);
x := x + 1/MAX_CONSOLE_COLUMN;
end;
glEnd();
// **********
SwapBuffers(h_DC);
end;
>>>>>>>
It’s not clean i now but i will clean it when it will works…
Thanks for help, it’s kind of urgent.
TheDD