OpenGL Kings.....

Started by
8 comments, last by Esap1 23 years, 10 months ago
Please help me, Im trying to write a Console in OpenGL, write now, Im just trying to get the text up. I have an array defined: char Buffer[MAX_HEIGHT][MAX_WIDTH]; I then have a function FontPuts which displays a string. I have another function that loops through the Buffer array and sets it to spaces, though for testing I turned to the letter a, and found it was trying to print off the right side of the screen, even though I set the MAX_WIDTH to 20, it was printing over 45 chars across the screen. Here is the rest of the code: void Console_class::DrawBuffer() { //Set Up Matrixies for 2D Printing glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, 640, 480, 0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); for(int y1=0; y1<MAX_HEIGHT; y1++) { glRasterPos2f(32,(float)32+(y1*32)); FontPuts(Buffer[y1]); } //Set them Back for 3D glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix gluPerspective(45.0f,(GLfloat)640/(GLfloat)480,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix } void Console_class::SetBuffer() { xpos=ypos=0; for(int y1=0; y1<MAX_HEIGHT; y1++) { for(int x1=0; x1<MAX_WIDTH; x1++) { Buffer[y1][x1] = ''a''; } } } PS: I have been working on this for about 5 days, I would appreciate any help you can offer, or suggestions, or anything, thanks alot.
Advertisement
Take a look at my old console, http://nate.scuzzy.net/uconsole/uconsole.html Its really cheesy, old and buggy, but maybe you can get something from it.

Nate
http://nate.scuzzy.net
Well i would not recommend to use raster func, since they normally are slow as hell, but im quite sure it is your FontPuts that doesnt work correctly...

It properly dont stop printing chars when it is supposed to.


Ries
I wrote a console in OpenGL a while back as well. Between mine and Nate''s I''m sure you''ll figure out a good way to do it.

glconsole



Scott Franke [druid-]
sfranke@usc.edu
druid-'s GL Journal
http://www.gamedev.net/opengl
Hey Druid, Thanks a Lot. I was looking at the source code of the Stone Hedge one(I think), and I saw that none of Header files were there. Im trying to implement the same type of Text you use, but in the loadpic function, what is pic defined as?, thanks a lot, later

Edited by - Esap1 on June 2, 2000 1:26:24 AM
Anyone have some OPENGL Text Drawing Functions, I tried Nehe''s but they dont work too well. Later,
Try here, http://nate.scuzzy.net/gltexfont/ and http://nate.scuzzy.net/common.html here.

Nate
http://nate.scuzzy.net
This may not be what you''re looking for - but have you seen the OpenGL 3DText screensaver that comes with the MSVC help examples?
Complete source code on how to implement Windows''s fonts using OpenGL.

Just thought I''d mention it...

I haven''t looked at the stonehenge code in years.

Just look at glConsole, it should have a much more robust and understandable implementation.

Also look at Nate''s if you haven''t.

Using fixed width bitmap fonts like these programs do is much easier than trying to deal with the complexities of truetype. Though there are libraries to help:
gltt & freetype

but gltt''s page is gone, so I don''t know where you''d get it.

http://www.moonlight3d.org/gltt/



Scott Franke [druid-]
sfranke@gljournal.org
druid-'s GL Journal
http://www.gamedev.net/opengl
Wow. I wonder when I became a moderator.

Scott Franke [druid-]
sfranke@gljournal.org
druid-'s GL Journal
http://www.gamedev.net/opengl

This topic is closed to new replies.

Advertisement