Anyone up to help me create an OpenGL commandline window

Started by zemtex, November 11, 2011, 03:07:54 PM

Previous topic - Next topic

zemtex

Howdy OpenGL people.

Is anyone up to help me solve a few problems creating a custom OpenGL commandline terminal window? I know how to do this in GDI, GDI+ and DirectX9 but I don't know how to do it in OpenGL. I simply want to create a full screen (blackish) terminal window where I can issue commands, just like the old ms-dos command line window. Perhaps 80x25 character screen. You should be able to scroll up and down in the window by using PGUP and PGDOWN.

My problem is that I don't know how to align text in a window and how to give colors to individual commands and characters, that requires that you know where the next character must be drawn and I don't know how OpenGL calculates width of character fonts. When you draw text, it should wrap to the next line of course and so forth.

Here is just a sample of what the terminal window could look like.

I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

Farabi

Hi zemtex,
Well youre the best here about OpenGL, what do you expect from me, but I'll do what I can.

I used this for showing the text


; I took it from Frank Charlet Code
Enter_2D_Mode proc _Width:real4, _Height:real4
local __Width:real8
local __Height:real8

fld dword ptr [_Width]
fstp qword ptr [__Width]
fld dword ptr [_Height]
fstp qword ptr [__Height]
invoke glMatrixMode, GL_MODELVIEW
invoke glPushMatrix
invoke glLoadIdentity
invoke glMatrixMode, GL_PROJECTION
invoke glPushMatrix
invoke glLoadIdentity
invoke glOrtho, FP8(0.0), __Width, __Height, FP8(0.0), FP8(0.1), FP8(100.0)
ret
Enter_2D_Mode endp

; ------------------------------------------------------
; Name: Leave_2d_Mode()
; Desc: Restore previous matrices mode
Leave_2d_Mode proc
invoke glMatrixMode, GL_PROJECTION
invoke glPopMatrix
invoke glMatrixMode, GL_MODELVIEW
invoke glPopMatrix
ret
Leave_2d_Mode endp

fShowText proc x:dword,y:dword,lptext:dword
LOCAL px,py:dword

push x
fild dword ptr[esp]
fstp px
pop eax
push y
fild dword ptr[esp]
fstp py
pop eax
invoke Enter_2D_Mode,FP4(640.0),FP4(480.0)
invoke glTranslatef, FP4(0.0), FP4(0.0), FP4(-1.0)
invoke glColor3f,FP4(1.0),FP4(1.0),FP4(1.0)
invoke lstrlen,lptext
invoke Display_2D_Text,px,py,fnt3d,lptext,eax
invoke Leave_2d_Mode

ret
fShowText endp


For coloring text youll need to use invoke glColor3f,FP4(1.0),FP4(1.0),FP4(1.0) before you wrote any text. You can create a parser so you coloring each single word, but I bet it took times.
I dont know what you need exactly but that is all I know.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Siekmanski

Hello zemtex

What's the name of the font you're using ( I like  :bg )

zemtex

I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.