Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: fonts in Opengl

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    fonts in Opengl

    good morning, I have a problem with a project I'm doing in OpenGL,
    but a problem I do not know how to begin to do this,

    what I want is a sphere of OpenGL (glutsolidsphere) might
    insert a letter (just like a billiard ball) but that this
    in the contours of the sphere (3D) that is not flat but have
    curves is the area, and try to download the FreeType but
    achievement to make it work (using the visual c 2008), I hope I can get a
    idea of how to do it. thanks.

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: fonts in Opengl

    Render the text to a 2D texture.
    Apply the 2D to the sphere.
    Read about FBO (GL_EXT_framebuffer_object) if you don't know how to render to a texture.

    Code examples are here
    http://www.opengl.org/wiki/GL_EXT_framebuffer_object

    and there are various articles on the net.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    595

    Re: fonts in Opengl

    V-man do you have projective texturing in mind or something else?

    john you can also create a texture atlas with glyphs and apply those, not absolutely necessary to render to texture. There are utilities that can help you with that. The big question for you is probably how to generate those texture coordinates.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    Re: fonts in Opengl

    sorry for the question, but as rendering the letters, I am beginning to
    OpenGL, the examples I found are not very clear on the copy and fbo
    Paste the examples I found and I get errors, any help please c.
    thanks!

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: fonts in Opengl

    Quote Originally Posted by ugluk
    V-man do you have projective texturing in mind or something else?
    No, he should just apply it to the sphere. Of course, your text needs to be small. It should not cover the entire texture. You could make a "8" ball or any other pool ball this way.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    Re: fonts in Opengl

    forgiveness that is so slow, but the truth is that I have no idea how
    First, what libraries need?, any instance in which I can base,
    thanks.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    595

    Re: fonts in Opengl

    Probably the simplest thing would be to model your sphere in a modeling program, apply the texture in using whatever mapping method you want, then importing this model into you app.

  8. #8
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    6

    Re: fonts in Opengl

    Thanks for responding,
    But I'm from 0.
    Firstly as I can model ... what program do I need?, as I can make
    export? some algorithm?
    use visual c 2008.

    thanks for answering

  9. #9
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: fonts in Opengl

    Forget the modeling program.
    If you want to learn GL, get the Red Book and learn the basics. The Red Book is online. It covers GL 1.1. It shows how to use GLUT, GLU and GL. I think they use AUX for loading BMP files which is dead and gone now. Use DevIL to load image files, which is here
    http://openil.sourceforge.net
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Oct 2009
    Posts
    595

    Re: fonts in Opengl

    Oh no, not devil. It's a bad program for beginners, since you need a lot of libraries and it's just a wrapper over different libraries anyways. Instead check this out:

    http://nothings.org/stb_image.c

    This is the best.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •