Results 1 to 2 of 2

Thread: glPixelZoom and glBitMap

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    282

    glPixelZoom and glBitMap

    I've created a textbox and would like to control the zoom of the text. The text is created with glBitMap(...). However, when I use glPixelZoom the text size does not change. The code is below. WinRect is a CRect giving the position of the control in windows coordinates. Left, Right, Top, Bottom, give the coordinates of the window in OpenGL. Can any one tell me what is wrong?

    void oglTextBox: raw() { // Draws text box's contents.
    TextMargin = (Top - Bottom) / 20; // Calculate control's internal margin.
    TextZoom = WinRect.Height() * 0.9f / 16;
    // Calculate zoom factor for text.
    glRasterPos2d(Left + TextMargin, Bottom + TextMargin);
    // Set raster position.
    glPixelZoom(TextZoom, -TextZoom);
    // Set zoom factor.
    ((OpenGLWnd *)((oglSection *)Parent)->Parent)->glPrint(Text);
    // Print text.
    }

    // ------------------------------------------------------------------

    void OpenGLWnd::glPrint(CString pString) {
    // Prints specified string at specified raster position.
    glPushAttrib(GL_LIST_BIT); // Save current list base.
    glListBase(FontOffset); // Set offset to start of font set call lists.
    glCallLists(pString.GetLength(), GL_UNSIGNED_BYTE, (GLubyte *)pString.GetBuffer(0));
    // Draw string via indexed call lists.
    glPopAttrib(); // Restore previous list base.
    }

    // ------------------------------------------------------------------

    void OpenGLWnd::BuildFontLists() {
    // Builds fonts for window.
    char Character; // Character being processed.
    int Width, Height; // Width and Height of character being processed.
    float OffsetX, OffsetY; // Offset positions of characters being processed.
    unsigned char Bitmap[18]; // Bitmap of font.

    FILE *InFile = fopen("System.fnt", "r");
    // Open font file.
    if (InFile != NULL) { // If file opened succesfully...
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    // Set packing alignment.
    FontOffset = glGenLists(12; // Reserve calllist space for an entire font set.
    do { // For each font in file.
    fscanf(InFile, "%c %d %d %f %f ", &Character, &Width, &Height, &OffsetX, &OffsetY);
    // Read character descriptors.
    if (Character == '_')
    Character = ' '; // Correct space character.
    int Temp = Height * (Width > 8? 2: 1);
    // Get size of bitmap.
    for (int i = 0; i < Temp; ++i)
    fscanf(InFile, "%x ", Bitmap + i);
    // Read bitmap.
    glNewList(FontOffset + Character, GL_COMPILE);
    // Create call list for character.
    glBitmap(Width, Height, OffsetX, OffsetY, (GLfloat)(Width + 1), 0.0f, Bitmap);
    // Draw the bitmap.
    glEndList(); // End the call list.
    }
    while (Character != ' ');
    fclose(InFile); // Close input file.
    }
    else { // Otherwise note error.
    FILE *Log = fopen("Error.log", "a");
    // Open error log.
    fprintf(Log, "Failed to open font file.\n");
    // Note error.
    fclose(Log); // Close log.
    }
    }

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: glPixelZoom and glBitMap

    glBitmap is not affected by glPixelZoom, only glDrawPixels and glCopyPixels are. Try glDrawPixels with GL_BITMAP instead.

Similar Threads

  1. glPixelZoom
    By imported_xargon in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-03-2006, 05:49 PM
  2. glPixelZoom accuracy
    By agentgonzo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-19-2004, 08:33 AM
  3. glPixelZoom problem
    By in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-18-2003, 01:46 PM
  4. oversampling and glPixelZoom, etc
    By sillst in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-28-2001, 04:43 PM
  5. Use of glPixelZoom
    By jeselviz in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-14-2001, 07:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean