Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using OpenGL Text Output with DIB Section

Using OpenGL Text Output with DIB Section

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beko
    wrote on last edited by
    #1

    Hello, I am creating an outline font as below, and use it with PrintOutlineString, when i use these functions without DIB Section (which i use for printing) it works. However, when i use the DIBSection, i cannot display texts. May be a bit off-topic in this forum, however if anyone used both together and how? Thanks in advance. Bekir. unsigned int CreateOutlineFont(char *fontName, int fontSize, float depth) { HFONT hFont; // windows font unsigned int base; base = glGenLists(256); // create storage for 96 characters if (stricmp(fontName, "symbol") == 0) { hFont = CreateFont(fontSize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName); } else { hFont = CreateFont(fontSize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, fontName); } if (!hFont) return 0; SelectObject((*m_dib.GetDC()), hFont); wglUseFontOutlines((*m_dib.GetDC()), 0, 255, base, 0.0f, depth, WGL_FONT_POLYGONS, gmf); /* SelectObject(m_hDC, hFont); wglUseFontOutlines(m_hDC, 0, 255, base, 0.0f, depth, WGL_FONT_POLYGONS, gmf); /**/ return base; } void PrintOutlineString(double x, double y, char *str) { float length = 0; if ((str == NULL)) return; // center the text for (unsigned int loop=0;loop<(strlen(str));loop++) // find length of text { length+=gmf[str[loop]].gmfCellIncX; // increase length by character's width } glPushMatrix(); glLoadIdentity(); glTranslatef(x,y,0.0f); // translate to center text //glScalef(0.25,0.25,0.25); // draw the text glPushAttrib(GL_LIST_BIT); glListBase(listBase); glCallLists(strlen(str), GL_UNSIGNED_BYTE, str); glPopAttrib(); glPopMatrix(); }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups