Results 1 to 2 of 2

Thread: Utilizing OGLFT class for rendering text

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2016
    Posts
    18

    Utilizing OGLFT class for rendering text

    Hello all,

    I know that I have two different threads running about rendering text. I am looking at a few different options right now to implement text rendering in my application. Which ever one I can get to render properly first is the solution that I am going to be running with. My first post is mainly about creating a solution from scratch. This post is about using a library to render the text.

    SO far, this solution is the "best" in the sense that I have gone the furthest. I am able to render some text on screen. However, there seems to be a bug in either my implementation or the libraries implementation.

    So, what is happening is that the text is being rendered only when the code glEnable(GL_LINE_STIPPLE) is executed and the glEnable command is executed after I have the OGLFT library code executed. I believe that there is some sort of gl confliction occurring but I can't seem to find out which one. I have attached here a minimalist code of the my application that demonstrates what is occurring (I am assuming that the OGLFT library is already installed). Normally, I would be posting this question on the appropriate mailing list or asking the author. Howver, it seems that the mailing list is non-existent and the two emails that I found concerning this library are non-functionality. I am hoping that there is someone here on the forum that has some experience on using this library and can assist on debugging the code.


    Code :
    double _zoomX = 1.0;
     
    double _zoomY = 1.0;
     
    double _cameraX = 0;
     
    double _cameraY = 0;
     
     
     
    /* This function gets called everytime a draw routine is needed */
    void modelDefinition::onPaintCanvas(wxPaintEvent &event)
    {
    	wxGLCanvas::SetCurrent(*_geometryContext);// This will make sure the the openGL commands are routed to the wxGLCanvas object
    	wxPaintDC dc(this);// This is required for drawing
     
        	glMatrixMode(GL_MODELVIEW);
        	glClear(GL_COLOR_BUFFER_BIT);
     
        	updateProjection();
     
    	OGLFT::Monochrome *testface = new OGLFT::Monochrome( "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf", 8);
            testface->draw(0, 0, "test");
            glEnable(GL_LINE_STIPPLE);// When I comment out this line, the text is unable to be drawn
     
            glLineStipple(1, 0b0001100011000110);
            glBegin(GL_LINES);
                glVertex2d(_startPoint.x, _startPoint.y);
                glVertex2d(_endPoint.x, _endPoint.y);
            glEnd();
            glDisable(GL_LINE_STIPPLE);
     
        SwapBuffers();
    }
     
    void modelDefinition::updateProjection()
    {
            // First, load the projection matrix and reset the view to a default view
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
     
        glOrtho(-_zoomX, _zoomX, -_zoomY, _zoomY, -1.0, 1.0);
     
        //Reset to modelview matrix
    	glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
     
        glViewport(0, 0, (double)this->GetSize().GetWidth(), (double)this->GetSize().GetHeight());
        /* This section will handle the translation (panning) and scaled (zooming). 
         * Needs to be called each time a draw occurs in order to update the placement of all the components */
        if(_zoomX < 1e-9 || _zoomY < 1e-9)
        {
            _zoomX = 1e-9;
            _zoomY = _zoomX;
        }
     
        if(_zoomX > 1e6 || _zoomY > 1e6)
        {
            _zoomX = 1e6;
            _zoomY = _zoomX;
        }
     
        glTranslated(-_cameraX, -_cameraY, 0.0);
    }

    I would kinda prefer to go with this solution as I do not need to write a vertex shader/fragment shader and this solution here seems to be the more portable.

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2016
    Posts
    18
    Hey all,

    I was able to narrow it down to a simple issue. I believe there is an issue with the library. I changed namespaces from monochromatic to greyscale and I was able to draw the text in black without any issues!

Similar Threads

  1. Text rendering class does not draw text
    By th0masr0ss in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-23-2015, 09:10 PM
  2. oglft fails to render properly with glDrawPixels
    By rakeshthp in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-21-2013, 06:57 PM
  3. Utilizing your GPU to do non-real time background rendering?
    By giantsquidman in forum OpenGL: User Software
    Replies: 1
    Last Post: 01-10-2004, 08:50 AM
  4. Did anyone get text to work in your MFC DOC class using NeHe's?
    By KenR7A in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-09-2002, 07:10 PM
  5. Utilizing Graphics Card
    By ksanim in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-03-2001, 10:24 PM

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