Author Topic: 4k - TextPrint and SinusScroller  (Read 4929 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
4k - TextPrint and SinusScroller
« on: April 05, 2007 »
hi... as some of you may know, i am working on a 4k intro for breakpoint... i think i will start driving to the party around 8:00am (german time)... first i have to thanks rbraz for trying to help me and converting my code to C... thanks!

Sadly rbraz dont have so much time atm... so i still try to ask the last hours before going to the party, if someone of you guys can/may help me as 4k OpenGL newbie ^^

I want to draw text on screen and use the same font for a sinus scroller... The font i want to use should be generated at runtime and is called "Times New Roman" ^^ If someone can help me, this would be great...

Btw, here are the routines i did a few days ago but i think the routines still suxx... printing text on screen, makes problems on two friends PCs (only a few fames/sec O.O) ... here it works smooth... but when printing text i see that the intro slow down a lot.. (dont know why)

Another thing... i think the best way would be to use a big texture (where all chars are available) and clipping each char for the TextPrint and SinusScroller as Texture...(even, each char of the sinus-scroller should transform in y axis to realize a wave on each char like the wave of the sinusscroller...

many thanks in advance...


Btw: Should i finish and release the 4k at BP... you can be sure to find greetz to Shockwave/S!P, rbraz ... ;) 





- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: 4k - TextPrint and SinusScroller
« Reply #1 on: April 05, 2007 »
Can you salvage anything out of this (attached code and exe)?  It creates bitmap fonts from Windows fonts using Windows API.

Jim
« Last Edit: April 06, 2007 by Jim »
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: 4k - TextPrint and SinusScroller
« Reply #2 on: April 06, 2007 »
Ahhhh... sorry... forgot to post my actual code...

Code: [Select]
// -------- Create Font --------
HFONT font = CreateFont(48, 24, 0, 0, FW_BOLD, false, false, false, ANSI_CHARSET,
   OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE | FIXED_PITCH,
   "Times New Roman");
  SelectObject(hDC, font);
  wglUseFontBitmaps(hDC, 0, 255, m_iFontBase);

Code: [Select]
void Font_DrawText(float x, float y, char *pText)
{
  glPushAttrib(GL_LIST_BIT);
  glListBase(m_iFontBase);

glColor3f  (0.38f,0.45f,0.67f);
glRasterPos2f(x-0.5f, y+1.0f);
  glCallLists(lstrlen(pText), GL_UNSIGNED_BYTE, pText);

  glColor3f  (0.06f,0.12f,0.32f);
  glRasterPos2f(x+1.0f, y-0.5f);
glCallLists(lstrlen(pText), GL_UNSIGNED_BYTE, pText);

  glColor3f  (0.19f,0.27f,0.45f);
glRasterPos2f(x, y);
glCallLists(lstrlen(pText), GL_UNSIGNED_BYTE, pText);

  glPopAttrib();
}

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: 4k - TextPrint and SinusScroller
« Reply #3 on: April 06, 2007 »
I've not done a huge amount of OGL Stuff, but as an idea to help you if your still stuck, I wonder if theres anything handy over in the Nehe Tutorials. 
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: 4k - TextPrint and SinusScroller
« Reply #4 on: April 06, 2007 »
i dont know if there is another (better) way, to create the font using Win32 API for creating a temp bitmap or just doing this stuff with OGL only... however, on nehe i saw a turorial but the source for doing was very long... i need an easy and very small code for doing it in 4k ^^
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: 4k - TextPrint and SinusScroller
« Reply #5 on: April 06, 2007 »
In the code I posted, I create a bitmap you could use as a texture.  The letters (32-127) are arranged in a fixed size grid so you could use GL_QUADS, using the uvs to extract a letter, to draw them which *may* overcome your performance issues with the wglUseFontBitmaps approach.

Jim
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: 4k - TextPrint and SinusScroller
« Reply #6 on: April 06, 2007 »
ahhh... thanks for the source.. i dint noticed it before ^^  i will take a look to your source... (have try to install my new notebook with XP... preinstalled vista (dont like it)... searching like hell for XP compatible drivers.. argh.. a looooong night before party :P
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: 4k - TextPrint and SinusScroller
« Reply #7 on: April 06, 2007 »
result looks very good... i will take a closer look to the source at the party... still having probs finding XP drivers for my vista notebook.. ^^ (the last days dont like me ^^)
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won: