Results 1 to 8 of 8

Thread: 2D OpenGL text rendering with existing app

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 2D OpenGL text rendering with existing app

    if your main goal is just to write 2D text to your 3D scene than you can use the code below
    My experience with the GL text output methods you referred to is that you don't get anti-aliasing and so the text doesn't look very good.
    MFC ... I've been there and since I meet Qt never use it again
    That's great, and perhaps thats eventually the way to go. But from a standpoint of cost, I was hoping I could have Qt perform OpenGL rendering using my existing GL rendering context. I mentioned MFC for completeness, but really, the question is that I have a GL rendering context setup and ready to render, so how do I get Qt to just use that and do its GL rendering.

    I've seen examples of Qt doing 2D rendering in OpenGL and it looks FAR nicer than what I've achieved using the font techniques you included in your reply. So I'm wondering how I can leverage that Qt OpenGL rendering in my existing app.

  2. #2
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60
    Thanks
    23
    Thanked 32 Times in 28 Posts

    Default Re: 2D OpenGL text rendering with existing app

    I dont think this will work for you, but in a QGLWidget I actually just render 2D text with

    Qt Code:
    1. QFont font;
    2. font.setPointSize(10);
    3. renderText(x,y,z,"some text",font);
    To copy to clipboard, switch view to plain text mode 

    this is somewath powerfull because QFont gives a lot of text format options. I have no experience in using Qt with MFC, I am assuming you're using visual studio integration, so I dont know if this renderText will work for you. Good look.
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 2D OpenGL text rendering with existing app

    I noticed that sort of text rendering code in the 2D GL example. But if you look at the other classes involved you end up needing a QGLContext class which houses the OpenGL rendering context.

    The problem is, I can't see a way to tell QGLContext to just use my existing context.

    MFC is not the issue and I don't think the issue has anything to do with MFC.

    Its just that I have already setup an OpenGL rendering context and I'd like Qt to render using that context. Getting Qt to render GL seems to hinge on the QGLContext class, but I'm not sure how to set that up to use an existing GL context.

  4. #4
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60
    Thanks
    23
    Thanked 32 Times in 28 Posts

    Default Re: 2D OpenGL text rendering with existing app

    Perhaps a workaround would be to use Qt opengl context to render text to a image, than import that image to your current gl context. Of course this could have performance issues.
    Or depending the dimension of your project, with more or less work, you could instead of triyng to draw to an existent context, adapt your existent gl methods to draw to the Qt opengl context.
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  5. #5
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 2D OpenGL text rendering with existing app

    Maybe that's what I need to try -- See if I can just use Qt to create the GL rendering context instead of doing it directly with Windows APIs. I suspect that to create a Qt context it expects to create its own windowing surface as well. So the question just migrates to, ok how do I create a Qt GL context attached to my own window I'll take a look at it and see what I can find. If that doesn't work then maybe I'd have to have Qt create the window for me which might get messy because currently MFC creates the window. Not impossible I guess. Time to see how far down the rabbit hole this will go!

    Certainly for a new application (or if there was unlimited time and resources) just doing it all with Qt would be cleaner. I'm hoping I can leverage Qt for some snazzy GL rendering without some major conversion or overhaul of an existing app though.

  6. #6
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60
    Thanks
    23
    Thanked 32 Times in 28 Posts

    Default Re: 2D OpenGL text rendering with existing app

    I just remember some months ago googling the web I find some librarys do draw text in opengl. Dont remember witch library or witch site but perhaps
    you can find other ways to display better quality text than the methods of the previews posts. Than you would avoid messing with qt gl context.
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

Similar Threads

  1. OpenGL rendering and threads
    By brcain in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2008, 09:45
  2. QGraphicsView + OpenGL -> Pixmap rendering issue
    By JoergRe in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2008, 18:41
  3. for the openGl to work should the direct rendering be enabled
    By babu198649 in forum General Programming
    Replies: 1
    Last Post: 27th April 2008, 15:22
  4. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  5. OpenGL rendering problem
    By spud in forum Qt Programming
    Replies: 5
    Last Post: 27th February 2007, 19:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.