FTGL artefact

Started by
1 comment, last by 21st Century Moose 8 years, 1 month ago

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?

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

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

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?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement