Jump to content
  • Advertisement
Sign in to follow this  
globalhost

FTGL artefact

This topic is 923 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Source code:

#include <GLFW/glfw3.h>
#include <SOIL/SOIL.h>
#include <FTGL/ftgl.h>
#include <stdlib.h>
#include <stdio.h>

FTFont *m_font1, *m_font2;
int width = 800, height = 600;

static void error_callback(int error, const char* description)
{
    fputs(description, stderr);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);
}

int main(void)
{
    GLFWwindow* window;
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        exit(EXIT_FAILURE);
    window = glfwCreateWindow(800, 600, "Simple example", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);
    glfwSetKeyCallback(window, key_callback);

    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);

    // ???????? ????????.
    GLuint tex_2d = SOIL_load_OGL_texture
    (
    "object.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID,
    SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

    m_font1 = new FTBufferFont("fonts/Linux Biolinum/LinBiolinum_R.otf");
    m_font2 = new FTBufferFont("fonts/Linux Biolinum/LinBiolinum_R.otf");
    if (m_font1->Error()) return -1;
    if (m_font2->Error()) return -1;
    m_font1->FaceSize(20);
    m_font2->FaceSize(16);

    glClearColor(0.4, 0.5, 0.6, 1.0);


    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, width, 0.0, height, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    while (!glfwWindowShouldClose(window))
    {

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        glTranslatef(0.1, 0.1, 0.0);

        glColor3f(1.0f, 1.0f, 1.0f);
        glBindTexture(GL_TEXTURE_2D, tex_2d);
        glBegin(GL_QUADS);
        glTexCoord2f (0.0f, 0.0f); glVertex3f(200.0, 200.0, 0);
        glTexCoord2f (1.0f, 0.0f); glVertex3f(500.0, 200.0, 0);
        glTexCoord2f (1.0f, 1.0f); glVertex3f(500.0, 500.0, 0);
        glTexCoord2f (0.0f, 1.0f); glVertex3f(200.0, 500.0, 0);
        glEnd();

        glColor3f(1.0f, 1.0f, 1.0f);
        for (int i = 0; i < 1; ++i)
          m_font1->Render("Testing FTGL", -1, FTPoint(50, 50, 0));

        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}

The text in screenshot 1 looks good. (The program is run on the graphics card Radeon HD 7870.)

The text in screenshot 1 looks bad. (The program is run on the graphics card Geforce2 MX 100 / 200.)

 

What needs to be fixed?

 

 

Share this post


Link to post
Share on other sites
Advertisement
My guess is your use of immediate mode, which has been deprecated for at least the time of Copernicus.
Confucius say, “Foolish is the man who solves world hunger, cures cancer, eradicates HIV, but still uses immediate mode.”


L. Spiro

Share this post


Link to post
Share on other sites

It looks like the second shot may not have a depth buffer.  But seriously - GeForce 2 MX?  Somebody has one of those that still works?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!