Jump to content
  • Advertisement
Sign in to follow this  
Decrius

FTGL: shadow

This topic is 3907 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

Hi, I'd like to have a little surrounding black around my fonts so they're better visible. Do we have a function for this, or should I draw the font 2 times on the same position (first one somewhat bigger and black, second on the original, white font)? The latter option didn't really work, the second draw string is black too... Code:
#include "FTGLOutlineFont.h"
#include "FTGLPolygonFont.h"
#include "FTGLBitmapFont.h"
#include "FTGLTextureFont.h"
#include "FTGLPixmapFont.h"

class Fonts
{
    public:
        Fonts(char *, int);
        void draw(int, int, char *);

    private:
        FTFont *font;
        FTFont *font_shadow;
};

Fonts::Fonts(char *filename, int size)
{
    font = new (nothrow) FTGLPixmapFont(filename);
    if (!font)
    {
        fatal << "could not allocate memory" << POS;
        quit();
    }

    font_shadow = new (nothrow) FTGLOutlineFont(filename);
    if (!font_shadow)
    {
        fatal << "could not allocate memory" << POS;
        quit();
    }

    font->FaceSize(size);
    font_shadow->FaceSize(size);
}

void Fonts::draw(int x, int y, char *string)
{
    //glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);

    glPushMatrix();
        glRasterPos2f(x, y);
        glScalef(1.0, -1.0, 0.0);

        glColor4f(0.0, 0.0, 0.0, 1.0);
        font_shadow->Render(string);
    glPopMatrix();

    glPushMatrix();
        glRasterPos2f(x, y);
        glScalef(1.0, -1.0, 0.0);

        glColor4f(1.0, 1.0, 1.0, 1.0);
        font->Render(string);
    glPopMatrix();

    glEnable(GL_TEXTURE_2D);
    //glEnable(GL_BLEND);
}
What could be the problem? Oh, and I tried texturefonts, but the font looks way too smooth/anti-aliased...I want them to be somewhat sharp, and the PixmapFont did that better... Thanks, Decrius

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!