🔒 Locked
need graphical console
Advertisement
Original Post
I'm developing an opengl application. I would like to have a graphical console in the application so that I can see messages as the application runs. Do you guys know where I can get a free console that I can plug into my application? The simpler the better. I checked out Crazy Eddie's Gui System, at www.cegui.org.uk, but it's too much for my needs. thanks for any help.
I'm fairly new to opengl. The idea was to put off writing my own console until a later time so that I can concentrate on other things. I guess I'm gonna have to do it myself. I really need one.
I can already output text. I figure I'll need to use scissor testing. Besides that, not sure what else I'll need.
What would be a good aproach to writing a console? Maybe some tips from you guys that have already made one.
Thanks
I can already output text. I figure I'll need to use scissor testing. Besides that, not sure what else I'll need.
What would be a good aproach to writing a console? Maybe some tips from you guys that have already made one.
Thanks
You could use some array or list that collects all the messages and then put them on your screen. For example, use a std::list, add new messages to the tail and remove from the head if you're out of space (lines you want to display).
Note, however, that using bitmap fonts is very slow, it would be faster to use texture mapped fonts but more difficult to implement.
Note, however, that using bitmap fonts is very slow, it would be faster to use texture mapped fonts but more difficult to implement.
So basically: store the message lines in some kind of list, and then output the list to the screen using a scissors to clip where the output will be going. Got it.
I got my font building here code from here:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=24
I guess they're bitmap fonts. I checked out he's texture-mapped fonts tutorial, but it's windows dependent. I'm using linux. That sucks.
thanks
I got my font building here code from here:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=24
I guess they're bitmap fonts. I checked out he's texture-mapped fonts tutorial, but it's windows dependent. I'm using linux. That sucks.
thanks
Well, basically texture mapped fonts work as follows:
- Create a quad for every character you want to display (e.g. in a display list as you did with your bitmap font). The quads vertices are specified in screen coordinates (with z beeing 0 or at your near clip plane) and contain the texture coordinates for ech character.
- Bind the font texture.
- Set the projection matrix to identity so that no projection will be used.
- Set the modelview matrix to identiy to eliminate camera position
- Render each character by using the display list and moving the position with glTranslatef(...)
Make shure you have blending enabled. If you can't load texures with alpha channels, use a key color to set the alpha when loading. For example, using purple as key color, when loading the texture use a 4 component color format like GL_RGBA and set the alpha component to 0 for each purple pixel.
- Create a quad for every character you want to display (e.g. in a display list as you did with your bitmap font). The quads vertices are specified in screen coordinates (with z beeing 0 or at your near clip plane) and contain the texture coordinates for ech character.
- Bind the font texture.
- Set the projection matrix to identity so that no projection will be used.
- Set the modelview matrix to identiy to eliminate camera position
- Render each character by using the display list and moving the position with glTranslatef(...)
Make shure you have blending enabled. If you can't load texures with alpha channels, use a key color to set the alpha when loading. For example, using purple as key color, when loading the texture use a 4 component color format like GL_RGBA and set the alpha component to 0 for each purple pixel.
Well that's bitmap characters again. You should consider using texture mapped fonts once you're more familiar with OpenGL.
Its really simple. Creating a set of quads is as simple as:
Note: m_size is a 2D vector specifying the size of each character. tex is an array of Rectangles specifying the float texture coordinates of each character in the texture.
Now create a texture which contains the characters. I'd suggest a 8-bit Bitmap since those are read easily an can be used as alpha map.
Rendering is also simple:
Enable blending.
Bind your font texture.
Set your text color. (glColor3f(...))
Render the text by calling the display list for each character and move the position of the next character by m_size.x (width of a character).
I'll send you some code once I have a simple example.
Its really simple. Creating a set of quads is as simple as:
glNewList(chars[character],GL_COMPILE_AND_EXECUTE); glBegin(GL_QUADS); //topleft glTexCoord2f(tex[character].left,tex[character].top); glVertex3f(0.0f,0.0f,0.0f); //bottom left glTexCoord2f(tex[character].left,tex[character].bottom); glVertex3f(0.0f,-m_size.y,0.0f); //bottom right glTexCoord2f(tex[character].right,tex[character].bottom); glVertex3f(m_size.x,-m_size.y,0.0f); //top right glTexCoord2f(tex[character].right,tex[character].top); glVertex3f(m_size.x,0.0f,0.0f); glEnd();glEndList();Note: m_size is a 2D vector specifying the size of each character. tex is an array of Rectangles specifying the float texture coordinates of each character in the texture.
Now create a texture which contains the characters. I'd suggest a 8-bit Bitmap since those are read easily an can be used as alpha map.
Rendering is also simple:
Enable blending.
Bind your font texture.
Set your text color. (glColor3f(...))
Render the text by calling the display list for each character and move the position of the next character by m_size.x (width of a character).
I'll send you some code once I have a simple example.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement